mysql 添加索引、删除所有、查询索引
1、创建索引
create index 自定义索引命名 on 表名(需要加索引的字段);
create unique 自定义索引命名 on 表名(需要加索引的字段);
create primary key 自定义索引命名 on 表名(需要加索引的字段);
或者
alter table 表名 add index index_name (需要加索引的字段)
alter table 表名 add unique (需要加索引的字段)
alter table 表名 add primary key (需要加索引的字段)
2、移除索引
drop index 自定义的索引命名 on 表名
或者
alter table 表名 drop index 自定义的索引命名
3、查询表索引
show index from 表名
或者
show keys from 表;
还没有评论,来说两句吧...