This topic describes how to update the configurations of a table by using Tablestore SDK for PHP.
Method description
public function updateTable(array $request)
$request parameter description
table_name (required) string: The name of the data table.
table_options (optional) object: The table configuration information, which includes the following parameters.
Parameter | Type | Description |
time_to_live (optional) | int | The time to live (TTL) of data in the data table. Unit: seconds. If you set this parameter to -1, data never expires. Otherwise, the minimum value is 86400 (one day). Data whose retention period exceeds the TTL will be automatically deleted. If you want to use search index or secondary index features, you must set this parameter to -1 or set the allow_update parameter to false.
|
max_versions (optional) | int | The maximum number of versions. |
deviation_cell_version_in_sec (optional) | int | The maximum version offset. Unit: seconds. The difference between the current system time and the timestamp of written data must be within the maximum version offset range. Otherwise, the data write will fail. The valid version range for attribute column data is [max(Data written time - Maximum version offset, Data written time - TTL), Data written time + Maximum version offset).
|
allow_update (optional) | bool | Specifies whether updates are allowed. |
stream_spec (optional) object: The Stream configuration information, which includes the following parameters.
Parameter | Type | Description |
enable_stream (optional) | bool | Specifies whether to enable Stream. |
enable_stream (optional) | int | The Stream expiration time, which indicates the duration for which incremental logs are retained. Unit: hours. The maximum value is 168 (7 days). |
reserved_throughput (optional) object: The reserved read and write throughput, in CU. You can set this parameter to a non-zero value only for high-performance instances in CU mode.
Note When you call the updateTable() method, you must specify at least one of the table_options or stream_spec parameters.
When you specify table_options, you must specify at least one of the time_to_live, max_versions, deviation_cell_version_in_sec, or allow_update parameters.
Sample code
The following sample code demonstrates how to modify the configuration information of the test_table table.
$request = array (
'table_name' => 'test_table',
'table_options' => array (
'time_to_live' => 86400,
'max_versions' => 3,
'deviation_cell_version_in_sec' => 86400,
'allow_update' => false
),
'stream_spec' => array (
'enable_stream' => true,
'expiration_time' => 168
),
'reserved_throughput' => array (
'capacity_unit' => array (
'read' => 0,
'write' => 0
)
)
);
try{
$client->updateTable( $request );
echo "Update table succeeded.";
} catch (Exception $e) {
echo "Update table failed.";
}