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

相关推荐
斯特凡今天也很帅43 分钟前
clickhouse常用语句汇总——持续更新中
数据库·sql·clickhouse
海尔辛6 小时前
SQL 基础入门
数据库·sql
噼里啪啦啦.9 小时前
Spring事务和事务传播机制
数据库·sql·spring
李少兄9 小时前
解决 idea提示`SQL dialect is not configured` 问题
java·sql·intellij-idea
珹洺10 小时前
数据库系统概论(十七)超详细讲解数据库规范化与五大范式(从函数依赖到多值依赖,再到五大范式,附带例题,表格,知识图谱对比带你一步步掌握)
java·数据库·sql·安全·oracle
我科绝伦(Huanhuan Zhou)19 小时前
深入解析Oracle SQL调优健康检查工具(SQLHC):从原理到实战优化
数据库·sql·oracle
神奇侠20241 天前
Hive SQL常见操作
hive·hadoop·sql
一只叫煤球的猫1 天前
MySQL 8.0 SQL优化黑科技,面试官都不一定知道!
后端·sql·mysql
多多*1 天前
微服务网关SpringCloudGateway+SaToken鉴权
linux·开发语言·redis·python·sql·log4j·bootstrap
deriva1 天前
某水表量每15分钟一报,然后某天示数清0了,重新报示值了 ,如何写sql 计算每日水量
数据库·sql