ClickHous DDL以及函数使用
- 创建本地复制表:
CREATE TABLE table_local on cluster mycluster
(EventDate DateTime,
CounterID UInt32,
UserID UInt32
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/table_local', '{replica}')
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
SAMPLE BY intHash32(UserID);
- 创建分布式表:
CREATE TABLE table_distributed as table_local ENGINE = Distributed(mycluster, default, table_local, rand());
- 关于分布式表的配置