您的位置:首页 > 教育 > 锐评 > 建设部四库一平台查询_学网页设计怎样_企业培训有哪些方面_百度大数据官网

建设部四库一平台查询_学网页设计怎样_企业培训有哪些方面_百度大数据官网

2024/10/5 16:26:53 来源:https://blog.csdn.net/u013416034/article/details/142425117  浏览:    关键词:建设部四库一平台查询_学网页设计怎样_企业培训有哪些方面_百度大数据官网
建设部四库一平台查询_学网页设计怎样_企业培训有哪些方面_百度大数据官网

下面将介绍一下 ClickHouse 建表SQL ,集群名 star_cluster

我这里以test 表   test_all 集群表 为演示   可以执行下面的SQL 

新建本地表

DROP TABLE IF EXISTS test ON CLUSTER star_cluster;
DROP TABLE IF EXISTS test_all ON CLUSTER star_cluster;
CREATE TABLE  test ON CLUSTER star_cluster
(`id` UInt32,`value` UInt8
)
ENGINE = MergeTree
ORDER BY id;

新建集群表 test_all  

CREATE TABLE test_all ON CLUSTER star_cluster AS test
ENGINE = Distributed(star_cluster, demo, test, id);

注:其中demo 为 数据库名称  

下面我们插入一些数据  验证一下

INSERT INTO test_all SELECT number AS id, toUInt8(rand()) FROM numbers(10000);

上面的sql 是 生成10000条数据  我们分别去查询一下 test_all集群表的数据 和test表的数据

-- 查询集群表
SELECT count() FROM test_all;   --查询本地本
SELECT count() FROM test

如果当前集群节点为2个时,那么我们查询test_all表时,总数量为10000, 在任意一台服务器上查询test本地表,则数量为5000, 在另一台节点查询test本地表数量也为5000,则说明ClickHouse正常.

下面将介绍一个预警表  字段设计如下:

字段名称

类型

含义

date

Date

预警日期

info_id

FixedString(16)

唯一uuid

warning_info_id

FixedString(16)

uuid 

type

UInt8

预警类型

location_id

UInt64

点位id

warning_num

UInt8

预警数量

capture_time

UInt32

预警抓拍时间戳

duration_time

UInt64

停留时间 秒

orgin_info_id

FixedString(16)

原始uuid

task_id

UInt64

任务id 关联表主键

detection

String

坐标 {"x”:222,”y”:33,”w”:44,”h”:44} 

image_url

String

场景大图

feature

String CODEC(NONE)

特征值  (没有用)

name

String

姓名

id_number

String

身份证

similarity

String

相似度 单位%

license_plate2

String

车牌号

plate_type_id

UInt8

车牌种类

insert_time

UInt32

写入数据时间戳

建表sql:
CREATE TABLE  warning_result ON CLUSTER star_cluster
(`date` Date DEFAULT toDate(capture_time),`info_id` FixedString(16),`warning_info_id` FixedString(16),`type` UInt8,`location_id` UInt64,`warning_num` UInt8,`capture_time` UInt32,`duration_time` UInt64,`orgin_info_id`   FixedString(16),`task_id`    UInt64,
`detection` String,
`image_url` String,
`feature` String CODEC(NONE),
`name`  String,
`id_number` String,
`similarity`  String,
`license_plate2` String,
`plate_type_id` UInt8,
`insert_time` UInt32 DEFAULT toUnixTimestamp(now())
)
ENGINE = MergeTree
PARTITION BY date
ORDER BY (capture_time,info_id);#集群表
CREATE TABLE warning_result_all ON CLUSTER star_cluster AS warning_result ENGINE = Distributed(star_cluster, demo, warning_result, rand());

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com