1.安装(命令来自于官网)
sudo apt-get install apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4echo "deb https://repo.clickhouse.com/deb/stable/ main/" | sudo tee \/etc/apt/sources.list.d/clickhouse.list
sudo apt-get updatesudo apt-get install -y clickhouse-server clickhouse-clientsudo service clickhouse-server start
clickhouse-client
2.登录(--password 在安装时设置密码当参数,没设置不用)
clickhouse-client --password
3.查看数据库
show databases
4.创建数据库(ddl语句大写区分)
CREATE DATABASE [ IF NOT EXISTS ] dbname;
--创建数据库
CREATE DATABASE db_test;--创建数据表
CREATE TABLE userinfo
(`uuid` String,`userName` String,`sex` String,`number` String,`phone` String
)
ENGINE = MergeTree
PARTITION BY sex
PRIMARY KEY uuid;--插入数据
INSERT INTO db_test.userinfo
(uuid, userName, sex, `number`, phone)
VALUES('87d0a235-8a90-44ef-a2f6-50abf862464a', '张三', '男', '0301481', '15121400000');
INSERT INTO db_test.userinfo
(uuid, userName, sex, `number`, phone)
VALUES('87d0a235-8a90-33ef-a2f6-50abf862464a', '王五', '男', '0400001', '13000000000');
INSERT INTO db_test.userinfo
(uuid, userName, sex, `number`, phone)
VALUES('87d0a235-8a90-44ef-a2f6-50abf862565a', '李四', '男', '0301141', '13121400000');