华佗小知识
您的当前位置:首页Mysql中关于索引操作的经验分享

Mysql中关于索引操作的经验分享

来源:华佗小知识
 索引是不由存储空间,如果使用恰当,是可以提高查询效率呢

本文就展示一下索引的增、删操作

1.查询一下mysql上的索引信息

命令:

 show index from staff;
Output:
mysql> show index from staff;
Empty set (0.00 sec)

2.增加普通索引

命令:

create index idx_staff on staff(id);

3.增加UNIQUE索引

命令:

create unique index idx_unique_staff on staff(id);

Tips:

不能用CREATE INDEX语句创建PRIMARY KEY索引

4.通过alter命令来增加索引

命令:

alter table staff add index idx_staff_byAlter (id);

5.删除索引

命令1:

 drop index idx_staff on staff;

6.命令2:

alter table staff drop index idx_staff_byAlter;

显示全文