All Products
Search
Document Center

Tablestore:Query the description of a table

Last Updated:Nov 09, 2023

You can call the DescribeTable operation to query the description such as the schema information, reserved read throughput, and reserved write throughput of a table.

Note

For more information about the DescribeTable operation, see DescribeTable.

Prerequisites

  • OTSClient is initialized. For more information, see Initialization.

  • A table is created.

Parameters

Parameter

Description

tableName

The name of the table.

Example

The following sample code provides an example on how to query the schema information, optional configurations, reserved read throughput, and reserved write throughput of a table:

private static void describeTable(SyncClient client) {
    // Specify the name of the table. 
    DescribeTableRequest request = new DescribeTableRequest("<TABLE_NAME>");
    DescribeTableResponse response = client.describeTable(request);
    TableMeta tableMeta = response.getTableMeta();
    System.out.println("Table name:" + tableMeta.getTableName());
    System.out.println("Primary key information:");
    for (PrimaryKeySchema primaryKeySchema : tableMeta.getPrimaryKeyList()) {
        System.out.println(primaryKeySchema);
    }
    TableOptions tableOptions = response.getTableOptions();
    System.out.println("Table TTL:" + tableOptions.getTimeToLive());
    System.out.println("Maximum number of data versions:" + tableOptions.getMaxVersions());
    // You can view the encryption configurations of a table only if the table is an encrypted table. If the table is not an encrypted table, this parameter is not returned. 
    System.out.println("Encryption configurations:" + response.getSseDetails());
    ReservedThroughputDetails reservedThroughputDetails = response.getReservedThroughputDetails();
    System.out.println("Reserved read throughput:"
            + reservedThroughputDetails.getCapacityUnit().getReadCapacityUnit());
    System.out.println("Reserved write throughput:"
            + reservedThroughputDetails.getCapacityUnit().getWriteCapacityUnit());
}