单引號转义符q’的使用
2017-08-06 16:39 tlnshuju 阅读(760) 评论(0) 编辑 收藏 举报当字符串包括单引號时,能够使用转义符q’对单引號进行转义。
q’后面的字符能够是:
!
[ ]
{ }
( )
< >
前提是这些字符不会出如今兴许的SQL中。
样例1:直接使用单引號转义
SQL> select 'it''s an example' as"Example" from dual;
Example
------------------------------
it's an example
样例2:使用q’转义符转义
SQL> select q'[it's an example]' as"Example" from dual;
Example
------------------------------
it's an example
上面两种写法都正确,可是显然后者可阅读性更强。