本文就展示一下索引的增、删操作
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;
Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务