MySql:索引,结构
文章目录
- 注意事项
- 结构
注意事项
- 主键字段在建表时,会自动创建主键索引
- 添加唯一约束时,数据库实际上会添加唯一索引。
解释:
增:创建:
create [unique] index 索引名 on 表名 (字段名……);-- 举例 :给tb_emp的字段name建立一个索引
create index idx_emp_name on table tb_emp(name);
删:
drop index 索引名 on 表名;-- 举例
drop index idx_emp_name on tb_emp;
查看:
show index from 表名;-- 举例
show index from tb_emp;
结构
MySQL数据库支持的索引结构有很多,如:Hash索引、B+Tree索引、Full-Text索引等。
我们平常所说的索引,如果没有特别指明,都是指默认的 B+Tree 结构组织的索引。