Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save den-crane/10993438d05bfda47d5a62824e7d32c2 to your computer and use it in GitHub Desktop.
Save den-crane/10993438d05bfda47d5a62824e7d32c2 to your computer and use it in GitHub Desktop.
CREATE TABLE test(A Int64, X String)
ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/test', 'R1')
ORDER BY A;
system stop merges test;
insert into test values(1, 0);
insert into test values(1, 1);
insert into test values(1, 2);
insert into test values(1, 4);
insert into test values(1, 5);
insert into test values(1, 6);
insert into test values(1, 7);
insert into test values(1, 8);
insert into test values(1, 9);
insert into test values(1, 10);
insert into test values(1, 11);
insert into test values(1, 12);
insert into test values(1, 13);
select * from test final;
┌─A─┬─X──┐
│ 1 │ 13 │
└───┴────┘
alter table test detach partition tuple(); alter table test attach partition tuple();
select * from test final;
┌─A─┬─X─┐
│ 1 │ 1 │
└───┴───┘
drop table test;
CREATE TABLE test(A Int64, X String)
ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/test', 'R1')
ORDER BY A;
system stop merges test;
insert into test values(1, 0);
insert into test values(1, 1);
insert into test values(1, 2);
insert into test values(1, 4);
insert into test values(1, 5);
insert into test values(1, 6);
insert into test values(1, 7);
insert into test values(1, 8);
insert into test values(1, 9);
insert into test values(1, 10);
insert into test values(1, 11);
insert into test values(1, 12);
insert into test values(1, 13);
select * from test final;
┌─A─┬─X──┐
│ 1 │ 13 │
└───┴────┘
detach table test; SYSTEM DROP REPLICA 'R1' FROM ZKPATH '/clickhouse/tables/test';
attach table test;
select * from test final;
┌─A─┬─X──┐
│ 1 │ 13 │
└───┴────┘
system restore replica test;
select * from test final;
┌─A─┬─X──┐
│ 1 │ 13 │
└───┴────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment