Setting TTL parameters
Use the table ttl set
subcommand to set TTL for the specified table.
General format of the command:
ydb [global options...] table ttl set [options...] <table path>
global options
: Global parameters.options
: Parameters of the subcommand.table path
: The table path.
View a description of the TTL set command:
ydb table ttl set --help
Parameters of the subcommand
Name | Description |
---|---|
--column |
The name of the column that will be used to calculate the lifetime of the rows. The column must have the numeric or date and time type. In case of the numeric type, the value will be interpreted as the time elapsed since the beginning of the Unix epoch. Measurement units must be specified in the --unit parameter. |
--expire-after |
Additional time before deleting that must elapse after the lifetime of the row has expired. Specified in seconds. The default value is 0 . |
--unit |
The value measurement units of the column specified in the --column parameter. It is mandatory if the column has the numeric type.Possible values:
|
--run-interval |
The interval for running the operation to delete rows with expired TTL. Specified in seconds. The default database settings do not allow an interval of less than 15 minutes (900 seconds). The default value is 3600 . |
Examples
Note
The examples use the quickstart
profile. To learn more, see Creating a profile to connect to a test database.
Set TTL for the series
table
ydb -p quickstart table ttl set \
--column createtime \
--expire-after 3600 \
--run-interval 1200 \
series