ClickHouse创建表

创建本地表:
CREATE TABLE default.xx on cluster default ( `id` Int64 COMMENT 'id', `plate_code` Nullable(String) COMMENT '板块编号', `plate_name` Nullable(String) COMMENT '板块名称', `date_time` Nullable(String) COMMENT '板块时间', `code` Nullable(String) COMMENT '小区code', `city_code` Nullable(String) COMMENT '城市code', `channel` Nullable(String) COMMENT '航道', `create_time` DateTime COMMENT '创建时间', `update_time` Nullable(DateTime) COMMENT '更新时间', `create_user` Nullable(String) COMMENT '创建人', `update_user` Nullable(String) COMMENT '更新人', `deleted` UInt8 COMMENT '是否删除 0:未删除,1:已删除', `province` Nullable(String) COMMENT '贝壳-省份', `community_name` Nullable(String) COMMENT '贝壳-小区名称', `area` Nullable(String) COMMENT '区域' ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/xx/{shard}', '{replica}') ORDER BY id SETTINGS index_granularity = 8192 CREATE TABLE default.xx on cluster default ( `id` Int64 COMMENT 'id', `plate_code` Nullable(String) COMMENT '板块编号', `plate_name` Nullable(String) COMMENT '板块名称', `date_time` Nullable(String) COMMENT '板块时间', `code` Nullable(String) COMMENT '小区code', `city_code` Nullable(String) COMMENT '城市code', `channel` Nullable(String) COMMENT '航道', `create_time` DateTime COMMENT '创建时间', `update_time` Nullable(DateTime) COMMENT '更新时间', `create_user` Nullable(String) COMMENT '创建人', `update_user` Nullable(String) COMMENT '更新人', `deleted` UInt8 COMMENT '是否删除 0:未删除,1:已删除', `province` Nullable(String) COMMENT '贝壳-省份', `community_name` Nullable(String) COMMENT '贝壳-小区名称', `area` Nullable(String) COMMENT '区域' ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/xx/{shard}', '{replica}') ORDER BY id SETTINGS index_granularity = 8192

 

创建分布式表:

CREATE TABLE default.xx
(
    `id` Int64 COMMENT 'id',
    `plate_code` Nullable(String) COMMENT '板块编号',
    `plate_name` Nullable(String) COMMENT '板块名称',
    `date_time` Nullable(String) COMMENT '板块时间',
    `code` Nullable(String) COMMENT '小区code',
    `city_code` Nullable(String) COMMENT '城市code',
    `channel` Nullable(String) COMMENT '航道',
    `create_time` DateTime COMMENT '创建时间',
    `update_time` Nullable(DateTime) COMMENT '更新时间',
    `create_user` Nullable(String) COMMENT '创建人',
    `update_user` Nullable(String) COMMENT '更新人',
    `deleted` UInt8 COMMENT '是否删除 0:未删除,1:已删除',
    `province` Nullable(String) COMMENT '贝壳-省份',	
    `community_name` Nullable(String) COMMENT '贝壳-小区名称',
    `area` Nullable(String) COMMENT '区域'
)
ENGINE = Distributed('default', 'default', 'falcon_beike_plate_relation', rand())



CREATE TABLE default.xx
(
    `id` Int64 COMMENT 'id',
    `plate_code` Nullable(String) COMMENT '板块编号',
    `plate_name` Nullable(String) COMMENT '板块名称',
    `date_time` Nullable(String) COMMENT '板块时间',
    `code` Nullable(String) COMMENT '小区code',
    `city_code` Nullable(String) COMMENT '城市code',
    `channel` Nullable(String) COMMENT '航道',
    `create_time` DateTime COMMENT '创建时间',
    `update_time` Nullable(DateTime) COMMENT '更新时间',
    `create_user` Nullable(String) COMMENT '创建人',
    `update_user` Nullable(String) COMMENT '更新人',
    `deleted` UInt8 COMMENT '是否删除 0:未删除,1:已删除',
    `province` Nullable(String) COMMENT '贝壳-省份',
    `community_name` Nullable(String) COMMENT '贝壳-小区名称',
    `area` Nullable(String) COMMENT '区域'
)
ENGINE = Distributed('default', 'default', 'xx', rand())

 

posted @ 2023-07-28 10:38  甜菜波波  阅读(226)  评论(0编辑  收藏  举报