Update a time series table

更新时间: 2026-01-20 21:40:07

Call the UpdateTimeseriesTable operation to update the configuration of a time series table or timeline metadata, such as the time-to-live (TTL) configuration.

Precautions

  • The time series model feature is available in Tablestore Python SDK 6.1.0 and later. Ensure that you use a supported version of the Python SDK.

    Note

    For more information about the release history of the Python SDK, see Python SDK release history.

  • You cannot change the configuration of a time series table (timeseries_table_options) and the configuration of timeline metadata (timeseries_meta_options) in the same call. You can modify only one of these configurations in a single call.

Prerequisites

Initialize the Tablestore client.

Parameters

Parameter

Description

table_meta (Required)

The structure of the time series table. It includes the following parameters:

  • timeseries_table_name (Required): The name of the time series table.

  • timeseries_table_options (Optional): The configuration of the time series table. It includes the following parameter:

    • time_to_live (Required): The lifecycle of data in the time series table, which specifies when the data expires. Unit: seconds.

      The minimum lifecycle for data in a time series table is 86400 seconds (1 day). You can also set this parameter to -1, which means the data never expires.

  • timeseries_meta_options (Optional): The configuration of the timeline metadata. It includes the following parameters:

    • meta_time_to_live (Required): The lifecycle of the timeline metadata, which specifies when the timeline expires. Unit: seconds.

      The minimum lifecycle for timeline metadata is 604800 seconds (7 days). You can also set this parameter to -1, which means the timeline never expires.

      Important

      The lifecycle of timeline metadata must be greater than or equal to the data lifecycle of the time series table.

    • allow_update_attributes (Required): Specifies whether to allow updates to the attributes of timeline metadata. Valid values:

      Important
      • If `meta_time_to_live` is not -1, you must set `allow_update_attributes` to False. This prevents you from updating the attributes of timeline metadata.

      • If you set `allow_update_attributes` to True, you must set `meta_time_to_live` to -1 (never expires).

      • True: Allows the operation.

      • False: Not permitted.

Example

The following example shows how to update the TTL of a time series table.

try:
    # The data lifecycle of the time series table is 604800 seconds (7 days).
    tableOption = TimeseriesTableOptions(604800)
    tableMeta = TimeseriesTableMeta("<TIMESERIES_TABLE_NAME>", tableOption)

    # Call the operation to update the time series table.
    otsClient.update_timeseries_table(tableMeta)
    print("update timeseries table success.")
except Exception as e:
    # If an exception is thrown, the execution failed. Handle the exception.
    print("update timeseries table failed. %s" % e)
上一篇: Create a time series table 下一篇: Query information of a time series table
阿里云首页 表格存储 相关技术圈