
一、参数功能概述ora_input_emptystr_isnull 是 KingbaseES (KES) 数据库中的一个兼容性参数专门用于处理空字符串()与 NULL 值的转换问题。该参数主要用于提高与 Oracle 数据库的兼容性。数据库是oracle 模式时参数ora_input_emptystr_isnullon是为了兼容oracle 对于‘’作为null处理。作用控制是否将空字符串()自动转换为 NULL 值二、参数取值及含义参数值含义on开启功能空字符串()作为NULL处理默认值off关闭功能空字符串()与NULL区分处理三、参数查看方法1. 查看当前参数设置test# SHOW ora_input_emptystr_isnull;ora_input_emptystr_isnull---------------------------off(1 行记录)2. 通过系统视图查看test# SELECT name, setting, unit, short_desctest-# FROM sys_settingstest-# WHERE name ora_input_emptystr_isnull;name | setting | unit | short_desc-------------------------------------------------------------------------ora_input_emptystr_isnull | off | | Convert empty string to null.(1 行记录)四、参数设置方法1. 会话级设置仅当前会话有效test# SET ora_input_emptystr_isnull on;SETtest# SHOW ora_input_emptystr_isnull;ora_input_emptystr_isnull---------------------------on(1 行记录)2. 用户级设置对指定用户永久生效test# ALTER USER system SET ora_input_emptystr_isnull on;ALTER ROLE3. 数据库级设置对整个数据库生效test# ALTER DATABASE test SET ora_input_emptystr_isnull on;ALTER DATABASE4. 全局设置修改配置文件修改 kingbase.conf 文件的最后位置添加ora_input_emptystr_isnull on修改后需重启KES服务或reload重载文件生效(选择其中一个即可)。五、参数使用示例 (判断值是否为空要用 is null)**1. 当参数设为off时 **test# SET ora_input_emptystr_isnull off;SETtest# CREATE TABLE test_null (id int, name varchar(20));CREATE TABLEtest# INSERT INTO test_null VALUES (1, ); -- 插入空字符串INSERT 0 1test# INSERT INTO test_null VALUES (2, NULL); -- 插入NULLINSERT 0 1SELECT id, name, name IS NULL FROM test_null;id | name | ?column?--------------------1 | | f -- 空字符串不为NULL2 | | t -- 真实的NULL(2 行记录)2. 当参数设为on时默认情况test# SET ora_input_emptystr_isnull on;SETtest# TRUNCATE TABLE test_null;TRUNCATE TABLEtest# INSERT INTO test_null VALUES (1, ); -- 插入空字符串INSERT 0 1test# INSERT INTO test_null VALUES (2, NULL); -- 插入NULLINSERT 0 1test# SELECT id, name, name IS NULL FROM test_null;id | name | ?column?--------------------1 | | t -- 空字符串转为NULL2 | | t -- 真实的NULL(2 行记录)此测试数据库版本号为V009R001C010