mysql 添加索引、删除所有、查询索引

柔光的暖阳◎ 2022-09-10 02:25 31阅读 0赞

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 表;

发表评论

表情:
评论列表 (有 0 条评论,31人围观)

还没有评论,来说两句吧...

相关阅读