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.

Note For more information about the TimeSeries model, see Overview.

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.

    ParameterRequiredExampleDescription
    -m, --modelYestimeseriesThe type of the table that you want to create. Default value: widecolumn. Valid values:
    • widecolumn: data table.
    • timeseries: time series table.
    -t, --tableYesmytableThe name of the time series table.
    --ttlNo864000The 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.

    ParameterRequiredExampleDescription
    --tsYesN/ASpecifies that the table you want to use is a time series table.
    -t, --tableYesmytableThe 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.

ParameterRequiredExampleDescription
-a, --allNoN/ALists the names of all tables.
-d, --detailNoN/ALists the details about the tables.
-w, --wcNoN/ALists the names of all data tables.
-t, --tsNoN/ALists 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.

    ParameterRequiredExampleDescription
    --tsYesN/ASpecifies that the table whose TTL configuration you want to modify is a time series table.
    --ttlYes864000The 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.

    ParameterRequiredExampleDescription
    --tsNoN/ASpecifies that the table whose information you want to query is a time series table.
    -t, --tableNomytableThe name of the time series table. This parameter is optional.
    -f, --print_formatNojsonThe output format of the information about the data table. Default value: json. Valid values: json and table.
    -o, --outputNo/tmp/describe_table_meta.jsonThe 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.

    ParameterRequiredExampleDescription
    -t, --tableYesmytableThe name of the time series table.
    -y, --yesYesN/ASpecifies that the confirmation information must appear. This parameter is required.
    --tsYesN/ASpecifies 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