2. 兼容Oracle参数 ¶
2.1. default_with_oids ¶
参数描述
使用OID创建新表的方式。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
隐含列
为实现兼容效果应设置值
需要创建表时自动创建名为oid的列时,将该参数设置为on
兼容效果示例
set default_with_oids = on; SET create table kingbase_tab1(a int); CREATE TABLE select oid,* from kingbase_tab1; oid | a -----+--- (0 rows)
2.2. default_with_rowid ¶
参数描述
默认值:
off
自测试兼容性需要设置的值
on
引入特性
rowid伪列
为实现兼容效果应设置值
需要创建表时自动创建名为rowid的列时,将该参数设置为on
兼容效果示例
set default_with_rowid = on; SET create table kingbase_tab2(a int); CREATE TABLE select rowid,* from kingbase_tab2; rowid | a -------+--- (0 rows)
2.3. enable_ci ¶
参数描述
是否启用不区分大小写,此参数只能通过initdb初始化实例时修改。
默认值:
off
自测试兼容性需要设置的值
off
引入特性
大小写敏感
为实现兼容效果应设置值
默认比较时大小写敏感;开启后大小写比较时不敏感
兼容效果示例
show enable_ci; enable_ci ----------- on (1 row) select 'A'='a'; ?column? ---------- t (1 row)
2.4. enable_func_colname ¶
参数描述
启用该参数后,查询结果的列名将是函数名和参数名。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
函数返回参数列表
为实现兼容效果应设置值
默认不返回函数参数列表;开启后返回函数参数列表;
兼容效果示例
set enable_func_colname=on; SET select sum(1+2); sum(1+2) ---------- 3 (1 row)
2.5. enable_globalindexscan ¶
参数描述
启用计划器使用全局索引扫描计划。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
全局索引
为实现兼容效果应设置值
开启后分区表索引扫描才会选择全局索引
2.6. enable_upper_colname ¶
参数描述
启用后,查询结果的列名称将转换为大写。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
查询结果集列名以大写形式显示。
为实现兼容效果应设置值
结果集列名大写形式显示需要开启改参数。
兼容效果示例
set enable_upper_colname=on; SET select sum(1+2); SUM ----- 3 (1 row)
2.7. exclude_reserved_words ¶
参数描述
允许为语法分析器排除某些关键字。
默认值:
无
自测试兼容性需要设置的值
详见:ref: ORACLE与KES关键字对比表
引入特性
MR2020082201371,忽略数据库关键字如level,name等
为实现兼容效果应设置值
将需要忽略的关键字设置为参数取值。
兼容效果示例
set exclude_reserved_words='select'; SET select 'abc' as level; ERROR: syntax error at or near "select" LINE 1: select 'abc' as level;
兼容性说明
此参数在oracle、mysql模式通用
2.8. ignore_char_null_check ¶
参数描述
参数作用:控制copy时,是否处理0字符。
参数影响范围: text、varchar,varcharbyte,clob、blob、bytea
遗留问题:由于bpchar和bpcharbyte类型自动补零机制,会导致字符串遇到0字符时,在当前处理中无法正确开辟空间、正常补零,所以ignore_char_null_check影响范围不包括bpchar和bpcharbyte类型。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
BUG31486:使用迁移工具迁移DM数据库中BINARY以及VARBINARY类型数据时,报错:无效的 "UTF8" 。
编码字节顺序: 0x00
兼容效果示例
set ignore_char_null_check = on; create table test ( id int, word varchar(100) ); copy test from '/home/test/515sql.sql';
2.9. ignore_zero_number ¶
参数描述
为number类型时忽略末尾的零。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
BUG2021051400438:是否忽略number类型末尾的零。
为实现兼容效果应设置值
忽略numeric类型末尾的0值时需要将参数设置为on。
兼容效果示例
create table tt1 (c number(24,8)); insert into tt1 values ('1'); insert into tt1 values ('1.000'); select * from tt1; set ignore_zero_number =true; SET show ignore_zero_number; IGNORE_ZERO_NUMBER -------------------- on (1 row) select * from tt1; C --- 1 1 (2 rows) set ignore_zero_number =off; SET show ignore_zero_number; IGNORE_ZERO_NUMBER -------------------- off (1 row) select * from tt1; C ------------ 1.00000000 1.00000000 (2 rows)
2.10. job_queue_processes ¶
参数描述
设置作业线程的最大数。
默认值:
0
自测试兼容性需要设置的值
5
引入特性
定时任务
为实现兼容效果应设置值
需要开启自动作业任务时,将参数设置为大于0的数,表示允许用户启动的最大并发数。参数设置为0 时,表示不启动自动作业任务,默认值为0。
兼容效果示例
kingbase.conf文件中添加kdb_schedule依赖库,并添加参数job_queue_processes=10后重启服务 show job_queue_processes; job_queue_processes --------------------- 10 (1 行记录) create extension kdb_schedule; CREATE EXTENSION create table ts2 (id int,name varchar(50)); CREATE TABLE call dbms_scheduler.create_program('myprogram_test2','PLSQL_BLOCK','insert into ts2 values(1,''test SQL_SCRIPT'')','user=system dbname=test port=10590','test',0,true); CALL call dbms_scheduler.create_schedule('myschedule_test',now()::timestamp,'FREQ=minutely;INTERVAL=1'); CALL call dbms_scheduler.create_job('job0_1','myprogram_test2','myschedule_test'); CALL call dbms_scheduler.enable ('job0_1'); CALL select * from ts2; id | name ----+----------------- 1 | test SQL_SCRIPT (1 行记录)
2.11. kdb_flashback.db_recyclebin ¶
参数描述
启用/禁用 回收站和闪回的功能。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
闪回
为实现兼容效果应设置值
需要开启闪回回收站时,将参数设置为on。
2.12. kdb_flashback.enable_fbquery_debug ¶
参数描述
启用/禁用将元组调试信息输出到关于闪回查询的syslog。
默认值:
off
自测试兼容性需要设置的值
off
引入特性
闪回
为实现兼容效果应设置值
需要开启闪回过程中元组级别的日志输出,将参数设置为on。
2.13. kdb_flashback.enable_flashback_query ¶
参数描述
启用/禁用闪回查询。
默认值:
on
自测试兼容性需要设置的值
on
引入特性
闪回
为实现兼容效果应设置值
需要开启闪回查询时,将参数设置为on
2.14. nls_date_format ¶
参数描述
模拟Oracle的日期输入行为。
默认值:
YYYY-MM-DD HH24:mi:ss
自测试兼容性需要设置的值
默认值
引入特性
兼容oracle的时间类型
为实现兼容效果应设置值
需要开启前置开关ora_style_nls_date_format
兼容效果示例
set ora_style_nls_date_format = on; SET show ora_style_nls_date_format ; ora_style_nls_date_format --------------------------- on (1 row) set nls_date_format = 'YYYY'; SET show nls_date_format ; nls_date_format ----------------- YYYY (1 row) create table date_1(c1 date); CREATE TABLE insert into date_1 values('1995-09-23'); INSERT 0 1 insert into date_1 values('01-08-4712BC'); INSERT 0 1 select * from date_1 ; c1 ------ 1995 0001 (2 rows) set nls_date_format = 'YYYY-MM-DD HH24:mi:ss'; SET show nls_date_format ; nls_date_format ----------------------- YYYY-MM-DD HH24:mi:ss (1 row) select * from date_1 ; c1 --------------------- 1995-01-01 00:00:00 0001-01-01 00:00:00 (2 rows)
2.15. nls_length_semantics ¶
参数描述
指定默认限定符并定义长度语义。
默认值:
char
自测试兼容性需要设置的值
byte
引入特性
兼容oracle字符类型的存储单位
为实现兼容效果应设置值
可选值: char按字符存储; byte按字节存储。
兼容效果示例
create table tab(c1 varchar(1 char),c2 varchar(1 byte));
2.16. nls_timestamp_format ¶
参数描述
模拟Oracle timestamp的输入行为。
默认值:
YYYY-MM-DD HH24:mi:ss.FF
自测试兼容性需要设置的值
默认值
引入特性
兼容oracle的时间类型
为实现兼容效果应设置值
需要开启前置开关ora_style_nls_date_format
兼容效果示例
set ora_style_nls_date_format = on; SET show nls_timestamp_format ; nls_timestamp_format -------------------------- YYYY-MM-DD HH24:mi:ss.FF (1 row) test=# create table kes(a timestamp); CREATE TABLE insert into kes values('2021-09-26 10:14:42'); INSERT 0 1 insert into kes values('2021-09-26'); INSERT 0 1 select * from kes; a ---------------------------- 2021-09-26 10:14:42.000000 2021-09-26 00:00:00.000000 (2 rows) set nls_timestamp_format = 'dd.mm.yyyy hh24:mi:ss.ff'; SET select * from kes; a ----------------------------- 26.09.2021 10:14:42.000000 26.09.2021 00:00:00.000000 (2 rows)
2.17. nls_timestamp_tz_format ¶
参数描述
模拟Oracle timestamp tz的输入行为。
默认值:
YYYY-MM-DD HH24:mi:ss.FF TZH:TZM
自测试兼容性需要设置的值
默认值
引入特性
兼容oracle的时间类型
为实现兼容效果应设置值
需要开启前置开关ora_style_nls_date_format
兼容效果示例
set ora_style_nls_date_format = on; show nls_timestamp_tz_format ; nls_timestamp_tz_format ---------------------------------- YYYY-MM-DD HH24:mi:ss.FF TZH:TZM (1 row) create table kes(a timestamptz); CREATE TABLE insert into kes values('2021-09-26 10:14:42'); INSERT 0 1 select * from kes ; a ----------------------------------- 2021-09-26 10:14:42.000000 +08:00 (1 rows) set nls_timestamp_tz_format = 'dd.mm.yyyy hh24:mi:ss.ff'; show nls_timestamp_tz_format ; nls_timestamp_tz_format --------------------------- dd.mm.yyyy hh24:mi:ss.ff (1 row) select * from kes ; a ----------------------------- 26.09.2021 10:14:42.000000 (1 rows)
2.18. ora_forbid_func_polymorphism ¶
参数描述
兼容Oracle禁止函数多态性。
true(on):表示开启禁用多态,同模式下不能创建同名的函数或存储过程。
false(off):表示启用多态,KingbaseES默认值。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
禁用函数多态
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
# 开启后,重载报错: set ora_forbid_func_polymorphism TO on; \set SQLTERM / CREATE OR REPLACE PROCEDURE p1(a int default 10) as BEGIN raise notice '%',a; END; / \set SQLTERM / CREATE PROCEDURE p1 as BEGIN raise notice '%',a; END; / ERROR: function or procedure "p1" already exists
2.19. ora_input_emptystr_isnull ¶
参数描述
将空串转为NULL。
默认值:
on
自测试兼容性需要设置的值
默认值
引入特性
空字符串是否作为NULL处理
为实现兼容效果应设置值
需要将空串作为NULL处理时,开启该参数
2.20. ora_numop_style ¶
参数描述
兼容Oracle的integer和strings操作符,作为numeric and string操作符。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
是否将integer操作符当做numeric操作符。
为实现兼容效果应设置值
需要将integer操作符当成numeric操作符时,将该参数设置为on。用户自测oracle兼容,建议设置为on。
兼容效果示例
set ora_numop_style = on; SET create table ss2 as select 34::int + '3'::varchar; SELECT 1 \d+ ss2 Table "public.ss2" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ----------+---------+-----------+----------+---------+---------+--------------+------------- ?column? | numeric | | | | main | | Access method: heap drop table ss2; DROP TABLE set ora_numop_style = off; SET create table ss2 as select 34::int + '3'::varchar; SELECT 1 \d+ ss2 Table "public.ss2" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ----------+---------+-----------+----------+---------+---------+--------------+------------- ?column? | integer | | | | plain | | Access method: heap drop table ss2; DROP TABLE
2.21. ora_style_nls_date_format ¶
参数描述
模拟oracle的nls_date_format,nls_timestamp_format,nls_timestamp_tz_format 行为。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
数据类型-日期时间类型
为实现兼容效果应设置值
兼容oracle的日期时间类型总控制开关,开启后日期时间类型表现才能兼容oracle效果若用户自测oracle兼容,建议设置为on
2.22. skip_tablespace_check ¶
参数描述
跳过表空间只读或脱机模式检查。
默认值:
TRUE
自测试兼容性需要设置的值
默认值
引入特性
表空间模式
为实现兼容效果应设置值
若需要跳过对只读表空间或离线表空间的检查,开启该参数
2.23. spacequota.enable ¶
参数描述
启用空间配额。true:enable, false: disable。
默认值:
off
自测试兼容性需要设置的值
默认值
引入特性
表空间限额
为实现兼容效果应设置值
需要设置表空间存储空间时,开启该参数;并调用函数set_space_quota设置额度
兼容效果示例
create extension sys_spacequota; alter system set spacequota.enable = on ; call sys_reload_conf();-- 开启功能 create tablespace tab_quo_aut1 location '/tmp/tab_quo_aut1'; select oid from sys_tablespace where spcname = 'tab_quo_aut1' \gset call set_space_quota(:'oid',1);
2.24. spacequota.fullwarningtype ¶
参数描述
空间配额已满警告类型: 0:WARNING, 1: ERROR。
默认值:
0
自测试兼容性需要设置的值
默认值
引入特性
表空间限额检查模式
为实现兼容效果应设置值
取值0时,表空间超限额后发出警告,但还能继续操作;取值1时,表空间超限额后,无法继续操作;需要开启前置控制参数spacequota.enable。
2.25. check_function_bodies ¶
参数描述
CREATE FUNCTION期间检查函数体。
默认值:
on
自测试兼容性需要设置的值
默认值
引入特性
原生
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后create function时对函数体字符串进行验证,表不存在时,报错:ERROR: relation "emp" does not exist \set SQLTERM ; CREATE FUNCTION clean_emp() RETURNS void AS ' DELETE FROM emp WHERE salary < 0; ' LANGUAGE SQL;
2.26. ora_open_cursors ¶
参数描述
设置会话中可以同时打开的DBMS SQL的最大游标数。
默认值:
300
自测试兼容性需要设置的值
引入特性
允许在同一个连接中打开的最大游标数。
为实现兼容效果应设置值
范围0-65535
兼容效果示例
打开游标个数为设置后的值,超过个数时报错:ERROR: maximum open cursors exceeded
2.27. ora_statement_level_rollback ¶
参数描述
如果事务块中的语句生成错误,则忽略该错误并继续事务处理。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
开启单语句回滚
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,表t1插入一条数据 \set SQLTERM / CREATE OR REPLACE PROCEDURE p1 AS v1 int; BEGIN INSERT INTO t1 VALUES(1,'kingbase'); v1 :=5/0; EXCEPTION WHEN ZERO_DIVIDE THEN DBMS_OUTPUT.PUT_LINE('here is exception'); END; / CALL p1(); SELECT * FROM t1; / id | name ----+---------- 1 | kingbase (1 row)
2.28. plsql.check_asserts ¶
参数描述
执行ASSERT报表中给出的检查。
默认值:
on
自测试兼容性需要设置的值
默认值
引入特性
是否启用PLSQL的ASSERT语句
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,启用断言测试,报错:ERROR: assertion failed \set SQLTERM / BEGIN assert(1=2); END; /
2.29. plsql.compile_checks ¶
参数描述
在PLSQL对象编译中执行检查。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
是否启用编译检查
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,表不存在时提示waining \set SQLTERM / CREATE OR REPLACE PROCEDURE p1 AS v1 int; BEGIN INSERT INTO t2 VALUES(1,'kingbase'); END; /
2.30. plsql.variable_conflict ¶
参数描述
设置PL/SQL变量名和列表名之间冲突的处理。
默认值:
error
自测试兼容性需要设置的值
默认值
引入特性
原生
为实现兼容效果应设置值
值域error、use_variable或者use_column 兼容设置为默认值error
兼容效果示例
设置为use_variable以下存储过程调用成功,设置为error以下存储过程调用报错。 \set SQLTERM ; CREATE TABLE t2(id int); insert into t2 values(88); set plpgsql.variable_conflict = error; \set SQLTERM ; CREATE OR REPLACE PROCEDURE p1(id int) as $$ BEGIN INSERT INTO t2(id) SELECT id FROM t1; END; $$ language plpgsql; call p1(10);
2.31. plsql_plprofiler.max_callgraphs ¶
参数描述
设置内存中存储堆栈关系的行数。
默认值:
20000
自测试兼容性需要设置的值
默认值
引入特性
PLPROFILER(pg开源)
为实现兼容效果应设置值
范围[1,123456789]
2.32. plsql_plprofiler.max_functions ¶
参数描述
设置内存中可存储的对象个数。
默认值:
2000
自测试兼容性需要设置的值
默认值
引入特性
PLPROFILER(pg开源)
为实现兼容效果应设置值
范围[1,123456789]
2.33. plsql_plprofiler.max_lines ¶
参数描述
设置内存中分析数据记录行数。
默认值:
200000
自测试兼容性需要设置的值
默认值
引入特性
PLPROFILER(pg开源)
为实现兼容效果应设置值
范围[1,123456789]
2.34. ora_func_style ¶
参数描述
默认值:
off
自测试兼容性需要设置的值
on
引入特性
PLSQL支持对象状态
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,tf不存在,pr1创建成功且状态为invalid \set SQLTERM / CREATE OR REPLACE PROCEDURE pr1 AS BEGIN INSERT INTO tf VALUES(1,'AA'); END; / \set SQLTERM ; SELECT object_name,object_type,status from USER_OBJECTS where object_name = 'PR1' ORDER BY object_name;
2.35. comp_v7_program_para_def ¶
参数描述
在 KingbaseES V9 版本中,默认情况下,函数的 OUT/INOUT 模式的参数不能指定默认值(否则创建时会报错),但是可以通过参数 comp_v7_program_para_def 控制兼容 KingbaseES V7 版本函数 OUT/INOUT 模式的参数支持默认值。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
兼容V7特性
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,out,inout参数可带默认值 \set SQLTERM / CREATE OR REPLACE PROCEDURE p1(a inout int default 10) as BEGIN raise notice '%',a; END; / BEGIN p1(); END; /
兼容性说明
兼容V7
2.36. comp_v7_select_into_strict_attr ¶
参数描述
可以通过开启参数 comp_v7_select_into_strict_attr 兼容 KingbaseES V7 版本的strict属性,即指定该属性时则当语句没有返回任何行时就报错,否则不报错,而是把 NULL 值 into 到目标变量中。
默认值:
off
自测试兼容性需要设置的值
on
引入特性
兼容V7特性
为实现兼容效果应设置值
开启参数为ON
兼容效果示例
开启后,返回0行执行成功 \set SQLTERM / DECLARE v1 int; BEGIN SELECT id INTO v1 FROM t1; END; / 开启后,返回0行执行报错 \set SQLTERM / DECLARE v1 int; BEGIN SELECT id INTO STRICT v1 FROM t1; END; /
兼容性说明
兼容V7
2.37. ora_integer_div_returnfloat ¶
参数描述
当开启参数时整数除法计算返回值保留小数位。当参数ora_integer_div_returnfloat关闭,除法计算返回值保留整数(向下取整)。
默认值:
on,参数默认开启。
自测试兼容性需要设置的值
off
引入特性
兼容ORACLE的整数除法在未除尽情况下返回小数
为实现兼容效果应设置值
开启参数为OFF
兼容效果示例
TEST=# set ora_integer_div_returnfloat=off; SET TEST=# select 8/5; ?column? ---------- 1 (1 row) TEST=# set ora_integer_div_returnfloat=on; SET TEST=# select 8/5; ?column? ---------- 1.6 (1 row)
兼容性说明
oracle