Name
SHOW INDEXES
Synopsis
SHOW {INDEX|INDEXES|KEYS} FROM table [FROM database]This SQL statement displays information about the indexes for a
given table. A table from a different database can be specified either
by preceding the table name with the database name and a dot (e.g.,
database.table) or by adding the FROM clause. The
INDEXES keyword may be replaced with INDEX or
KEYS—all three are synonymous:
SHOW INDEXES FROM contacts FROM sales_dept \G
*************************** 1. row ***************************
Table: contacts
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: contact_id
Collation: A
Cardinality: 265
Sub_part: NULL
Packed: NULL
Null:
Index_type: BTREE
Comment:
*************************** 2. row ***************************
Table: contacts
Non_unique: 0
Key_name: contact_name
Seq_in_index: 1
Column_name: name_last
Collation: A
Cardinality: NULL
Sub_part: 10
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
*************************** 3. row ***************************
Table: contacts
Non_unique: 0
Key_name: contact_name
Seq_in_index: 2
Column_name: name_first
Collation: A
Cardinality: NULL
Sub_part: 10
Packed: NULL
Null: YES
Index_type: BTREE
Comment: Looking at these results, we can see that for each index the
table name is given. This is followed by a field indicating whether
the index is nonunique. A unique index is indicated by 0, a nonunique
index by 1. The name of the index or key (i.e.,
PRIMARY or contact_name in the example) is shown next. For indexes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access