定义表格:
CREATE TABLE test
(
`created_at` DateTime DEFAULT now(),
`created_by` Nullable(Int64)
)ENGINE=TinyLog;
插入数据:
insert into test ( created_at,created_by) values(null,null)
在 clickhouse-server:21.9.4.35 版本,上述语句可以正常执行,插入数据:
03f1f51b76a9 :) select * from test;
SELECT *
FROM test
Query id: 4726bec5-4443-4b1f-bacf-bd60f69dde60
┌──────────created_at─┬─created_by─┐
│ 2021-11-03 02:18:34 │ ᴺᵁᴸᴸ │
└─────────────────────┴────────────┘
1 rows in set. Elapsed: 0.006 sec.
而在 clickhouse-server:20.5.4.40 执行则报错,没有插入默认值:
dd4f1dff9dd0 :) insert into test ( created_at,created_by) values(null,null)
INSERT INTO test (created_at, created_by) VALUES
Exception on client:
Code: 53. DB::Exception: Cannot insert NULL value into a column of type 'DateTime' at: null,null)
Connectin

本文探讨了在不同版本的ClickHouse中插入空值时的行为差异,并提供了在特定版本下解决该问题的方法。
最低0.47元/天 解锁文章
4112

被折叠的 条评论
为什么被折叠?



