分布式表
创建本地表
1 2 3 4 5 6 7 8 9 10 11
| CREATE TABLE zhangruiqi.daily_local ON CLUSTER my_cluster ( code UInt64, 'date' String, open Decimal(18, 2), high Decimal(18, 2) ) ENGINE = MergeTree() PARTITION BY toYYYYMM(trade_date) ORDER BY ('date', code);
|
创建分布式表
1 2 3 4 5 6 7 8 9
| CREATE TABLE zhangruiqi.daily ON CLUSTER my_cluster AS zhangruiqi.daily_local ENGINE = Distributed( 'my_cluster', 'zhangruiqi', 'daily_local', cityHash64(trade_id) );
|
shard(分片)、node、和 replica:
- shard 是逻辑概念,代表数据集的一部分
- node 代表一个 ClickHouse Server 实例
- replica:副本
