ClickHouse新建库表
集群部署传送门
https://blog.youkuaiyun.com/xushijie89/article/details/123039704
新建库
CREATE DATABASE db_name on cluster cluster_3shards_2replicas COMMENT '测试库'
新建物理表
create table table_name on cluster cluster_3shards_2replicas(
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine = ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/table_name','{replica}')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
新建分布式表(逻辑表)
create table db_name.table_name_all on cluster cluster_3shards_2replicas(
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) ENGINE = Distributed(cluster_3shards_2replicas, db_name, table_name, hiveHash(id));