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千亿+

相关推荐
Decay__24 分钟前
05_MySQL 常用 SQL 大全 —— 诊断、管理、优化辅助 SQL 与三大系统库速查
运维·数据库·sql·mysql·架构
Decay__6 小时前
04_MySQL DBA 日常运维手册 —— 会话管理、锁与阻塞、事务监控、慢查询与日志巡检
运维·数据库·sql·mysql·架构
吃一碗粉只付一碗钱12 小时前
10-令牌里的用户主键不要明文
服务器·数据库·sql·sqlserver·c#
sun032213 小时前
【JDK 动态代理】 和 【CGLIB 代理】对比
java·数据库·sql
l1t15 小时前
DeepSeek总结的AI 智能体应该用哪种语言搜索其记忆:SQL 还是 SPARQL?
数据库·人工智能·sql
geovindu16 小时前
SQL Data Sampling and Approximation Techniques using postgreSQL 18
大数据·数据库·数据仓库·sql·postgresql·数据库开发·数据库架构
l1t17 小时前
DeepSeek总结的从 SQL 桥梁到智能体基础设施:Hex 的 DuckDB 实践
数据库·sql·duckdb
正儿八经的少年17 小时前
MyBatis 一对一、一对多 SQL
数据库·sql·mybatis
Decay__18 小时前
03_MySQL 存储引擎与存储管理 —— InnoDB 深入、表空间/ibd、binlog/redo/undo 与双写缓冲
运维·数据库·sql·mysql·架构