All Products
Search
Document Center

Tablestore:Update the configurations of a table

Last Updated:Nov 14, 2024

This topic uses parameters and sample code to describe how to use Tablestore SDK for PHP to update the configurations of a table. You can update the time to live (TTL), max versions, max version offset, and Stream configuration of a data table. You can also update the reserved read and write throughput of a data table in a high-performance instance.

Prerequisites

API operation

/**
 * Update the configurations of a data table by using table_options, reserved_throughput, or stream_spec. 
 * You can call this operation to increase or decrease the reserved read and write throughput of a data 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 updateTable(array $request);           

Parameters

For more information, see Parameters.

Sample code

Update the configurations of a data table

The following sample code provides an example on how to update the configurations of a data table.

$result = $client->updateTable([
    // Specify the name of the data table. 
    'table_name' => '<TABLE_NAME>',
    'table_options' => [
        // Specify the TTL of data in the data table. A value of -1 specifies that data in the data table never expires. 
        'time_to_live' => -1,   
        // Specify the maximum number of versions that can be retained for data in each attribute column of the data table. In this example, up to five versions of data can be retained for each attribute column. 
        'max_versions' => 5,
        // Specify the maximum difference between the current system time and the timestamp of the written data. In this example, the maximum difference is set to 86,400 seconds (one day). 
        'deviation_cell_version_in_sec' => 86400,
        // Specify that the UpdateRow operation on the data table is allowed. 
        'allow_update' => true
    ],
    //'stream_spec' => [
    //    // Enable the Stream feature. 
    //    'enable_stream' => true,
    //    // Set the validity period of streams to 24 hours. 
    //    'expiration_time' => 24
    //]
]); 

Update the reserved throughput of a data table in a high-performance instance

The following sample code provides an example on how to update the reserved throughput of a data table in a high-performance instance.

$result = $client->updateTable([
    'table_name' => '<TABLE_NAME>',
    // Set the new reserved read throughput to 1 and the new reserved write throughput to 1. You can set the reserved read and write throughput only to 0 for a data table in a capacity instance. 
    'reserved_throughput' => [         
        'capacity_unit' => [
            'read' => 1,            
            'write' => 1
        ]
    ]
]);  

References

  • For more information about the API operation, see UpdateTable.

  • After you update the configurations of a table, you can perform the following operations: