Clickhouse 的MergeTree引擎,要求必须提供order by 或者 primary key, 否则表创建失败。但Clickhouse提供了 tuple功能,可以不指定排序列。
目录导航
语法
ORDER BY tuple()
样例
CREATE TABLE t_no_order
(
CREATE TABLE t_tuple
(
`id` int,
`name` varchar(100)
)
ENGINE = MergeTree
ORDER BY tuple()
向无排序列的表插入数据
localhost :) insert into t_tuple select * from t2 where id is not null;
INSERT INTO t_tuple SELECT *
FROM t2
WHERE isNotNull(id)
Query id: c369acda-5452-4ec1-93dc-07f6ca4ac109
Ok.
0 rows in set. Elapsed: 0.005 sec.
localhost :) select * from t_tuple;
SELECT *
FROM t_tuple
Query id: 067c6500-e45f-484d-8c74-5b30060fce7c
┌─id─┬─name─┐
│ 1 │ 111 │
│ 1 │ 111 │
│ 2 │ 2222 │
└────┴──────┘
3 rows in set. Elapsed: 0.002 sec.