MySQL 5.5 刪除索引的方法
mysql> show keys from dept2;
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_deptno | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_report_date | 1 | report_date | A | 4 | NULL | NULL | YES | BTREE | | |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)
方法①
mysql> drop index idx_dept2_deptno on dept2;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show keys from dept2;
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_report_date | 1 | report_date | A | 4 | NULL | NULL | YES | BTREE | | |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.00 sec)
--方法②
mysql> alter table dept2 drop index idx_dept2_report_date;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show keys from dept2;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_deptno | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_report_date | 1 | report_date | A | 4 | NULL | NULL | YES | BTREE | | |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)
方法①
mysql> drop index idx_dept2_deptno on dept2;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show keys from dept2;
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
| dept2 | 1 | idx_dept2_report_date | 1 | report_date | A | 4 | NULL | NULL | YES | BTREE | | |
+-------+------------+-----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.00 sec)
--方法②
mysql> alter table dept2 drop index idx_dept2_report_date;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show keys from dept2;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dept2 | 0 | PRIMARY | 1 | deptno | A | 4 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2113870/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql刪除主鍵索引,刪除索引語法MySql索引
- Mysql索引的建立與刪除MySql索引
- MySQL建立索引、修改索引、刪除索引的命令語句MySql索引
- Oracle刪除主鍵保留索引的方法Oracle索引
- mysql 建立和刪除聯合索引MySql索引
- mysql 關聯更新刪除不走索引優化MySql索引優化
- 【Mongo】MongoDB索引管理-索引的建立、檢視、刪除MongoDB索引
- DataFrame刪除複合索引索引
- MYSQL日誌的正確刪除方法詳解MySql
- MYSQL中刪除重複記錄的方法薦MySql
- mysql表刪除重複記錄方法MySql
- mongodb建立索引和刪除索引和背景索引backgroundMongoDB索引
- 儲存系統實現-資料刪除之索引的刪除索引
- Lucene中建立索引的效率和刪除索引的實現索引
- MySQL防止delete命令刪除資料的兩種方法MySqldelete
- js刪除陣列指定索引的元素JS陣列索引
- elasticsearch(三)----索引建立與刪除Elasticsearch索引
- 【常用方法推薦】如何刪除MySQL的重複資料?MySql
- 指定刪除幾天前的索引資料索引
- mysql bin 日誌的刪除MySql
- mysql刪除查詢MySql
- ElasticSearch分片互動過程(建立索引、刪除索引、查詢索引)Elasticsearch索引
- mySql刪除多個表 刪除多個欄位的SQLMySql
- Mysql InnoDB刪除資料後釋放磁碟空間的方法MySql
- MySQL刪除表重複記錄的三種方法舉例MySql
- 陣列的方法-新增刪除陣列
- 刪除古怪檔案的方法
- elasticsearch按照日期定時批量刪除索引Elasticsearch索引
- 刪除分割槽需要更新全域性索引索引
- MySQL刪除資料表MySql
- MySQL-刪除欄位MySql
- MySQL 多表關聯刪除MySql
- Ubuntu徹底刪除MySqlUbuntuMySql
- mysql 刪除重複項MySql
- 【MySql】如何刪除 bin logMySql
- 做實驗驗證MongoDB刪除文件後索引是否會自動刪除MongoDB索引
- 【MySQL】批量刪除mysql中資料庫中的表MySql資料庫
- Java ArrayList刪除特定元素的方法Java