Skip to main content

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 NameTypeDescription
TablestringThe name of the table where the index is located.
Non_uniqueintIndicates whether the index is unique:
- 0: Unique index
- 1: Non-unique index
Key_namestringThe name of the index.
Seq_in_indexintThe 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_namestringThe name of the indexed column.
CollationstringThe sorting order of the index column:
- A: Ascending
- D: Descending.
CardinalityintThe 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_partintThe 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.
PackedstringWhether the index is compressed.
NullstringWhether NULL values are allowed:
- YES: NULL values allowed
- NO: NULL values not allowed
Index_typestringThe 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)
CommentstringThe comment or description of the index, typically custom remarks.
PropertiesstringAdditional properties of the index.

Access Control Requirements​

The user executing this SQL command must have at least the following privileges:

PrivilegeObjectNotes
SHOW_PRIVDatabase

Examples​

  • Display indexes for a specified table_name

     SHOW INDEX FROM example_db.table_name;