ClickHouse/tests/queries/0_stateless/01166_truncate_multiple_partitions.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
1.1 KiB
MySQL
Raw Normal View History

2022-05-06 14:12:31 +00:00
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;