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
- A time series table is created. For more information, see Create a time series table.
- The TimeseriesClient is initialized. For more information, see Initialize an OTSClient instance.
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());
}