How to Escape Characters in Oracle PL/SQL Queries如何转义字符在甲骨文特等/ 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查询建立在甲骨文,并可能造成错误的结果返回尤其是当表演字符串搜索类的关键字。 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 JDeveloper Reviews甲骨文JDeveloper评语
- Oracle PL/SQL ORA-00947 Not Enough Values Error甲骨文特等/数据库口腔00947不够值误差
- Change Oracle Database User Password更改Oracle数据库用户密码
- Check Oracle Version检查甲骨文版
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database进出口- 00016要求字符集转换不支持的错误当进口Oracle数据库
- Oracle Business Activity Monitoring Reviews Oracle商务活动监控评语
- Insert Text Literal and Concatenation in Oracle SQL插入文本文字和级联在甲骨文的SQL

































July 13th, 2007 19:27 2007年七月13号19:27
[...] about Escape Characters. [...]对转义字符。 Escape Characters Oracle Wildcards Wildcard Characters Escape Character How to Escape Characters in Oracle PL/SQL Queries甲骨文转义字符通配符通配符转义字符如何转义字符在甲骨文特等/ SQL查询
September 17th, 2008 20:44 08年9月17号20:44
salut j’ai le mm pb !救国j'ai乐毫米铅! si je fait une recherche sur le ‘_’ seul sa marche mais si v je chercher des mots avec le ‘_’市济既成事实新英格兰大学研究河畔乐' _ '涩山马尔凯看市v济chercher万mots带乐' _ '
exmple: exmple :
SELECT * from Test WHERE nom LIKE ‘1%\_%test’ ESCAPE ‘\’;选择*从测试的WHERE化名样'1 % \ _ %测试'逃逸' \ ' ;
sa me renvoie :山箱renvoie :
1_test
10_test ?? 10_test ? ?
or que normalement sa devait rendre que:或者你normalement山devait rendre你:
1_test ?? 1_test ? ?
je comprend pas济comprend考绩
September 26th, 2008 00:28 08年九月26日00:28
Thank you very much - I’ma SQL Server gent with an Oracle source and I was going nuts!非常感谢你-我的S QLS erver代理与甲骨文来源和我正要坚果!