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

  • A Tablestore client is initialized. For more information, see Initialization.
  • A data table is created.

API operations

/**
 * Query the schema information, configuration information, reserved read throughput and reserved write throughput, and Stream configuration information about the specified 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 parameters
    Parameter Description
    table_name The name of the table.
  • Request format
    $result = $client->describeTable([
         'table_name' => '<string>', // Specify the name of the table. The table name must be specified. 
    ]);
  • 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 of the table, which is the same as the primary key 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: CUs.
      • 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 period during which data in the table can be retained. This period is the validity period of data.
    • max_versions: the maximum number of versions of data 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 table. Unit: hours. Earlier modification records are deleted.
    • last_enable_time: the time when Stream was enabled most recently.
  • Result format
    [
        '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 code provides an example on how to query the description of a table:

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