All Products
Search
Document Center

Tablestore:Query information about a table

Last Updated:Apr 29, 2026

Retrieves table schema information, including field names and field types, by executing the DESCRIBE statement.

Note

For the full DESCRIBE statement syntax, see Query information about tables.

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 version details, see Version history of Tablestore SDK for .NET .

Parameters

Parameter

Description

query

The SQL statement to run. To query table information, use DESCRIBE <table_name> or DESC <table_name>.

Examples

The following example runs the describe test_table statement and prints the schema and each row of the result set. Each row contains six columns in this order: field name, field type, null constraint, default value, primary key flag, and partition key flag.

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

    SQLQueryResponse sqlQueryResponse = otsClient.SQLQuery(sqlQueryRequest);

    // Print the table schema as JSON.
    SQLTableMeta sqlTableMeta = sqlQueryResponse.GetSQLResultSet().GetSQLTableMeta();
    Console.WriteLine(JsonConvert.SerializeObject(sqlTableMeta.GetSchema()));

    // Iterate over the result set. Each row contains six columns:
    // index 0: field name, 1: field type, 2: null constraint,
    // 3: default value, 4: primary key flag, 5: partition key flag.
    ISQLResultSet resultSet = sqlQueryResponse.GetSQLResultSet();
    while (resultSet.HasNext())
    {
        ISQLRow row = resultSet.Next();
        Console.WriteLine(row.GetString(0) + " " + row.GetString(1) + " " + row.GetString(2) + " " +
                          row.GetString(3) + " " + row.GetString(4) + " " + row.GetString(5));
    }
}