Change the structure of the data table:
ALTER TABLE Tb_name Action,[action,action] (before using ALTER TABLE, you need to see the current definition of the data table and need to execute the show CREATE TABLE statement)
ALTER TABLE Tb_name modify columns+ data type
ALTER TABLE Tb_name change column_name column_new_name+ data type
Change changes the table name and data type, MODFY can only change the data type
You can also change the character set: ALTER TABLE tb_name modify T char () Character Set USC2
For data columns, when two data columns have the same data column, the comparison is much faster
Char (a more slow comparison of the char (
Change the storage Engine:
ALTER TABLE table_name ENGINE=ENGINE_NAME if the data column includes a BLOB data column, it cannot be converted to a memory engine,
Because the memory engine does not support blobs,
When InnoDB defines an external check constraint, the foreign key is lost when the storage engine is converted, and only InnoDB supports the foreign key
Renaming a data table
(1) ALTER TABLE Tb1_name Rename to New_tb1_name
(2) Rename table Tb1_name to New_tb1_name
ALTER TABLE can only modify one data table at a time, but rename ... to can be modified together by multiple: rename table T1 to t2,t2 to T3,...
If you add a database prefix to the renaming, you can migrate the data table from one database to another database.
Alter Table to Table to B.tb1_name
MySQL Study notes Day sixth