官方安装教程:clickhouse.com/docs/zh/get… 选择跟自己系统匹配的安装方式即可。
启动服务:/etc/init.d/clickhouse-server start 今日客户端:clickhouse-client
数据类型:
String 字符串: 只支持单引号包含的字符串
Int 数字
Date 日期
DateTime 日期时间
float
Decimal
FixedString 固定字符串
MAP:
CREATE TABLE table_map (a Map(String, UInt64)) ENGINE=Memory;
INSERT INTO table_map VALUES ({'key1':1, 'key2':10}), ({'key1':2,'key2':20}), ({'key1':3,'key2':30});
表结构:
describe test.user
desc test.user
解析sql
explain:
explain SELECT `number`, name, age, birthday, gender FROM test.`user` order by number desc limit 3 ;
增加字段
alter table 表名 add column 字段 UInt8 after number
alter table test.`user` add column core UInt8 after number
删除字段
alter table 表名 drop column 字段
alter table test.`user` drop column core
修改字段名:
alter table 表名 rename column 原字段名 to 新字段名
alter table test.`user` rename column gender to sex
修改字段备注:
alter table 表名 comment column 字段 '备注'
alter table test.`user` comment column name '姓名'
修改字段类型:
alter table 表名 modify column 字段 类型
alter table test.`user` modify column birthday Date