Oracle中quote的使用

來源:互聯網
上載者:User

Oracle中quote的使用

在SQL或者PLSQL中如果要表達一個帶有特殊字元的字串時,通常要用''封裝起來。但如果字串本身包含‘或者“這樣的字元,那麼實現起來有點繁瑣。

比如:My Name is "Wang Xiu Li"

用sql實現

SQL> select 'My Name is "Wang Xiu Li"' names from dual;

NAMES
------------------------
My Name is "Wang Xiu Li"

Oracle提供了一個Q-quote的運算式,用來簡化SQL或PLSQL中字串的表示,quote實現

SQL> select q'[My Name is "Wang Xiu Li"]' names from dual;

NAMES
------------------------
My Name is "Wang Xiu Li"

注意文法:必須將要表示的字串用一對特殊字元括起來,這對字元必須一致。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.