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

相关推荐
奇点 ♡14 小时前
MySQL基础题
数据库·sql·mysql
啊吧怪不啊吧14 小时前
SQL之表的时间类内置函数详解
大数据·服务器·数据库·sql
虎子_layor15 小时前
PostgreSQL这么多优势,为什么还要使用MySQL
后端·sql
Hello.Reader15 小时前
Flink 流式计算的状态之道从 Table/SQL 语义到算子状态与 TTL 精准控制
sql·flink·linq
wind_one116 小时前
5.基础--SQL--DDL数据库操作
数据库·sql
TDengine (老段)16 小时前
TDengine 数学函数 CRC32 用户手册
java·大数据·数据库·sql·时序数据库·tdengine·1024程序员节
llxxyy卢16 小时前
SQL注入之二次、加解密、DNS等注入
数据库·sql
珊珊而川16 小时前
MAC-SQL:SQL-Llama 的具体训练流程
sql·macos·llama
kali-Myon1 天前
NewStarCTF2025-Week4-Web
sql·安全·web安全·php·ctf·ssti·ssrf
liliangcsdn1 天前
如何利用约束提示优化LLM在问题转sql的一致性
数据库·sql