---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/reference/ydb-cli/table-ttl-set.md?version=v26.1
  - https://ydb.tech/docs/ru/reference/ydb-cli/table-ttl-set.md?version=v26.1
  - href: en/reference/ydb-cli/table-ttl-set.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/reference/ydb-cli/table-ttl-set.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# Setting TTL parameters

Use the `table ttl set` subcommand to set [TTL](https://ydb.tech/docs/en/concepts/ttl.md?version=v26.1) for the specified table.

General format of the command:

```bash
ydb [global options...] table ttl set [options...] <table path>
```

* `global options`: [Global parameters](https://ydb.tech/docs/en/reference/ydb-cli/commands/global-options.md?version=v26.1).
* `options`: [Parameters of the subcommand](#options).
* `table path`: The table path.

View a description of the TTL set command:

```bash
ydb table ttl set --help
```

## Parameters of the subcommand {#options}

| 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](../../yql/reference/types/primitive.md#numeric) or [date and time](../../yql/reference/types/primitive.md#datetime) type.<br/>In case of the numeric type, the value will be interpreted as the time elapsed since the beginning of the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). 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.<br/>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](../../yql/reference/types/primitive.md#numeric) type.<br/>Possible values:<ul><li>`seconds (s, sec)`: Seconds.</li><li>`milliseconds (ms, msec)`: Milliseconds.</li><li>`microseconds (us, usec)`: Microseconds.</li><li>`nanoseconds (ns, nsec)`: Nanoseconds.</li></ul>                                                                       |
| `--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).<br/>The default value is `3600`.                                                                                                                                                                                                                                                     |

## Examples {examples}

<!-- source: en/_includes/ydb-cli-profile.md -->
{% note info %}

The examples use the `quickstart` profile. To learn more, see [Creating a profile to connect to a test database](https://ydb.tech/docs/en/reference/ydb-cli/profile/create.md?version=v26.1#quickstart).

{% endnote %}
<!-- endsource: en/_includes/ydb-cli-profile.md -->

Set TTL for the `series` table

```bash
ydb -p quickstart table ttl set \
  --column createtime \
  --expire-after 3600 \
  --run-interval 1200 \
  series
```
