ClickHouse中建表默认指定数据写入时间
例如:下表中的insert_time、date两个字段是在每次写入数据都不需要指定的,系统会自动生成。
非all表
CREATE TABLE db_name.tb_name ON CLUSTER bip_ck_cluster (
ip String,
cdn String,
insert_time DateTime DEFAULT now(),
date Date DEFAULT toDate(now()))
ENGINE = MergeTree ORDER BY ip SETTINGS index_granularity = 8192;
all表
CREATE TABLE IF NOT EXISTS db_name.tb_name_all
ON CLUSTER bip_ck_cluster AS db_name.tb_name
ENGINE = Distributed(bip_ck_cluster, 'db_name', 'tb_name', rand());