All Products
Search
Document Center

Tablestore:Modify the configurations of a time series table

Last Updated:Jan 15, 2024

You can call the UpdateTimeseriesTable operation to modify the configurations of a time series table, such as the time to live (TTL) of data or time series metadata.

Prerequisites

Usage notes

You cannot modify the configurations of a time series table and time series metadata at the same time. To modify the configurations of a time series table, specify the timeseriesTableOptions parameter. To modify the configurations of time series metadata, specify the timeseriesMetaOptions parameters.

Parameters

For more information, see the "Parameters" section of the Create a time series table topic.

Example

The following sample code provides an example on how to change the TTL of the data in a time series table to three years.

private static void updateTimeseriesTable(TimeseriesClient client) {
    // Specify the name of the time series table. 
    String tableName = "<TIMESERIES_TABLE>";
    UpdateTimeseriesTableRequest updateTimeseriesTableRequest = new UpdateTimeseriesTableRequest(tableName);
    // Change the TTL to three years. 
    updateTimeseriesTableRequest.setTimeseriesTableOptions(new TimeseriesTableOptions(86400 * 365 * 3)); 
    client.updateTimeseriesTable(updateTimeseriesTableRequest);

    DescribeTimeseriesTableResponse describeTimeseriesTableResponse = client.describeTimeseriesTable(new DescribeTimeseriesTableRequest(tableName));
    TimeseriesTableMeta tableMeta = describeTimeseriesTableResponse.getTimeseriesTableMeta();
    // View the modified TTL. 
    System.out.println(tableMeta.getTimeseriesTableOptions().getTimeToLive()); 
}