- 增加约束条件 alter table [表名] add constraint [约束];
如alter table users add constraint primary key(username,birthdate); - 去掉约束条件 alter table [表名] drop PRIMARY KEY | INDEX | FOREIGN KEY;
- 修改列类型 alter table [表名] modify column [列名] [新类型];
- 增加列 alter table [表名] add column [列名] [新类型] [列级约束] ;
如alter table users add column id int auto_increment primary key; - 修改原来的某列为自增主键。alter table [表名] modify column [主键列名] int(10) auto_increment primary key;