ALTER TABLE tbl_name ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name];
另外,如果不写FIRST或AFTER col_name,则新加入的列将添加到所有列的最下面。
ALTER TABLE tbl_name ADD [COLUMN] (col_name column_definition,...);
ALTER TABLE tbl_name DROP [COLUMN] col_name;
也可以在删除列的同时,又增加新列,这些语句只需用逗号分隔开即可。
ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...);
ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...);
ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...) reference_definition;
ALTER TABLE tbl_name ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT};
ALTER TABLE tbl_name DROP PRIMARY KEY;
ALTER TABLE tbl_name DROP {INDEX|KEY} index_name;
ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol;
ALTER TABLE tbl_name MODIFY [COLUMN] col_name col_definition [FIRST | AFTER col_name];
ALTER TABLE tbl_name CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name];
方法一:
ALTER TABLE tbl_name RENAME [TO|AS] new_tbl_name;
方法二:
RENAME TABLE tbl_name TO new_tbl_name [,tbl_name2 TO new_tbl_name2] ...;