mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 20:53:27 +00:00
1.3 KiB
1.3 KiB
toc_priority | toc_title |
---|---|
44 | TTL |
Manipulations with Table TTL
MODIFY TTL
You can change table TTL with a request of the following form:
ALTER TABLE table_name MODIFY TTL ttl_expression;
REMOVE TTL {remove-ttl}
Removes TTL-property from the specified column.
Syntax:
ALTER TABLE table_name MODIFY column_name REMOVE TTL
Example
Requests and results:
To start the background cleaning using TTL, make this:
OPTIMIZE TABLE table_with_ttl FINAL;
SELECT * FROM table_with_ttl;
As a result you see that the second line was deleted.
2020-12-11 12:44:57 1 username1
ALTER TABLE table_with_ttl REMOVE TTL;
INSERT INTO table_with_ttl VALUES (now() - INTERVAL 4 MONTH, 2, 'username2');
OPTIMIZE TABLE table_with_ttl FINAL;
SELECT * FROM table_with_ttl;
And now we have nothing to delete.
--2020-12-11 12:44:57 1 username1
--2020-08-11 12:44:57 2 username2
See Also
- More about the TTL-expression.
- Modify column with TTL.