如何在 clickhouse 中创建 table 时将自定义默认值添加到 Nullable 类型?
How to add custom default value to Nullable type when creating table in clickhouse?
我希望能够为特定行插入空值,而不是默认情况下
例如:
我希望能够为年龄插入空值,但如果未指定,则默认值为 10。
create table mytable
(
age Int null default 10,
name String
) ENGINE = MergeTree()
ORDER BY name
结果
Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 88 ('default') (line 3, col 26): default 10,
name String
) ENGINE = MergeTree()
ORDER BY name. Expected one of: CODEC, TTL, ClosingRoundBracket, Comma, COMMENT, token (version 21.8.10.19 (official build))
documentation 说:
NULL is the default value for any Nullable type, unless specified otherwise in the ClickHouse server configuration.
我想我必须在这个 page 上找到正确的设置或者我误解了默认值和 Nullable 类型之间的关系...
ClickHouse 有一个特殊的语法 Nullable( <type> )
--> age Nullable(Int)
create table mytable
(
age Nullable(Int) default 10,
name String
) ENGINE = MergeTree()
ORDER BY name
我希望能够为特定行插入空值,而不是默认情况下 例如: 我希望能够为年龄插入空值,但如果未指定,则默认值为 10。
create table mytable
(
age Int null default 10,
name String
) ENGINE = MergeTree()
ORDER BY name
结果
Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 88 ('default') (line 3, col 26): default 10,
name String
) ENGINE = MergeTree()
ORDER BY name. Expected one of: CODEC, TTL, ClosingRoundBracket, Comma, COMMENT, token (version 21.8.10.19 (official build))
documentation 说:
NULL is the default value for any Nullable type, unless specified otherwise in the ClickHouse server configuration.
我想我必须在这个 page 上找到正确的设置或者我误解了默认值和 Nullable 类型之间的关系...
ClickHouse 有一个特殊的语法 Nullable( <type> )
--> age Nullable(Int)
create table mytable
(
age Nullable(Int) default 10,
name String
) ENGINE = MergeTree()
ORDER BY name