首页 > 代码库 > mysql语句 索引操作
mysql语句 索引操作
创建索引:(help create index;)
CREATE INDEX indexName ON tableName(Coll,Coll....);
ALTER TABLE tableName ADD INDEX indexName(Coll,Coll);
eg:
联合索引:
create index Sage_Sdept on student(Sage,Sdpt(10))
create index d_a_p on student(dateline,ader(20),pos(20));
删除索引:
ALTER TABLE tableName DROP indexName;
DROP INDEX indexName ON tableName;
查看表的索引:
mysql> show index from proc;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| proc | 0 | PRIMARY | 1 | db | A | NULL | NULL | NULL | | BTREE | | |
| proc | 0 | PRIMARY | 2 | name | A | NULL | NULL | NULL | | BTREE | | |
| proc | 0 | PRIMARY | 3 | type | A | 48 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)
mysql语句 索引操作