【Oracle】oracle10g以后利用q-quote特性简化包含单引号后双引号的字符串写法

The Q-quote delimiter can be any single- or multibyte character except space, tab, and return. If the opening quote delimiter is a [, {, <, or ( character, then the closing quote delimiter must be the corresponding ], }, >, or )character. In all other cases, the opening and closing delimiter must be the identical character.

oracle10g以后开始引入的一个新特性:q-quote

使用Q或q开头(如果是national character literals,则是将N或n放在Q或q之前),字符串的前后使用界定符“ ' ” 单引号括起来。

注:q-quote的界定符可以是除了TAB、空格、回车以外的任何单字节或双字节字符;一般情况下,可以统一使用{} 或[]或 <>或 () 作为界定符。

使用方法如下:

select q'[select 'hello' as str from dual]' as q_str from dual;

查询结果如下:

 

或者带双引号的,如下:

select q'[select 'I say "hello"' as str from dual]' as q_str from dual;

 

这样就比每次需要写单引号的时候,用多个单引号括起来要更方便一些。

--------------------------------------------------------------------------

转载于:https://www.cnblogs.com/uzipi/p/4203566.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值