当前位置:网站首页>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

边栏推荐
猜你喜欢

C语言 一级指针

哈夫曼树以及哈夫曼编码在文件压缩上的应用

三次握手四次挥手针对面试总结

Detailed explanation of serial port communication

实现简单的数据库查询(不完整)

GPIO的输入输出详解
![[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises](/img/6f/f7c5d605ea9b7b9e7c49ac716492ef.jpg)
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises

【C语言系列】—深度解剖数据在内存中的存储(一) 暑假开篇

Occt learning 003 - MFC single document project

Alibaba cloud architect details nine trends in the game industry
随机推荐
The function of using wechat applet to scan code to log in to the PC web of the system
Database operation day 6
Live broadcast Preview: integration of JD cloud Devops and jfrog product library
Bubble sort c language
QT learning: qdropevent drag event
GPIO的输入输出详解
The road to success in R & D efficiency of 1000 person Internet companies
B - 识别浮点常量问题
C language first level pointer
C语言数组典型应用代码详细讲解—高手误入(逐步代码详解)
Day 3
Alibaba cloud architect details nine trends in the game industry
Pointer
Side effects and sequence points
paddle.fluild常量计算报错‘NoneType‘ object has no attribute ‘get_fetch_list‘
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
力扣994:腐烂的橘子(BFS)
QML control: combobox
[event preview] cloud development, efficient and intelligent - the second Alibaba cloud ECS cloudbuild developer competition is about to start
Summary of the first week