ClickHouse 使用

CREATE DATABASE test on cluster ck_00_1repl;

DROP TABLE local_t_ordt_order on cluster ck_00_1repl;

创建本地 local 表

CREATE TABLE test.local_order_db_t_order on cluster ck_00_1repl

(
forder_id_hash String,
forder_id String,
fuid Int32,
forder_type Int32,
fsale_type Int32,
frepay_type Int32,
forder_info String,
ftotal_amount Int64,
ftotal_handling_fee Int32,
ftotal_mon_pay Int32,
fextra_capital Int32,
ftotal_manage_fee Int64,
fversion Int32,
fpay_way Int32,
fpay_suc_time DateTime,
fetl_time DateTime,
forder_state Date,
f_p_date Date

)

ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')

PARTITION BY f_p_date

PRIMARY KEY (forder_type, fsale_type, forder_state)

ORDER BY (forder_type, fsale_type, forder_state, forder_id)

TTL f_p_date+ toIntervalDay(7)

SETTINGS index_granularity = 8192;

创建分布式 distributed 表

CREATE TABLE test.t_order_db_t_order on cluster ck_00_1repl

(
forder_id_hash String,
forder_id String,
fuid Int32,
forder_type Int32,
fsale_type Int32,
frepay_type Int32,
forder_info String,
ftotal_amount Int64,
ftotal_handling_fee Int32,
ftotal_mon_pay Int32,
fextra_capital Int32,
ftotal_manage_fee Int64,
fversion Int32,
fpay_way Int32,
fpay_suc_time DateTime,
fetl_time DateTime,
forder_state Date,
f_p_date Date

)

ENGINE = Distributed('ck_00_1repl', 'test', 'local_order_db_t_order', rand());

SHOW DATABASES;

SHOW TABLES;

INSERT INTO test.local_order_db_t_order(forder_id) VALUES ('1_10.9.104.249');

INSERT INTO test.local_order_db_t_order(forder_id) VALUES ('2_10.9.104.250');

select * from test.local_order_db_t_order;

select count(1) from test.local_order_db_t_order;

select * from test.t_order_db_t_order;

select count(1) from test.t_order_db_t_order;

数据量记录

1、实时数据仓库

4百亿+
4十亿+

2、日志


5.5万亿+
2.9千亿+

相关推荐
人道领域17 小时前
Day | 12 【苍穹外卖 :导出Excel数据表】
java·后端·sql·servlet·mvc·intellij-idea
芒果披萨17 小时前
sql实操
数据库·sql·mysql
不剪发的Tony老师17 小时前
FlowScope:一款注重隐私的SQL数据血缘分析工具
数据库·sql·数据血缘
星马梦缘18 小时前
数据库作战记录2
数据库·sql
Rick199318 小时前
SQL优化
数据库·sql
沪漂阿龙18 小时前
掌握MySQL这些函数,SQL水平直接起飞!
数据库·sql·mysql
marsh020619 小时前
23 openclaw防止SQL注入:参数化查询与ORM安全使用
数据库·sql·安全·ai·编程·技术
小江的记录本19 小时前
【端口号】计算机领域常见端口号汇总(完整版)
java·前端·windows·spring boot·后端·sql·spring
虾..1 天前
多路复用 --- select系统调用
服务器·数据库·sql
Ricky_Theseus1 天前
SQL Server 的五种约束类型
数据库·sql·oracle