After you create a time series table, you can use the table, query the information about the table, update the table, and delete the table. You can also list the names of all tables in an instance.
Create a time series table
Create a time series table for which the time to live (TTL) value is specified.
- Command syntax
create -m mode -t tableName --ttl timeToLive
The following table describes the parameters that you can configure to create a time series table.
Parameter Required Example Description -m, --model Yes timeseries The type of the table that you want to create. Default value: widecolumn. Valid values: - widecolumn: data table.
- timeseries: time series table.
-t, --table Yes mytable The name of the time series table. --ttl No 864000 The TTL of the data in the time series table. Unit: seconds. The default value is -1, which indicates that the data never expires. If the system detects that the difference between the current time and the time column that is passed to the table exceeds the specified TTL value, the system automatically deletes the expired data.
Important In a time series table, the system determines the time when the data is generated based on the time column that is passed to the table, not the time when the data is written to the table.Minimum value: 86400 seconds, which is one day. A value of -1 specifies that the data never expires.
- Example
Create a time series table named mytable in which the data never expires.
create -m timeseries -t mytable --ttl -1
Use a time series table
Select the data table on which you want to perform table operations or data operations.
- Command syntax
use --ts -t tableName
The following table describes the parameters that you must configure to use a time series table.
Parameter Required Example Description --ts Yes N/A Specifies that the table you want to use is a time series table. -t, --table Yes mytable The name of the time series table. - Example
Use a time series table named mytable.
use --ts -t mytable
List the names of tables
List the names of all tables, all data tables, or all time series tables in an instance.
- List the names of all tables of the same type as the current table
list
- List the names of all tables
list -a
- List the names of all data tables
list -w
- List the names of all time series tables
list -t
The following table describes the parameters that you can configure to list the names of tables.
Parameter | Required | Example | Description |
---|---|---|---|
-a, --all | No | N/A | Lists the names of all tables. |
-d, --detail | No | N/A | Lists the details about the tables. |
-w, --wc | No | N/A | Lists the names of all data tables. |
-t, --ts | No | N/A | Lists the names of all time series tables. |
Update a time series table
Modify the TTL configuration of a time series table.
- Command syntax
alter --ttl timeToLive --ts
The following table describes the parameters that you must configure to modify the TTL configuration of a time series table.
Parameter Required Example Description --ts Yes N/A Specifies that the table whose TTL configuration you want to modify is a time series table. --ttl Yes 864000 The TTL of the data in the time series table. Unit: seconds. The default value is -1, which indicates that the data never expires. If the system detects that the difference between the current time and the time column that is passed to the table exceeds the specified TTL value, the system automatically deletes the expired data.
Important In a time series table, the system determines the time when the data is generated based on the time column that is passed to the table, not the time when the data is written to the table.Minimum value: 86400 seconds, which is one day. A value of -1 specifies that the data never expires.
- Example
Set the TTL value of the current table to 86400 seconds.
alter --ttl 86400 --ts
Query the information about a time series table
Query the information about a time series table.
- Command syntax
desc --ts -t tableName
The following table describes the parameters that you must configure to query the information about a time series table.
Parameter Required Example Description --ts No N/A Specifies that the table whose information you want to query is a time series table. -t, --table No mytable The name of the time series table. This parameter is optional. -f, --print_format No json The output format of the information about the data table. Default value: json. Valid values: json and table. -o, --output No /tmp/describe_table_meta.json The path of the local JSON file in which the information about the time series table is stored. - Example
Query the information about the current table.
desc
Query the information about a time series table named mytable.desc --ts -t mytable
Delete a time series table
Delete a time series table that you no longer need.
- Command syntax
drop -t tableName --ts -y
The following table describes the parameters that you must configure to delete a time series table.
Parameter Required Example Description -t, --table Yes mytable The name of the time series table. -y, --yes Yes N/A Specifies that the confirmation information must appear. This parameter is required. --ts Yes N/A Specifies that the table you want to delete is a time series table. - Example
Delete a time series table named mytable.
drop -t mytable --ts -y