DB2 : ' ' 在插入时取为 null
DB2 : ' ' taking as null while insert
我正在尝试在 table
中插入值
Test(id number,name varchar(20) not null);
insert into Test values(1,' '); //executing correctly
但对于下面的语句
insert into Test values(1,'');//showing here null value cannot be accepted for not null column.
任何人都可以解释为什么 ' ' 在 DB2 中取为 null。
我猜您的 DB2 数据库使用了启用的 Oracle compatibility mode and has VARCHAR2 支持。一旦为数据库启用 Oracle 模式或 VARCHAR2
模式,空字符串将被视为 NULL 值。我建议检查 varchar2_compat
设置的数据库配置 (get db cfg
)。
我正在尝试在 table
中插入值Test(id number,name varchar(20) not null);
insert into Test values(1,' '); //executing correctly
但对于下面的语句
insert into Test values(1,'');//showing here null value cannot be accepted for not null column.
任何人都可以解释为什么 ' ' 在 DB2 中取为 null。
我猜您的 DB2 数据库使用了启用的 Oracle compatibility mode and has VARCHAR2 支持。一旦为数据库启用 Oracle 模式或 VARCHAR2
模式,空字符串将被视为 NULL 值。我建议检查 varchar2_compat
设置的数据库配置 (get db cfg
)。