You can call the CreateTimeseriesTable operation to create a time series table. When you call the CreateTimeseriesTable operation to create a time series table, you must specify the configurations of the table.

Prerequisites

Usage note

The name of the time series table that you create cannot be the same as the name of an existing data table.

Parameters

Parameter Description
timeseriesTableName The name of the time series table.
timeseriesTableOptions The configurations of the time series table, which include the following content:

timeToLive: the retention period of the data in the time series table. Unit: seconds. If you want the data in the time series table to never expire, set this parameter to -1. You can call the UpdateTimeseriesTable operation to modify the value of this parameter.

Example

Create a time series table named test_timeseries_table and set the data in the time series table to never expire.

private static void createTimeseriesTable(TimeseriesClient client) {
    String tableName = "test_timeseries_table";
    TimeseriesTableMeta timeseriesTableMeta = new TimeseriesTableMeta(tableName);
    int timeToLive = -1;
    timeseriesTableMeta.setTimeseriesTableOptions(new TimeseriesTableOptions(timeToLive));
    CreateTimeseriesTableRequest request = new CreateTimeseriesTableRequest(timeseriesTableMeta);
    client.createTimeseriesTable(request);
}