示例'不在表所在库,显示索引,需要指定库名'
MariaDB [(none)]> SHOW INDEXES FROM hellodb.students;
'进入表所在数据库后,可以省略'
MariaDB [(none)]> use hellodb
MariaDB [hellodb]> show index from students\G
查看复合索引,显示效果,以两行显示,键名相同,分为2部分*************************** 4. row ***************************
Table: students
Non_unique: 1
Key_name: idx_name_age <==具有相同的键名
Seq_in_index: 1 <==表示Name在组合键的前面
Column_name: Name
*************************** 5. row ***************************
Table: students
Non_unique: 1
Key_name: idx_name_age <==与4都属于复合键,相同的键名
Seq_in_index: 2 <==表示age在组合键的后面
Column_name: Age
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
查看唯一键索引MariaDB [hellodb]> show index from students\G
*************************** 2. row ***************************
Table: students
Non_unique: 0 <==主键和唯一键与其他索引的区别在于,此项为0
Key_name: uni_idx_name