ORACLE之q操作符

qqmengxue發表於2011-05-12

ENV:

ORACLE RELEASE

OBJECT:Q operator

[@more@]

oracle本身預設的是單引號,但是在大家寫儲存過程或者寫SQL語句時,有時候需要拼SQL或者是SQL的值裡需要傳入含單引號的值,此時就需要使用兩個單引號"''"來進行轉義,其實oracle本身提供了這種轉換預設單引號為其他標識的方法那就是——"q"

q [Oracle's quote operator]

q'c text-to-be-quoted c'
c is a single character (called the quote delimiter). 
With the «quote operator» apostrophes don't have to
 be doubled: 
SQL> select q'#Oracle's quote operator#' from dual;
Q'#ORACLE'SQUOTEOPERATO
-----------------------
Oracle's quote operator
begin
execute immediate q'#select * from abc#';
end;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10130206/viewspace-1049749/,如需轉載,請註明出處,否則將追究法律責任。

相關文章