A modified table name
ALTER TABLE old_table_name Rename [to] New_table_name
Eg:alter Table T_dept
RENAME tab_dept;
Two add fields
1) Add field at the last position of the table
ALTER TABLE table_name
ADD Property Name Property type
Eg:alter Table T_dept
ADD Descri varchar (20);
2) Add a field to the first position in the table
ALTER TABLE table_name
ADD Property Name property type first;
3) Add a field after the specified field in the table
ALTER TABLE table_name
ADD Property Name Property type
After property name;
Three delete fields
ALTER TABLE table_name
DROP attribute name;
Four modified fields
1) Modify the data type of the field
ALTER TABLE table_name
MODIFY Property name Data type
Eg:alter Table T_dept
Modify Deptno varchar (20);
2) Change the name of the field
ALTER TABLE table_name
Change old property name new property name old data type
Eg:alter Table T_dept
Change LOC location varchar (40);
3) Modify the name and attributes of the field at the same time
ALTER TABLE table_name
Change old property name new property name new data type
Eg:alter Table T_dept
Change LOC location varchar (20);
4) Modify the order of the fields
ALTER TABLE table_name
MODIFY Property name 1 data type first| After property name 2
Eg:alter Table T_dept
Modify Deptno Int (one) after dname;
This article from the "Walk and Stop" blog, reproduced please contact the author!
mysql-Modifying a table