mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
40 lines
1.7 KiB
SQL
40 lines
1.7 KiB
SQL
-- Tags: no-replicated-database
|
|
-- Tag no-replicated-database: Unsupported type of ALTER query
|
|
|
|
DROP TABLE IF EXISTS test.partitions;
|
|
CREATE TABLE test.partitions (EventDate Date, CounterID UInt32) ENGINE = MergeTree(EventDate, CounterID, 8192);
|
|
INSERT INTO test.partitions SELECT EventDate + UserID % 365 AS EventDate, CounterID FROM test.hits WHERE CounterID = 1704509;
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
ALTER TABLE test.partitions DETACH PARTITION 201501;
|
|
|
|
SELECT count() FROM test.partitions;
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
ALTER TABLE test.partitions ATTACH PARTITION 201501;
|
|
|
|
SELECT count() FROM test.partitions;
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
|
|
ALTER TABLE test.partitions DETACH PARTITION 201403;
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
INSERT INTO test.partitions SELECT EventDate + UserID % 365 AS EventDate, CounterID FROM test.hits WHERE CounterID = 1704509 AND toStartOfMonth(EventDate) = toDate('2014-03-01');
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
ALTER TABLE test.partitions ATTACH PARTITION 201403;
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
|
|
DROP TABLE test.partitions;
|