当前位置:网站首页>ClickHouse学习(四)SQL操作
ClickHouse学习(四)SQL操作
2022-07-29 05:09:00 【阳光里哭泣的狗】
增
INSERT INTO 数据库名.表名 [(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');
删
虽然clickhouse提供了删除和修改的功能但是其原理还是需要和alter语法相结合而且不支持事务。
删除表中某一元素
ALTER TABLE [数据库名.]表名 delete where 字段 = '属性值';
alter table t_order_smt delete where sku_id ='sku_001';

删除表中某一列
ALTER TABLE 表名 DROP COLUMN [IF EXISTS] 字段名
alter table t_order_mt drop column total_amount;

删除表
DROP TABLE 表名
drop table t_order_mt;


改
增加一列
ALTER TABLE 表名 ADD COLUMN 列名 字段类型 AFTER 已有的列
alter table t_order_rmt add column test String after sku_id;

添加注释
ALTER TABLE 表名 COMMENT 字段名 'xxxxxxxxxx'
alter table t_order_rmt comment column test '测试添加注释';

更改列的类型
ALTER TABLE 表名 MODIFY COLUNM 字段名 字段类型
alter table t_order_rmt modify column test int;

查
和mysql基本一致就不写了,具体的官网写的很详细了
https://clickhouse.tech/docs/zh/sql-reference/statements/select/
注意:
- 它支持各种join,但是join操作无法使用缓存,所以即使是两次相同的join语句,clickhouse也会视为两条新sql
- 不支持自定义函数
- 窗口函数也还在测试
数据导入
数据
csv形式
cat test.csv | clickhouse-client --query="insert into im_test format CSV";

自定义分割符
cat test.csv | clickhouse-client --format_csv_delimiter="|" --query="INSERT INTO im_test FORMAT CSV";

数据导出
clickhouse-client --query "select * from im_test where age=23" --format CSVWithNames> /root/test2.csv

边栏推荐
- GPIO的输入输出详解
- Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system
- Cryengine3 debugging shader method
- Alibaba cloud architect details nine trends in the game industry
- B - identify floating point constant problems
- Detailed explanation of GPIO input and output
- 浅谈Servlet
- 167. 两数之和 II - 输入有序数组
- 【C语言系列】— 一道递归小题目
- ·来一篇编程之路的自我介绍吧·
猜你喜欢

200 多家 ISV 入驻!阿里云计算巢发布一周年

365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array

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

Preemptive appointment | Alibaba cloud shadowless cloud application online conference appointment opens

PyQt5:第一章第1节:使用Qt组件创建一个用户界面-介绍

力扣994:腐烂的橘子(BFS)

阿里云联合鼎捷软件发布云上数字工厂解决方案,实现云MES系统本地化部署

【C语言系列】— 不创造第三个变量,实现两个数的交换

C语言 一维数组

321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
随机推荐
Cryengine Technology
C语言文件操作
副作用和序列点
MySQL的基础概念+数据库系统结构+拓展延申+基础命令学习
【C语言系列】—文件操作详解(上)
Camunda 1. Camunda workflow - Introduction
Come on! See how Clickhouse, which has risen 16 places a year, can be implemented in jd.com
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
C语言 一维数组
Redirection and files
科班同学真的了解未来的职业规划吗?
C语言数组入门到精通(数组精讲)
C语言 N皇后问题
ClickHouse学习(七)表查询优化
整数溢出和打印
无重复字符的最长字串
Live broadcast preview | how to save 30% labor cost and shorten 80% trademark processing cycle?
串口通讯部分详解
365 day challenge leetcode 1000 questions - day 042 array sequence number conversion + relative ranking discretization processing