Update a time series table
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.
-
A TimeseriesClient instance is initialized. For more information, see Initialize an OTSClient instance.
Parameters
For more information, see Create a time series table.
Examples
The following example updates the time to live (TTL) of a time series table.
func UpdateTimeseriesTableSample(client *tablestore.TimeseriesClient, timeseriesTableName string) {
// Construct the TTL configuration of the time series table.
ttlInSeconds := int64(964000)
timeseriesTableOptions := tablestore.NewTimeseriesTableOptions(ttlInSeconds)
updateTimeseriesTableRequest := tablestore.NewUpdateTimeseriesTableRequest(timeseriesTableName)
updateTimeseriesTableRequest.SetTimeseriesTableOptions(timeseriesTableOptions)
updateTimeseriesTableResponse, err := client.UpdateTimeseriesTable(updateTimeseriesTableRequest)
if err != nil {
fmt.Println("[Error] UpdateTimeseriesTable failed:", err)
return
}
fmt.Println("[Info] UpdateTimeseriesTable succeeded. RequestId:", updateTimeseriesTableResponse.RequestId)
}
References
For more information about the API operation, see UpdateTimeseriesTable.
To verify the updated configurations, query the time series table. For more information, see Query the information about a time series table.
-
If you want to read data from or write data to a time series table, you can call the specific API operation. For more information, see Write time series data and Query time series data.