【lightdb】oracle||与-兼容

本文介绍了Oracle中||操作符用于字符串连接的功能,以及在LightDB24.1版本前后,它与数值和日期的混合使用,以及与减号-之间的特殊处理。24.1版本后,||-将不再作为合法运算符名。

||功能

在Oracle中,"||"是用于字符串连接的操作符。它可以将两个字符串连接成一个新的字符串。借助隐式转换规则,||参数两边的值也可以是数值和日期。以下是一些例子

select 'dummy=' || dummy from dual; 
select 'current_date: '||current_date from dual;
select 1|| -1 from dual;
select 1||-1 from dual; 

LightDB ||

24.1之前,||运算符已支持。但是||和-同时出现时,中间必须加空格,因为不加空格时,||-被识别成一个特定运算符||-。LightDB并不存在||-运算符,所以报运算符不存在。示例如下:

lightdb@oracle=# select 1|| -1 from dual;
 ?column? 
----------
 1-1
(1 row)

lightdb@oracle=# select 1||-1 from dual;
ERROR:  operator does not exist: integer ||- integer
LINE 1: select 1||-1 from dual;
                ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

24.1版本中,||-在oracle模式下将不能作为合法的运算符名,||-也会将被解析为||和-。

lightdb@oracle=# select 1 || -1 from dual;
 ?column? 
----------
 1-1
(1 row)

lightdb@oracle=# select 1||-'1'from dual;
 ?column? 
----------
 1-1
(1 row)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值