All Products
Search
Document Center

Tablestore:Update the configurations of a table

Last Updated:Apr 29, 2026

Use the Tablestore SDK for Python to update table configurations such as time to live (TTL), max version, and reserved throughput.

Prerequisites

Before you begin, ensure that you have:

Method description

def update_table(self, table_name, table_options=None, reserved_throughput=None)

Parameters

  • table_name (required) str: the name of the data table.

  • table_options (optional) TableOptions: the table configurations, including the following parameters.

    Parameter

    Type

    Description

    time_to_live (optional)

    int

    The time to live (TTL) of data, in seconds. Default: -1.

    Set to -1 to keep data indefinitely. Any other value must be at least 86400 (one day). Data that exceeds the TTL is automatically deleted.

    To use search index or secondary index features, set this parameter to -1 or set allow_update to False.

    max_version (optional)

    int

    The maximum number of versions. Default: 1.

    • To use search index or secondary index features, set this parameter to 1.

    max_time_deviation (optional)

    int

    The maximum version offset, in seconds. Default: 86400 (one day).

    • The difference between the current system time and the timestamp of written data must be within this offset. Writes that exceed this range 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 to allow row updates. Default: True.

    • Set to False to prevent row updates via the UpdateRow() method.

  • reserved_throughput (optional) ReservedThroughput: reserved read and write throughput, in capacity unit (CU). Default: 0. Applies only to high-performance instances in CU mode.

Note

At least one of table_options or reserved_throughput must be specified when calling update_table().

Sample code

The following example updates the configurations of test_table.

# Set table configurations: TTL of 1 day, max 3 versions, max time deviation of 1 day, updates disabled
table_options = TableOptions(time_to_live=86400, max_version=3, max_time_deviation=86400, allow_update=False)

# Set reserved read and write throughput to 0 CUs
# Non-zero values are only supported for high-performance instances in CU mode
reserved_throughput = ReservedThroughput(CapacityUnit(0, 0))

try:
    client.update_table('test_table', table_options, reserved_throughput)
    print("Update table succeeded.")
except Exception as e:
    print("Update table failed. %s" % e)

References

Update a time series table