All Products
Search
Document Center

Tablestore:Query the description of a table

Last Updated:Aug 22, 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

ParameterDescription
tableNameThe name of the table.

Examples

private static void describeTable(SyncClient client) {
    DescribeTableRequest request = new DescribeTableRequest(TABLE_NAME);
    DescribeTableResponse response = client.describeTable(request);
    TableMeta tableMeta = response.getTableMeta();
    System.out.println("The name of the table:" + tableMeta.getTableName());
    System.out.println("The primary key of the table:");
    for (PrimaryKeySchema primaryKeySchema : tableMeta.getPrimaryKeyList()) {
        System.out.println(primaryKeySchema);
    }
    TableOptions tableOptions = response.getTableOptions();
    System.out.println("TTL of the table:" + tableOptions.getTimeToLive());
    System.out.println("MaxVersions of the table:" + tableOptions.getMaxVersions());
    System.out.println("Encryption configuration of the table:" + response.getSSEDetails());
    ReservedThroughputDetails reservedThroughputDetails = response.getReservedThroughputDetails();
    System.out.println("Reserved read throughput of the table:"
            + reservedThroughputDetails.getCapacityUnit().getReadCapacityUnit());
    System.out.println("Reserved write throughput of the table:"
            + reservedThroughputDetails.getCapacityUnit().getWriteCapacityUnit());
}