当前位置:网站首页>Clickhouse learning (IV) SQL operation
Clickhouse learning (IV) SQL operation
2022-07-29 05:33:00 【Crying dogs in the sun】
Catalog
increase
INSERT INTO Database name . Table name [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
insert into t_order_mt values
(101,'sku_001',1000.00,'2021-08-01 12:00:00'),
(101,'sku_002',2000.00,'2021-08-01 12:00:00');
Delete
although clickhouse It provides the function of deletion and modification, but its principle still needs to be consistent with alter Syntax combined and transaction not supported .
Delete an element in the table
ALTER TABLE [ Database name .] Table name delete where Field = ' Property value ';
alter table t_order_smt delete where sku_id ='sku_001';

Delete a column in the table
ALTER TABLE Table name DROP COLUMN [IF EXISTS] Field name
alter table t_order_mt drop column total_amount;

Delete table
DROP TABLE Table name
drop table t_order_mt;


Change
Add a row
ALTER TABLE Table name ADD COLUMN Name Field type AFTER Existing columns
alter table t_order_rmt add column test String after sku_id;

Add notes
ALTER TABLE Table name COMMENT Field name 'xxxxxxxxxx'
alter table t_order_rmt comment column test ' Test add comments ';

Change the type of column
ALTER TABLE Table name MODIFY COLUNM Field name Field type
alter table t_order_rmt modify column test int;

check
and mysql If it's basically the same, don't write , The specific official website is very detailed
https://clickhouse.tech/docs/zh/sql-reference/statements/select/
Be careful :
- It supports all kinds of join, however join The operation cannot use the cache , So even if it's the same twice join sentence ,clickhouse It will also be regarded as two new sql
- Custom functions are not supported
- The window function is also being tested
Data import
data 
csv form
cat test.csv | clickhouse-client --query="insert into im_test format CSV";

Custom splitters 
cat test.csv | clickhouse-client --format_csv_delimiter="|" --query="INSERT INTO im_test FORMAT CSV";

Export data
clickhouse-client --query "select * from im_test where age=23" --format CSVWithNames> /root/test2.csv

边栏推荐
- Camunda 1、Camunda工作流-介绍
- Yangyonglin, vice president of Rushi Technology: when traditional industries encounter "digital space"
- Detailed explanation of serial port communication
- 分配内存:malloc()和free()
- Allocate memory: malloc() and free()
- 阿里云张新涛:异构计算为数字经济提供澎湃动力
- 365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
- 题解:在一个排序数组中查找元素第一个和最后一个的位置 (个人笔记)
- 力扣994:腐烂的橘子(BFS)
- C language n queen problem
猜你喜欢

ClickHouse学习(三)表引擎

Day 3

Container security open source detection tool - veinmind (mirror backdoor, malicious samples, sensitive information, weak password, etc.)

无重复字符的最长字串

ClickHouse学习(十)监控运行指标

Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system

NVIDIA Zhou Xijian: the last mile from design to digital marketing

ClickHouse学习(五)集群操作

·来一篇编程之路的自我介绍吧·

On Paradigm
随机推荐
一维数组练习
数据库操作 Day 6
Best practices for elastic computing in the game industry
vim编辑器使用
Occt learning 003 - MFC single document project
微信小程序视频上传组件直接上传至阿里云OSS
抽象类与接口
刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解
C语言数组入门到精通(数组精讲)
During the appointment, the 2022 JD cloud industrial integration new product launch was launched online
C语言 一维数组
Pointer
QML control: combobox
【C语言系列】— 不创造第三个变量,实现两个数的交换
Alibaba cloud architect Liang Xu: MES on cloud box helps customers quickly build digital factories
水一篇图的拓扑排序
【C语言系列】—文件操作详解(上)
终端shell常用命令
Redirection and files
Time complexity and space complexity