ClickHouse/tests/queries/0_stateless/01901_test_attach_partition_from.sql

24 lines
948 B
MySQL
Raw Normal View History

2021-06-07 21:30:03 +00:00
DROP TABLE IF EXISTS test_alter_attach_01901S;
DROP TABLE IF EXISTS test_alter_attach_01901D;
2021-06-08 09:11:06 +00:00
CREATE TABLE test_alter_attach_01901S (A Int64, D date) ENGINE = MergeTree PARTITION BY D ORDER BY A;
INSERT INTO test_alter_attach_01901S VALUES (1, '2020-01-01');
2021-06-07 21:30:03 +00:00
2021-06-08 09:11:06 +00:00
CREATE TABLE test_alter_attach_01901D (A Int64, D date)
2021-06-07 21:30:03 +00:00
Engine=ReplicatedMergeTree('/clickhouse/tables/test_alter_attach_01901D', 'r1')
2021-06-08 09:11:06 +00:00
PARTITION BY D ORDER BY A;
2021-06-07 21:30:03 +00:00
2021-06-08 09:11:06 +00:00
ALTER TABLE test_alter_attach_01901D ATTACH PARTITION '2020-01-01' FROM test_alter_attach_01901S;
2021-06-07 21:30:03 +00:00
2021-06-08 09:11:06 +00:00
SELECT count() FROM test_alter_attach_01901D;
SELECT count() FROM test_alter_attach_01901S;
2021-06-07 21:30:03 +00:00
2021-06-08 09:11:06 +00:00
INSERT INTO test_alter_attach_01901S VALUES (1, '2020-01-01');
ALTER TABLE test_alter_attach_01901D REPLACE PARTITION '2020-01-01' FROM test_alter_attach_01901S;
2021-06-07 21:30:03 +00:00
2021-06-08 09:11:06 +00:00
SELECT count() FROM test_alter_attach_01901D;
SELECT count() FROM test_alter_attach_01901S;
2021-06-07 21:30:03 +00:00
DROP TABLE test_alter_attach_01901S;
DROP TABLE test_alter_attach_01901D;