Skip to main content
The SHOW INDEX returns index information for a table or database.

Required privileges

The user must have any on the target table or database.

Aliases

In CockroachDB, the following are aliases for SHOW INDEX:
  • SHOW INDEXES
  • SHOW KEYS

Synopsis

show_indexes syntax diagram

Parameters

ParameterDescription
table\_nameThe name of the table for which to show indexes.
database\_nameThe name of the database for which to show indexes.

Response

The following fields are returned for each column in each index.
FieldDescription
table\_nameThe name of the table.
index\_nameThe name of the index.
non\_uniqueWhether values in the indexed column are unique. Possible values: true or false.
seq\_in\_indexThe position of the column in the index, starting with 1.
column\_nameThe indexed column.
directionHow the column is sorted in the index. Possible values: ASC or DESC for indexed columns; N/A for stored columns.
storingWhether the STORING clause was used to index the column during . Possible values: true or false.
implicitWhether the column is part of the index despite not being explicitly included during . Possible values: true or false columns are the only columns implicitly included in secondary indexes. The inclusion of primary key columns improves performance when retrieving columns not in the index.
visibleWhether the index is visible to the .
A column is in the primary key if the value of the index_name column is {tbl}_pkey and value of the storing column is false.

Example

Setup

To follow along, run to start a temporary, in-memory cluster with the sample dataset preloaded:

Show indexes for a table

In this example, the columns where the value of the index_name column is users_pkey and value of the storing column is false, and thus are in the primary key, are city and id.

Show indexes for a database

See also