创建普通索引的一个疑问
mysql> desc student;+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| stuno | int(11) | YES| | NULL | |
| stuname | varchar(60) | YES| | NULL | |
+---------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> create index sNoIdx on student(stuno); ----->只为一个字段stuno加了普通索引
Query OK, 0 rows affected (0.12 sec)
Records: 0Duplicates: 0Warnings: 0
mysql> desc student;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| stuno | int(11) | YES| MUL | NULL | | -----------为什么却显示的是复合索引 ???
| stuname | varchar(60) | YES| | NULL | |
+---------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Key是MUL, 那么该列的值可以重复, 该列是一个非唯一索引的前导列(第一列)或者是一个唯一性索引的组成部分但是可以含有空值NULL;
并不一定是复合索引,也可以是可以为空的单列索引,就如你建的索引。
一般查看表中已经存在 index:show index from table_name;
参考自:MySQL索引操作 http://www.data.5helpyou.com/article259.html
页:
[1]