How to Escape Characters in Oracle PL/SQL Queries如何轉義字符在Oracle PL / SQL的疑問
Oracle databases reserve some special characters with specific meaning and purpose within Oracle environment. Oracle數據庫儲備一些特殊字符與特定的含義和目的內部的Oracle環境。 These reserved characters include _ (underscore) wild card character which used to match exactly one character, % (percentage) which used to match zero or more occurrences of any characters and ‘ (apostrophe or quotation mark) which used to mark the value supplied.這些保留字符,包括_ (下劃線)外卡的特點,其中,用於匹配,正是一個字符, % (百分比) ,其中用於匹配零個或多個發生的任何字符和' (單引號或引號) ,用來標誌提供的值。 These special characters will not be interpreted literally when building SQL query in Oracle, and may caused error in results returned especially when performing string search with LIKE keyword.這些特殊字符將不會字面解釋時,建設SQL查詢在Oracle中,並可能造成的錯誤,在返回的結果,尤其是當表演字符串搜索與關鍵字一樣。 To use these characters so that Oracle can interpret them literally as a part of string value instead of preset mean, escape character has to be assigned.使用這些字符,使甲骨文公司可以解釋他們在字面上的一個組成部分字符串值,而不是預設的意思是,轉義字符已經被指派。
Oracle allows the assignment of special escape characters to the reserved characters in Oracle can be escaped to normal characters that is interpreted literally, by using ESCAPE keyword.甲骨文允許轉讓特別轉義字符,以保留字在甲骨文可以逃脫正常的字符是字面解釋,利用逃生的關鍵字。
For example, to select the name of guests with _ (underscore) in it, use the following statement:舉例來說,選擇的名稱,客人與_ (下劃線)在它,使用以下聲明:
SELECT guest_name FROM guest_table WHERE name LIKE ‘%\_%’ ESCAPE ‘\’;選擇guest_name從guest_table那裡的名稱一樣, ' % \ _ % '逃生' \ ' ;
Without specifying the \ (backslash) as escape clause, the query will return all guest names, making the unwanted results problem.沒有具體說明\ (反斜線)作為免責條款,查詢將返回所有客戶的名稱,使不想要的結果的問題。
The above syntax will not work on ‘ (quote).上述語法將不會工作, ' (引) 。 To escape this quotation mark and to display the quote literally in string, insert another quote (total 2 quotes) for every quote that want to be displayed.要擺脫這種引號,並顯示引述從字面上來看,在字符串,插入另一引號(共計2引號)為每引述說,要顯示的。 For example:例如:
SELECT ‘This will display line with quote’’s word.’ FROM temp_table;選擇' ,這將顯示符合quote'的話。 '從temp_table ;
SELECT ‘This will display ””double quoted”” word.’ FROM temp_table;選擇' ,這將顯示“ , ”雙引述“ ”字。 '從temp_table ;
will return the following respectively:將返回以下分別是:
This will display line with quote’s word.這將顯示器產品線引的話。
This will display ”double quoted” word.這會顯示“雙引述”字。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明 :這是一個機器翻譯網頁是“按原樣”提供的擔保。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原版的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at分享和貢獻,或取得技術的支持和幫助,在 My Digital Life Forums 我的數字生活論壇 . 。
Related Articles相關文章
- Manual and Clean Uninstall Oracle for Windows手冊和乾淨的卸載甲骨文為Windows
- Oracle Database Link Oracle數據庫的連接
- Oracle Database Import Error 3113/3114 Oracle數據庫的進口錯誤三千一百一十四分之三千一百十三
- Oracle PL/SQL ORA-00947 Not Enough Values Error甲骨文PL / SQL的庫存- 00947沒有足夠的價值觀錯誤
- Change Oracle Database User Password改變Oracle數據庫的用戶密碼
- Check Oracle Version檢查的Oracle版本
- Oracle JDeveloper Reviews甲骨文的JDeveloper評語
- Oracle Business Activity Monitoring Reviews Oracle商務活動監控評語
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database進出口- 00016所需的字符集轉換不支持時出現錯誤,導入到Oracle數據庫
- Insert Text Literal and Concatenation in Oracle SQL插入文字的字面和串連在Oracle的SQL



















July 13th, 2007 19:27 2007年7月13日19時27分
[...] about Escape Characters. [ … … ]關於轉義字符。 Escape Characters Oracle Wildcards Wildcard Characters Escape Character How to Escape Characters in Oracle PL/SQL Queries轉義字符甲骨文通配符通配符字符轉義字符如何轉義字符在Oracle PL / SQL的疑問