You can execute the show index statement to query the index information about tables.
Note For more information about the show index statement, see Query the index information about a table.
Prerequisites
- An OTSClient instance is initialized. For more information, see Initialization.
- A mapping table is created. For more information, see Create mapping tables.
Parameters
Parameter | Description |
---|---|
query | The SQL statement. Configure the parameter based on the required feature. |
Examples
Execute the show index in test_table
statement to query index information about the table named test_table.
/// <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"));
}
}