一、对于null 值处理
1、Oracle
分区字段允许为空,只要存在maxvalue 分区,值就可以插入。
SQL> create table t1(id number,data varchar(9)) partition by range(id)
2 (
3 partition p1 values less than (1000),
4 partition p2 values less than (maxvalue)
5 );
Table created.
SQL> insert into t1(data) values('a');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1 partition(p2);
ID DATA
---------- ---------
a
2、KingbaseES
允许分区列值为空,但需要 Default 分区
test=# create table t1(id integer,name text) partition by range(id);
CREATE TABLE
test=# create table t1_p1 partition of t1 for values from (minvalue) to (1000);
CREATE TABLE
test=# create table t1_p2 partition of t1 for values from (1000) to (maxvalue);
CREATE TABLE
test=#
test=# insert into t1(name) values('a');
ERROR: no partition of relation "t1" found for row
DETAIL: Partition key of the failing row contains (id) = (null).
test=# create table t1_default partition of t1 default;
CREATE TABLE
test=# insert into t1(name) values('a');
INSERT 0 1
文章介绍了在Oracle和KingbaseES中对null值处理的不同方式。在Oracle中,允许分区字段为空,只要有maxvalue分区,值即可插入。而KingbaseES虽然也允许分区列为空,但需要有Default分区才能插入null值。文中通过创建表和插入数据的示例展示了这两种数据库的差异。

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



