ClickHouse/dbms/tests/queries/0_stateless/00933_alter_ttl.sql
Anton Popov 7f93f9ad2f TTL for columns and tables (#4212)
Add TTL for columns and tables.
2019-04-15 12:30:45 +03:00

25 lines
962 B
SQL

set send_logs_level = 'none';
drop table if exists test.ttl;
create table test.ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d);
alter table test.ttl modify ttl d + interval 1 day;
show create table test.ttl;
insert into test.ttl values (toDateTime('2000-10-10 00:00:00'), 1);
insert into test.ttl values (toDateTime('2000-10-10 00:00:00'), 2);
insert into test.ttl values (toDateTime('2100-10-10 00:00:00'), 3);
insert into test.ttl values (toDateTime('2100-10-10 00:00:00'), 4);
optimize table test.ttl partition 10 final;
select * from test.ttl order by d;
alter table test.ttl modify ttl a; -- { serverError 450 }
drop table if exists test.ttl;
create table test.ttl (d Date, a Int) engine = MergeTree order by tuple() partition by toDayOfMonth(d);
alter table test.ttl modify column a Int ttl d + interval 1 day;
desc table test.ttl;
alter table test.ttl modify column d Int ttl d + interval 1 day; -- { serverError 44}