1.腾讯云集群建表格式
CREATE TABLE ads_product_history_info on cluster default_cluster
(
`asin` String COMMENT 'ASIN',
`country` String COMMENT '站点',
`category_bsr` Nullable(Int32) COMMENT '大类目bsr排名',
`little_category_bsr` Nullable(Int32) COMMENT '小类目bsr排名',
`reviews` Nullable(Int32) COMMENT '评分数',
`last_day_add_reviews` Nullable(Int32) COMMENT '较昨日新增评分数',
`rating` Nullable(Decimal(2, 1)) COMMENT '评分值',
`price` Nullable(Decimal(18, 2)) COMMENT '价格',
`create_time` Nullable(DateTime) DEFAULT toDateTime(now()) COMMENT '生成时间',
`craw_hour` String COMMENT '爬取时间小时',
`Sign` Int8
)
ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/{uuid}/{shard}/amazing_tracker_pre/ads_product_history_info', '{replica}', Sign)
PARTITION BY craw_hour
PRIMARY KEY (asin, country, craw_hour)
ORDER BY (asin, country, craw_hour)
SETTINGS replicated_deduplication_window = 0, index_granularity = 8192;
2.阿里云单机建表格式
CREATE TABLE selectx.ads_product_history_info
(
`asin` String COMMENT 'ASIN',
`country` String COMMENT '站点',
`category_bsr` Nullable(Int32) COMMENT '大类目bsr排名',
`little_category_bsr` Nullable(Int32) COMMENT '小类目bsr排名',
`reviews` Nullable(Int32) COMMENT '评分数',
`last_day_add_reviews` Nullable(Int32) COMMENT '较昨日新增评分数',
`rating` Nullable(Decimal(2, 1)) COMMENT '评分值',
`price` Nullable(Decimal(18, 2)) COMMENT '价格',
`create_time` Nullable(DateTime) DEFAULT toDateTime(now()) COMMENT '生成时间',
`craw_hour` String COMMENT '爬取时间小时',
`Sign` Int8
)
ENGINE = CollapsingMergeTree( Sign)
PARTITION BY craw_hour
PRIMARY KEY (asin, country, craw_hour)
ORDER BY (asin, country, craw_hour)
SETTINGS replicated_deduplication_window = 0, index_granularity = 8192;
对比上面的两者建表区别:
1.在建表表名后面有无on cluster default_cluster
2.ENGINE两者不同
3.引擎后面的参数三个变一个