彪悍开源的分析数据库-ClickHouse
趣头条基于ClickHouse玩转每天1000亿数据量
Clickhouse替代ES后,日志查询速度提升了38倍
基于ClickHouse的大数据全链路监控平台实践
微服务治理实战:Hadoop和Spark,都不及Clickhouse香
天啦,从Mongo到ClickHouse我到底经历了什么?
Docker安装Clickhouse
Clickhouse Docker集群部署
常见ClickHouse集群部署架构
ClickHouse高可用集群方案
ClickHouse 官网文档
篇一|ClickHouse快速入门
篇二|什么是ClickHouse的表引擎?
篇三|ClickHouse的数据类型
springboot+mybatisplus+druid配置mysql与clickhouse多数据源配置
SpringBoot + Mybatis Plus + Druid 配置多数据源
SpringBoot + Mybatis Plus + ClickHouse增删改查入门教程
Canal Server发送binlog消息到Kafka消息队列中
如何使用Canal同步MySQL的Binlog到Kafka
基于Canal和Kafka实现MySQL的Binlog近实时同步
clickhouse同步kafka数据方案
腾讯大牛教你ClickHouse实时同步MySQL数据
MySQL数据导入到ClickHouse
史上最全-mysql迁移到clickhouse的5种办法
创建本地表
CREATE DATABASE IF NOT EXISTS test_database;
创建分页式表
CREATE DATABASE IF NOT EXISTS test_database on cluster cluster_name;
删除数据库
drop database test_database;
CREATE TABLE user_info_ck ENGINE = MergeTree ORDER BY id AS SELECT * FROM mysql('127.0.0.1:5986', 'user', 'user_info', 'root', 'root');
DROP table if exists default.product_id;
CREATE TABLE default.product_id
(
factory_goods_id UInt32 COMMENT '工厂商品ID',
goods_name String COMMENT '商品名称',
shop_id UInt32 COMMENT '店铺ID',
shop_name String COMMENT '店铺名称',
create_time DateTime COMMENT '创建时间',
update_time DateTime COMMENT '更新时间'
) ENGINE = MergeTree()
PRIMARY KEY factory_goods_id
ORDER BY factory_goods_id
创建分页式表
DROP table if exists product_id on cluster cluster_name;
CREATE TABLE product_id on cluster cluster_name
(
factory_goods_id UInt32 COMMENT '工厂商品ID',
goods_name String COMMENT '商品名称',
shop_id UInt32 COMMENT '店铺ID',
shop_name String COMMENT '店铺名称',
create_time DateTime COMMENT '创建时间',
update_time DateTime COMMENT '更新时间'
) ENGINE = MergeTree()
PRIMARY KEY factory_goods_id
ORDER BY factory_goods_id
DROP table db.视图表 ON CLUSTER cluster_name;
DROP table db.本地表 ON CLUSTER cluster_name;
rename table default.dept to scott.dept;
rename table default.dept to default.dept2;
CREATE TABLE IF NOT EXISTS t_emp AS scott.emp ENGINE = TinyLog
create table if not exists t_employee engine=Memory as select * from scott.emp;
desc scott.emp;
alter table scott.emp add column remark varchar(128) comment '说明信息' TTL createtime + toIntervalDay(31);
alter table tableName add column newcolname String;
alter table tableName add column newcolname String after col1;
ALTER table advertsierdaily_super_ck MODIFY COLUMN real_principal_consume Decimal(16,4);
修改字段默认值
ALTER table advertsierdaily_superfans_ck3 MODIFY COLUMN sign DEFAULT 1;
alter table tableName drop column newcolname;
alter table scott.emp CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name
alter table scott.emp COMMENT COLUMN name 'comment'
INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
ALTER TABLE <table_name> UPDATE col1 = expr1, ... WHERE <filter>
更新和删除限制:
索引列不能进行更新
分布式表不能进行更新
该命令是异步执行的,可以通过查看表 system.mutations 来查看命令的是否执行完毕
强制更新或删除 使用 OPTIMIZE TABLE emp_table
按分区删除
ALTER TABLE db_name.table_name DROP PARTITION '20200601'
按条件删除
ALTER TABLE db_name.table_name DELETE WHERE day = '20200618'
ALTER TABLE test_user_ck DELETE where version >=0
truncate table scott.department;
clickhouse-client --query "select * from t_order_mt where create_time='2022-06-01 12:00:00'" --format CSVWithNames> /opt/module/data/rs1.csv
OPTIMIZE TABLE emp_table
CREATE TABLE traffic (
`date` Date,
...
) ENGINE = MergeTree(date, (end_time), 8192);
我想在PARTITION BY toYYYYMMDD(date)没有删除表的情况下更改如何执行此操作。
由于ALTER 查询不允许分区更改,因此可能的方法是创建一个新表
CREATE TABLE traffic_new
(
`date` Date,
...
)
ENGINE = MergeTree(date, (end_time), 8192)
PARTITION BY toYYYYMMDD(date);
并移动您的数据
INSERT INTO traffic_new SELECT * FROM traffic WHERE column BETWEEN x and xxxx;
重命名最终表。是的,这个选项涉及删除旧表(似乎没有办法跳过这一步)
DROP TABLE IF EXISTS default.traffic
rename table default.traffic_new to default.traffic;
clickhouse物化视图
clickhouse-物化视图
clickhouse物化视图详解