All Products
Search
Document Center

Tablestore:Query the description of a table

Last Updated:Aug 06, 2024

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

Note

For more information about the DescribeTable operation, see DescribeTable.

Prerequisites

API operation

/**
 * Query the schema information, configuration information, reserved read throughput and reserved write throughput, and Stream configuration information about a table. 
 * @api
 * @param [] $request The request parameters. 
 * @return [] The response. 
 * @throws OTSClientException The exception that is thrown when a parameter error occurs or the Tablestore server returns a verification error. 
 * @throws OTSServerException The exception that is thrown when the Tablestore server returns an error. 
 */
public function describeTable(array $request);

Parameters

Request information

Request parameters

Parameter

Description

table_name

The name of the table.

Request syntax

$result = $client->describeTable([
     'table_name' => '<string>', // Specify the name of the table. The table name must be specified. 
]);

Response information

Response parameters

Parameter

Description

table_meta

The schema information about the table, which includes the following items:

  • table_name: the name of the table.

  • primary_key_schema: the primary key schema of the table, which is the same as the primary key schema defined when the table is created.

  • defined_column: the definition of a predefined column in the table.

capacity_unit_details

The reserved read throughput and reserved write throughput of the table, which includes the following items:

  • capacity_unit indicates the reserved read throughput and reserved write throughput configurations of the table, which are related to billing. Unit: CU.

    • read: the reserved read throughput.

    • write: the reserved write throughput.

  • last_increase_time: the time when the reserved read throughput or reserved write throughput was last increased for this table. The time is expressed in the number of seconds that have elapsed since 00:00:00, January 1, 1970 (UTC).

  • last_decrease_time: the time when the reserved read throughput or reserved write throughput was last decreased for this table. The time is expressed in the number of seconds that have elapsed since 00:00:00, January 1, 1970 (UTC).

table_options

The configuration information about the table, which includes the following items:

  • time_to_live: the retention period of data in the table. This period is the validity period of data.

  • max_versions: the maximum number of data versions that can be retained for a single attribute column.

  • deviation_cell_version_in_sec: the max version offset, which is the maximum difference between the current system time and the timestamp of the written data.

stream_details

The Stream information about the table, which includes the following items:

  • enable_stream: indicates whether Stream is enabled for the table.

  • stream_id: the Stream ID of the table.

  • expiration_time: the expiration time of the Stream data of the data table. Unit: hours. Earlier modification records are deleted.

  • last_enable_time: the time when Stream was enabled most recently.

Response syntax

[
    'table_meta' => [
        'table_name' => '<string>',
        'primary_key_schema' => [
            ['<string>', <PrimaryKeyType>],
            ['<string>', <PrimaryKeyType>, <PrimaryKeyOption>]
        ],
        'defined_column'=> [
            ['<string>', <DefinedColumnType>] 
        ]
    ],
    'capacity_unit_details' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ],
        'last_increase_time' => <integer>,
        'last_decrease_time' => <integer>
    ],
    'table_options' => [
        'time_to_live' => <integer>,
        'max_versions' => <integer>,
        'deviation_cell_version_in_sec => <integer>
    ],
    'stream_details' => [
        'enable_stream' => true || false,
        'stream_id' => '<string>',
        'expiration_time' => <integer>,
        'last_enable_time' => <integer>
    ]
]        

Examples

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

$result = $client->describeTable([
        'table_name' => 'mySampleTable',
        ]);
        var_dump($result);    

References

  • For information about the API operation that you can call to query the description of a table, see DescribeTable.

  • You can call API operations to read and write data in a table. For more information, see Basic operations on data.

  • You can update a table to modify the information about the table, such as the TTL and max versions. For more information, see Update data tables.

  • You can delete a data table that you no longer require. For more information, see Delete a data table.