All Products
Document Center

Tablestore:Query the description of a table

Last Updated:Apr 01, 2024

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.


For more information about the DescribeTable operation, see DescribeTable.


API operation

def describe_table(self, table_name):

The return value is the description of the table. describe_table_response indicates the description of the table, which is an instance of the ots2.metadata.DescribeTableResponse class.





The name of the table.

Sample code

The following sample code provides an example on how to query the description of a table:

    describe_response = ots_client.describe_table('SampleTable')
    # If no exception is thrown, the description is obtained and the following information is displayed: 
    print("describe table succeeded.")
    print('TableName: %s' % describe_response.table_meta.table_name)
    print('PrimaryKey: %s' % describe_response.table_meta.schema_of_primary_key)
    print('Reserved read throughput: %s' %
    print('Reserved write throughput: %s' % describe_response.reserved_throughput_details.capacity_unit.write)
    print('Last increase throughput time: %s' % describe_response.reserved_throughput_details.last_increase_time)
    print('Last decrease throughput time: %s' % describe_response.reserved_throughput_details.last_decrease_time)
    print('table options\'s time to live: %s' % describe_response.table_options.time_to_live)
    print('table options\'s max version: %s' % describe_response.table_options.max_version)
    print('table options\'s max_time_deviation: %s' % describe_response.table_options.max_time_deviation)
except Exception:
    # If an exception is thrown, the description of the table fails to be queried. Handle the exception. 
    print("describe table failed.")

For more information about the detailed sample code, visit DescribeTable on GitHub.