功能介绍
在Lightdb数据库兼容Oracle的语法时,发现Oracle支持sql语句中使用中文空格和中文逗号,为了方便用户迁移到Lightdb,在Lightdb23.4版本中支持了转换中文空格和逗号的功能。该功能由GUC参数lightdb_convert_chinese_char
来控制开关,默认开启转换的功能。
使用约束
- 该功能只在Oracle兼容模式下生效;
- 在双引号之间或者单引号之间的数据,不会转换;
使用示例
- 非Oracle模式,lightdb_convert_chinese_char为on, 转换空格和逗号失败
lightdb@postgres=# show lightdb_convert_chinese_char ;
lightdb_convert_chinese_char
------------------------------
on
(1 row)
lightdb@postgres=# show lightdb_dblevel_syntax_compatible_type ;
lightdb_dblevel_syntax_compatible_type
----------------------------------------
off
(1 row)
lightdb@postgres=# select 1 + 2 ;
ERROR: syntax error at or near "+"
LINE 1: select 1 + 2 ;
^
lightdb@postgres=# create table t1(id int, cont varchar);
CREATE TABLE
lightdb@postgres=#
lightdb@postgres=# insert into t1 values(1, 'xiaohong'),(2,'ming');
ERROR: syntax error at or near "1"
LINE 1: insert into t1 values(1, 'xiaohong'),(2,'ming');
^
lightdb@postgres=#
- Oracle模式, 转换空格和逗号成功
lightdb@oracle_test=# show lightdb_convert_chinese_char ;
lightdb_convert_chinese_char
------------------------------
on
(1 row)
lightdb@oracle_test=# show lightdb_dblevel_syntax_compatible_type ;
lightdb_dblevel_syntax_compatible_type
----------------------------------------
Oracle
(1 row)
lightdb@oracle_test=#
lightdb@oracle_test=# select 1 + 2 ;
?column?
----------
3
(1 row)
lightdb@oracle_test=# create table t1(id int, cont varchar);
CREATE TABLE
lightdb@oracle_test=# insert into t1 values(1, 'xiaohong'),(2,'ming');
INSERT 0 2
lightdb@oracle_test=#