Table Creation Create Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')); Create a table for the specified Database Engine Create Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')) Engine = memory ; Create temporary table Create Temporary Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')); Copy Data Table Structure (You can also create a temporary table as a copy. Create Temporary Table tblnew like tblold) Create Table tblnew like tblold copy data at the same time insert into tblnew select * From tblold Create a table from the query results Create Table tblnew select * From tblold Delete A data table Drop table tbl_nameddrop table tbl_name, tbl2_nameddrop table if exists tbl_nameddrop temporary table tbl_name Modify a data table
Modify the Data Type of a data column Alter table mytbl modify I mediumint unsignedalter table mytbl Chang I mediumint unsigned Modify the data type and character set of a data column Alter table mytbl modify I mediumint Character Set ucs2 Modify the storage engine of a data table Alter table mytbl engine = engine_name Rename a data table Alter table tbl_name Rename to new_tbl_namerename talbe tbl_name to new_tbl_name Rename multiple data tables
Rename talbe tbl_name to new_tbl_name, T1 to T2, T3 to T4 Move data tables to another database ALTER TABLE Db1. Tbl_name Rename Db2. New_tbl_namerename talbe Db1. Tbl_name Db2. New_tbl_name