All Products
Search
Document Center

Tablestore:Create a time series table

Last Updated:Jan 15, 2024

You can call the CreateTimeseriesTable operation to create a time series table. When you create a time series table, you can configure the time to live (TTL) of data and parameters about time series metadata.

Prerequisites

Usage notes

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

Syntax

public class CreateTimeseriesTableRequest implements Request {
    /**The configurations of the time series table. */
    private TimeseriesTableMeta timeseriesTableMeta;
}

Parameters

Parameter

Description

TimeseriesTableMeta

The configurations of the time series table.

  • timeseriesTableName: the name of the time series table.

  • timeseriesMetaOptions: the configurations of the time series metadata, including the following parameters:

    • metaTimeToLive: the TTL of the time series metadata. Unit: seconds. The value must be -1 or a value that is greater than or equal to 604800. A value of -1 indicates that the metadata never expires. A value of 604800 indicates seven days.

    • allowUpdateAttributes: specifies whether the property columns of the time series metadata can be modified.

    You can call the UpdateTimeseriesTable operation to modify the preceding parameters.

  • timeseriesTableOptions: the configurations of the time series table, including the following parameter:

    timeToLive: the TTL 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 this parameter.

Example

The following sample code provides an example on how to create a time series table named test_timeseries_table whose data never expires.

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);
}