GBase 8a
其他
文章
clickhouse 建表create table MergeTree报错DB::Exception: Storage MergeTree requires 3 to 4 parameters
GBase社区管理员发表于2021-04-27 13:11:0520次浏览0个评论
Clickhouse 在创建MergeTree引擎的表时,必须指定一些必要的参数,否则会报DB::Exception: Storage MergeTree requires 3 to 4 parameters的错误。
报错样例
localhost :) create table t1(id int, name varchar(100),birthday date)ENGINE = MergeTree();
CREATE TABLE t1
(
`id` int,
`name` varchar(100),
`birthday` date
)
ENGINE = MergeTree
Query id: 6f3cbf90-2921-4eb8-b0e3-959b503bcb03
0 rows in set. Elapsed: 0.059 sec.
Received exception from server (version 21.4.5):
Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Storage MergeTree requires 3 to 4 parameters:
name of column with date,
[sampling element of primary key],
primary key expression,
index granularity
Syntax for the MergeTree table engine:
CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
(
name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1],
name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2],
...
INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1,
INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2
) ENGINE = MergeTree()
ORDER BY expr
[PARTITION BY expr]
[PRIMARY KEY expr]
[SAMPLE BY expr]
[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...]
[SETTINGS name=value, ...]
See details in documentation: https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/mergetree/. Other engines of the family support different syntax, see details in the corresponding documentation topics.
If you use the Replicated version of engines, see https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/replication/.
.
解决方案
指定一些必要的参数,比如主键列 primary key
localhost :) create table t1(id int, name varchar(100),birthday date)ENGINE = MergeTree() primary key id;
CREATE TABLE t1
(
`id` int,
`name` varchar(100),
`birthday` date
)
ENGINE = MergeTree
PRIMARY KEY id
Query id: 5f8f94dc-3db7-429c-b954-32538c859095
Ok.
0 rows in set. Elapsed: 0.057 sec.
localhost :)
评论已关闭
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25052
- 42023-09-25浏览数:18521
- 52020-05-11浏览数:17526