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
An instance for the TimeSeries model is created in the Tablestore console. For more information, see Create an instance for the TimeSeries model.
An OTSClient is initialized. For more information, see Initialize an OTSClient instance.
Usage notes
The name of the time series table that you create cannot be the same as the name of an existing data table.
Operation
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.
|
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);
}
References
After you create a time series table, you can write time series data to the table and read time series data from the table. For more information, see Write time series data and Query time series data.
For information about how to modify the TTL of data in a time series table, see Modify the configurations of a time series table.
For information about how to query the names of all time series tables in an instance, see Query the names of time series tables.
For information about how to query the information about a time series table, see Query the information about a time series table.
For information about how to delete a time series table that you no longer require, see Delete a time series table.
To back up time series data in Tablestore in a cost-effective manner or export time series data as files to local devices, you can use the Data Integration service of DataWorks to synchronize time series data from Tablestore to Object Storage Service (OSS) for storage or download. For more information, see Synchronize data from Tablestore to OSS.
For information about how to connect Tablestore to Grafana to visualize time series data, see Connect Tablestore to Grafana.
If you use Realtime Compute for Apache Flink to compute and analyze data, you can use Tablestore time series tables to store the results. For more information, see Tutorial (TimeSeries model).