You can execute the describe statement to query information about tables, such as the field names and field types.

Note For more information about the describe statement, see Query the information about a table.

Prerequisites

Usage notes

Tablestore SDK for Java V5.13.0 or later supports the SQL query feature. Before you use the SQL query feature, make sure that Tablestore SDK for Java V5.13.0 or later is obtained. For more information about the version history of Tablestore SDK for Java, see Tablestore SDK for Java.

Parameters

Parameter Description
query The SQL statement. Configure the parameter based on the required feature.

Example

Execute the describe test_table statement to query information about the table named test_table.

private static void getTableDesc(SyncClient client) {
    // Create a SQL request. 
    SQLQueryRequest request = new SQLQueryRequest("describe test_table");

    // Obtain the response to the SQL request. 
    SQLQueryResponse response = client.sqlQuery(request);
    // Obtain the schema of the returned results of the SQL query statement. 
    SQLTableMeta tableMeta = response.getSQLResultSet().getSQLTableMeta();
    System.out.println("response table schema: " + tableMeta.getSchema());

    // Use SQL ResultSet to obtain all returned results of the SQL query statement. 
    System.out.println("response resultset:");
    SQLResultSet resultSet = response.getSQLResultSet();
    while (resultSet.hasNext()) {
        SQLRow row = resultSet.next();
        System.out.println(row.getString(0) + ", " + row.getString(1) + ", " +
                           row.getString(2) + ", " + row.getString(3) + ", " +
                           row.getString(4) + ", " + row.getString(5));
    }
}
Sample output:
response table schema: [Field:STRING, Type:STRING, Null:STRING, Key:STRING, Default:STRING, Extra:STRING]
response resultset:
pk, varchar(1024), NO, PRI, null,
long_value, bigint(20), YES, , null,
double_value, double, YES, , null,
string_value, mediumtext, YES, , null,
bool_value, tinyint(1), YES, , null,