单引號转义符q’的使用

当字符串包括单引號时,能够使用转义符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

上面两种写法都正确,可是显然后者可阅读性更强。


原文地址:https://www.cnblogs.com/tlnshuju/p/7295213.html