MySQL instructions are basically divided into three categories: DDL(Data definition Language), DML(Data manipulation language), and DCL(Data Control language).

DDL: The function of DDL directive is to define DATabase, table, index, view, column, etc.

The difference between DDL and DML is that DDL defines and modifies the structure of a table. DML can only process data in a database, but cannot change the structure of a table.

Keywords: INSERT, delete, update, SELECT, drop, etc. Common DDL languages include:

create database db_name; // Define the database

Create table tb_name(// Define a table

Id int(5), // define column

name varchar(10)

);

create view view_name as select id fROMtb_name; // Define the view

If you have a problem with C/C++ one item is a very enthusiastic one (● ‘◡’ ●).

Alter table tb_name add columnTexttext [first/after existing column name]; // Add a text column

Later table tb_name change Old column name New column name Data type; // Change the column name of a column in the table

Alter table tb_name modify column name new data type; // Change the data type of a column

Alter table tb_name rename new table name; // Change the name of the table

alter table tb_name engine=innoDB/MyISAM… // Modify the storage engine of the table

alter table tb_name add index idx_name on tb_name(id); Index idx_name based on id column;

alter table add unique(name); // create unique index name;

Alter table add primary key

Alter TABLE TB_name DROP column name // Drop a column of a table

drop index index_name on tb_name; // Drop an index of the table

show index from tb_name; // Check the index of the table