先看一下一些常見的索引吧!
-
主鍵索引(primary key)
-
唯一鍵索引(unique)
-
普通索引(index)
-
全文索引(fulltext)
在看一下索引的基本原理~ -
首先索引相當於創建二叉樹
-
然後基於二叉樹這種查找的性質當我們需要查找8000000的數據最多也就找一個23次就可以了
-
但是了當我們對原有數據進行增刪改查,那麼在空間換時間的基礎思想上理解,需要的維護速度肯定也是會增長很多的
創建索引 -
主鍵創建
-
唯一鍵創建索引
-
普通索引的創建
-
全文索引的創建
刪除索引
第一種方法-刪除主鍵索引: alter table 表名 drop primary key;
第二種方法-其他索引的刪除: alter table 表名 drop index 索引名; 索引名就是show keys from 表名 中的 Key_name 字段 mysql> alter table user10 drop index idx_name;
第三種方法方法: drop index 索引名 on 表名 mysql> drop index name on user8;