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

被折叠的 条评论
为什么被折叠?



