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.
For more information about the DescribeTable operation, see DescribeTable.
Prerequisites
- A Tablestore client is initialized. For more information, see Initialize an OTSClient instance.
- A data table is created.
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:
|
capacity_unit_details | The reserved read throughput and reserved write throughput of the table, which includes the following items:
|
table_options | The configuration information about the table, which includes the following items:
|
stream_details | The Stream information about the table, which includes the following items:
|
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.