All Products
Search
Document Center

Tablestore:Query index information about a table

Last Updated:Apr 30, 2026

Run the show index statement to retrieve the index name, index fields, and index type for a table.

Note

For more information about the show index statement, see Query the index information about a table.

Prerequisites

Before you begin, ensure that you have:

Usage notes

The SQL query feature requires Tablestore SDK for .NET V5.0.0 or later.

For more information, see Version history of Tablestore SDK for .NET .

Parameters

Parameter

Description

query

The SQL statement to execute. Set this to a show index statement targeting the table you want to inspect.

Examples

The following example runs show index in test_table against a table named test_table. The code submits the SQL query, reads the result set schema, then iterates over each row to print the index fields.

/// <summary>
/// Query index information about a table. 
/// </summary>
/// <param name="otsClient"></param>
public static void DescribeIndex(OTSClient otsClient)
{
    SQLQueryRequest sqlQueryRequest = new SQLQueryRequest("show index in test_table");

    SQLQueryResponse sqlQueryResponse = otsClient.SQLQuery(sqlQueryRequest);

    SQLTableMeta sqlTableMeta = sqlQueryResponse.GetSQLResultSet().GetSQLTableMeta();
    Console.WriteLine(JsonConvert.SerializeObject(sqlTableMeta.GetSchema()));

    ISQLResultSet resultSet = sqlQueryResponse.GetSQLResultSet();
    while (resultSet.HasNext())
    {
        ISQLRow row = resultSet.Next();
        Console.WriteLine(row.GetString("Table") + " " + row.GetLong("Non_unique") + " " + row.GetString("Key_name") + " " +
                          row.GetLong("Seq_in_index") + " " + row.GetString("Column_name") + " " + row.GetString("Index_type"));
    }
}

Response fields

The result set returns the following fields for each index entry.

Field

Type

Description

Table

String

The name of the table.

Non_unique

Long

Specifies whether the index allows duplicate values. 0 means values must be unique; 1 means duplicates are allowed.

Key_name

String

The name of the index.

Seq_in_index

Long

The position of the column in the index, starting from 1.

Column_name

String

The name of the indexed column.

Index_type

String

The index type.

References

  • To use a specific search index when querying data with the SQL query feature, run the CREATE TABLE statement to create a mapping table for the search index. For more information, see Create mapping tables for search indexes.

  • To query data based on index fields using SQL statements, see Query data.