集群表

==作者:YB-Chi==

  1. 通过cluster在每个节点创建本地表
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE st_order_mt ON CLUSTER cyb_cluster
(
`id` UInt32,
`sku_id` String,
`total_amount` Decimal(16, 2),
`create_time` Datetime
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/st_order_mt', '{replica}')
PARTITION BY toYYYYMMDD(create_time)
PRIMARY KEY id
ORDER BY (id, sku_id)
  1. 创建Distribute分布式表
1
2
3
4
5
6
7
8
CREATE TABLE st_order_mt_ALL ON CLUSTER cyb_cluster
(
`id` UInt32,
`sku_id` String,
`total_amount` Decimal(16, 2),
`create_time` Datetime
)
ENGINE = Distributed(cyb_cluster, cyb, st_order_mt, hiveHash(sku_id))
文章作者: CYBSKY
文章链接: https://cybsky.top/2022/10/28/cyb-mds/database/ClickHouse/集群表/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 CYBSKY