All Products
Search
Document Center

Tablestore:Query the index information about a table

Last Updated:Jul 22, 2024

You can execute the SHOW INDEX statement to query the index information about a table, such as the index names, indexed fields, and index types.

Syntax

SHOW INDEX {FROM | IN} table_name;

Parameters

Parameter

Required

Description

table_name

Yes

The name of the table

  • If you set this parameter to the name of a mapping table, information about all indexes in the table is returned.

  • If you set this parameter to the name of a mapping table for a search index, only information about the specified index is returned.

Examples

A table named exampletable1 contains a global secondary index index2 and two search indexes. You created a mapping table named search_exampletable 1 for one of the search indexes. The following examples show the query results of different mapping tables.

  • Example 1: Query the index information about a mapping table

    The following sample code provides an example on how to query the index information about the exampletable1 table:

    SHOW INDEX IN exampletable1;

    The following figure shows a sample output.

    image

  • Example 2: Query the index information about a mapping table for a search index

    The following sample code provides an example on how to query the information about the search_exampletable1 table:

    SHOW INDEX IN search_exampletable1;

    The following figure shows a sample output.

    image

References

  • If you want to use a specific search index to query data when you use the SQL query feature, you can execute the CREATE TABLE statement to create a mapping table for the search index. For more information, see Create mapping tables for search indexes.

  • You can execute SQL statements to query data based on the fields of an index. For more information, see Query data.