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-08-05 06:55:07 +00:00
|
|
|
Engine=ReplicatedMergeTree('/clickhouse/tables/{database}/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;
|