SHOW INDEX
Descriptionβ
This statement is used to display information about indexes in a table. Currently, only bitmap indexes are supported.
Syntaxβ
SHOW INDEX [ ES ] FROM [ <db_name>. ] <table_name> [ FROM <db_name> ];
Varaint Syntaxβ
SHOW KEY[ S ] FROM [ <db_name>. ] <table_name> [ FROM <db_name> ];
Required Parametersβ
1. <table_name>
: The name of the table to which the index belongs.
Optional Parametersβ
1. <db_name>
: The database name, optional. If not specified, the current database is used by default.
Return Valueβ
Column Name | Type | Description |
---|---|---|
Table | string | The name of the table where the index is located. |
Non_unique | int | Indicates whether the index is unique: - 0 : Unique index - 1 : Non-unique index |
Key_name | string | The name of the index. |
Seq_in_index | int | The position of the column in the index. This column shows the order of the column in the index, used when multiple columns form a composite index. |
Column_name | string | The name of the indexed column. |
Collation | string | The sorting order of the index column: - A : Ascending - D : Descending. |
Cardinality | int | The number of unique values in the index. This value is used to estimate query efficiency; the higher the value, the higher the index selectivity and query efficiency. |
Sub_part | int | The prefix length used by the index. If the index column is a string type, Sub_part represents the length of the first few characters of the index. |
Packed | string | Whether the index is compressed. |
Null | string | Whether NULL values are allowed: - YES : NULL values allowed - NO : NULL values not allowed |
Index_type | string | The type of index: - BTREE : B+ tree index (default type in MySQL) - HASH : Hash index - RTREE : R-tree index - INVERTED : Inverted index (e.g., full-text index) |
Comment | string | The comment or description of the index, typically custom remarks. |
Properties | string | Additional properties of the index. |
Access Control Requirementsβ
The user executing this SQL command must have at least the following privileges:
Privilege | Object | Notes |
---|---|---|
SHOW_PRIV | Database |
Examplesβ
-
Display indexes for a specified
table_name
SHOW INDEX FROM example_db.table_name;