mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #6849 from den-crane/patch-8
Doc change. TTL examples
This commit is contained in:
commit
ce47e707c1
@ -388,10 +388,66 @@ When the values in the column expire, ClickHouse replaces them with the default
|
||||
|
||||
The `TTL` clause can't be used for key columns.
|
||||
|
||||
Examples:
|
||||
|
||||
Creating a table with TTL
|
||||
|
||||
```sql
|
||||
CREATE TABLE example_table
|
||||
(
|
||||
d DateTime,
|
||||
a Int TTL d + INTERVAL 1 MONTH,
|
||||
b Int TTL d + INTERVAL 1 MONTH,
|
||||
c String
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toYYYYMM(d)
|
||||
ORDER BY d;
|
||||
```
|
||||
|
||||
Adding TTL to a column of an existing table
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY COLUMN
|
||||
c String TTL d + INTERVAL 1 DAY;
|
||||
```
|
||||
|
||||
Altering TTL of the column
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY COLUMN
|
||||
c String TTL d + INTERVAL 1 MONTH;
|
||||
```
|
||||
|
||||
**Table TTL**
|
||||
|
||||
When data in a table expires, ClickHouse deletes all corresponding rows.
|
||||
|
||||
Examples:
|
||||
|
||||
Creating a table with TTL
|
||||
|
||||
```sql
|
||||
CREATE TABLE example_table
|
||||
(
|
||||
d DateTime,
|
||||
a Int
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toYYYYMM(d)
|
||||
ORDER BY d
|
||||
TTL d + INTERVAL 1 MONTH;
|
||||
```
|
||||
|
||||
Altering TTL of the table
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY TTL d + INTERVAL 1 DAY;
|
||||
```
|
||||
|
||||
**Removing Data**
|
||||
|
||||
Data with an expired TTL is removed when ClickHouse merges data parts.
|
||||
|
@ -327,10 +327,64 @@ TTL date_time + INTERVAL 15 HOUR
|
||||
|
||||
Секцию `TTL` нельзя использовать для ключевых столбцов.
|
||||
|
||||
Примеры:
|
||||
|
||||
Создание таблицы с TTL
|
||||
|
||||
```sql
|
||||
CREATE TABLE example_table
|
||||
(
|
||||
d DateTime,
|
||||
a Int TTL d + INTERVAL 1 MONTH,
|
||||
b Int TTL d + INTERVAL 1 MONTH,
|
||||
c String
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toYYYYMM(d)
|
||||
ORDER BY d;
|
||||
```
|
||||
|
||||
Добавление TTL на колонку существующей таблицы
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY COLUMN
|
||||
c String TTL d + INTERVAL 1 DAY;
|
||||
```
|
||||
|
||||
Изменение TTL у колонки
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY COLUMN
|
||||
c String TTL d + INTERVAL 1 MONTH;
|
||||
```
|
||||
|
||||
**TTL таблицы**
|
||||
|
||||
Когда некоторые данные в таблице устаревают, ClickHouse удаляет все соответствующие строки.
|
||||
|
||||
Примеры:
|
||||
|
||||
```sql
|
||||
CREATE TABLE example_table
|
||||
(
|
||||
d DateTime,
|
||||
a Int
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toYYYYMM(d)
|
||||
ORDER BY d
|
||||
TTL d + INTERVAL 1 MONTH;
|
||||
```
|
||||
|
||||
Изменение TTL
|
||||
|
||||
```sql
|
||||
ALTER TABLE example_table
|
||||
MODIFY TTL d + INTERVAL 1 DAY;
|
||||
```
|
||||
|
||||
**Удаление данных**
|
||||
|
||||
Данные с истекшим TTL удаляются, когда ClickHouse мёржит куски данных.
|
||||
|
Loading…
Reference in New Issue
Block a user