文章目錄
- 注意事項
- 結構
注意事項
- 主鍵字段在建表時,會自動創建主鍵索引
- 添加唯一約束時,數據庫實際上會添加唯一索引。
解釋:
增:創建:
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 結構組織的索引。