mysql-alter语句常用操作

删除列

alter table table-name drop col-name

增加列(多列)

alter table table-name add col-name col-type comment 'xxx', add col-name col-type(col-length) comment 'xxx';

修改列类型、长度

alter table table-name modify column col-name col-type(col-type);

添加索引

alert table table-name add index index-name (col-name);

添加唯一限制条件索引

alert table table-name add unique index-name(col-name);

 删除索引

alter table tablename drop index index-name;

联合唯一索引

alter table tablename add unique index index-name (col-1-name, col-2-name);

查看索引

show index from tbl_name;

 

posted @ 2018-03-01 11:12  秋水秋色  阅读(1430)  评论(0编辑  收藏  举报