ClickHouse/tests/queries/0_stateless/01166_truncate_multiple_partitions.sql
2022-05-06 16:12:31 +02:00

31 lines
1.1 KiB
SQL

drop table if exists trunc;
set default_table_engine='ReplicatedMergeTree';
create table trunc (n int, primary key n) engine=ReplicatedMergeTree('/test/1166/{database}', '1') partition by n % 10;
insert into trunc select * from numbers(20);
select count(), sum(n) from trunc;
alter table trunc detach partition all;
select count(), sum(n) from trunc;
alter table trunc attach partition id '0';
alter table trunc attach partition id '1';
alter table trunc attach partition id '2';
alter table trunc attach partition id '3';
select count(), sum(n) from trunc;
truncate trunc;
select count(), sum(n) from trunc;
drop table trunc;
set default_table_engine='MergeTree';
create table trunc (n int, primary key n) partition by n % 10;
insert into trunc select * from numbers(20);
select count(), sum(n) from trunc;
alter table trunc detach partition all;
select count(), sum(n) from trunc;
alter table trunc attach partition id '0';
alter table trunc attach partition id '1';
alter table trunc attach partition id '2';
alter table trunc attach partition id '3';
select count(), sum(n) from trunc;
truncate trunc;
select count(), sum(n) from trunc;
drop table trunc;