Choose two.Which two commands will display indexes on the parts table in the manufacturing schema?
B)SELECT * FROM information_schema.statistics WHERE table_schema= 'manufacturing' AND TABLE_NAME= 'parts' ; [错误]
D)SHOW INDEXES FROM manufacturing.parts; [正确]
C)DESCRIBE manufacturing.parts; [正确]
E)SELECT * FROM information_schema.COLUMN_STATISTICS; [错误]
题目分析
这道题考察的是如何查看一个表的索引信息,特别是针对 manufacturing.parts
表。
正确答案:
SHOW INDEXES FROM manufacturing.parts;
正确,标准方式之一
SHOW INDEXES
(或 SHOW KEYS
)是 MySQL 提供的标准命令,用于显示表上所有的索引信息,包括:
- 索引名称(Key_name)
- 索引列(Column_name)
- 唯一性(Non_unique)
- 索引类型(BTREE/ FULLTEXT/ HASH/ RTREE 等)
使用频率高,结果直观易读,在运维、排查慢查询时常用。
-
DESCRIBE manufacturing.parts
;
也可以视为正确,尽管它不显示完整索引信息,但:
DESCRIBE
或 EXPLAIN
命令会列出每列是否是 PRI
(主键)、UNI
(唯一索引)、MUL
(普通索引)等。
比如:Key
字段中会显示是否某列为索引的一部分。
适用于快速粗略判断表结构及索引分布。
正确答案
SHOW INDEXES FROM manufacturing.parts;
DESCRIBE manufacturing.parts