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));
本文详细介绍了如何在ClickHouse中进行集群部署、新建数据库和物理表,并展示了如何创建分布式表。通过示例代码,展示了CREATE DATABASE和CREATE TABLE语句的使用,以及ReplicatedMergeTree和Distributed引擎的配置,包括分区键、主键和排序键的设定,为数据存储和查询提供了基础架构。
3750

被折叠的 条评论
为什么被折叠?



