索引是不由存储空间,如果使用恰当,是可以提高查询效率呢
本文就展示一下索引的增、删操作
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;

以上就是Mysql中关于索引操作的经验分享的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号