1.添加单列;
ALTER TABLE tb_name ADD[COLUMN] col_name column_definition[FIRST|AFTER col_name];
2.添加多列
ALTER TABLE tb_name ADD[COLUMN] (col_name1,col_name2……);
3.删除列
ALTER TABLE tb_name DROP col_name;
4.删除多列
ALTER TABLE tb_name DROP col_name1,col_name2……;
5.添加主键约束
ALTER TABLE tb_name ADD[CONSTRAINT[symbol]] PRIMARY KEY [index_type](index_col_name,……);
6.添加唯一约束
ALTER TABLE tb_name ADD [CONSTRAINT] UNIQUE [INDEX|KEY][index_name][index_type](index_col_name,……);
7.添加外键约束
ALTER TABLE tb_name ADD [CONSTRAINT[symbol]] FOREIGN KEY [index_name](index_col_name,……) reference_definition;
例:ALTER TABLE users2 ADD FOREIGN KEY (pid) REFERENCES province (id)
8.添加/删除默认约束
ALTER TABLE tb_name ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT};
9.删除主键约束
ALTER TABLE tb_name DROP PRIMARY KEY
10.删除唯一约束:字段仍然存在
ALTER TABLE tb_name DROP INDEX {INDEX | KEY} index_name
11.删除外键约束
ALTER TABLE tb_name DROP FOREIGN KEY fk_symbol
12.修改列定义
ALTER TABLE tb_name MODIFY [COLUMN] col_name collumn_definition [FIRST | AFTER col_name];
ALTER TABLE tb_name CHANGE [COLUMN] old_col_name new_col_name column_definition
[FIRST | AFTER ] col_name;
13.数据表更名(尽量少使用)
(1)ALTER TABLE tb_name RENAME [TO|AS] new_tb_name
(2) RENAME TABLE tb_name TO new_table_name,[tb_name2 TO new_tb_name2]
可以为多张数据表更名