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 我的数字生活论坛 .



3 Responses to “How to Escape Characters in Oracle PL/SQL Queries”三答复“如何转义字符在甲骨文特等/ SQL查询”

  1. Escape Character in MySql - Discussweb IT Community - Web Development, Software Programming, SEO, Quality Assurance, 3D, Web Hosting and more...转义字符在MySQL -D iscussweb的I T社区-网站开发,软件编程,搜索引擎优化,质量保证,三维,虚拟主机和更多.. .
    July 13th, 2007 19:27 2007年七月13号19:27
    1

    [...] about Escape Characters. [...]对转义字符。 Escape Characters Oracle Wildcards Wildcard Characters Escape Character How to Escape Characters in Oracle PL/SQL Queries甲骨文转义字符通配符通配符转义字符如何转义字符在甲骨文特等/ SQL查询

  2. sam33
    September 17th, 2008 20:44 08年9月17号20:44
    2

    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考绩

  3. Charles Asbornsen查尔斯Asbornsen
    September 26th, 2008 00:28 08年九月26日00:28
    3

    Thank you very much - I’ma SQL Server gent with an Oracle source and I was going nuts!非常感谢你-我的S QLS erver代理与甲骨文来源和我正要坚果! : )

Leave a Reply留下一个回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签: href="" title="">的<a <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> “删除日期时间= “ ” “的<em> <i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅没有评论


Custom Search

New Articles新文章

Incoming Search Terms for the Article收到的搜索字词的文章

oracle escape character 甲骨文转义字符 - - oracle sql escape 甲骨文的SQL逃生 - - pl sql escape character 的PL SQL转义字符 - - Oracle escape characters 甲骨文转义字符 - - oracle sql escape character 甲骨文的SQL转义字符 - - oracle quote escape 甲骨文报价逃生 - - PLSQL escape character PLSQL转义字符 - - escape characters oracle 转义字符甲骨文 - - escape character in sql 转义字符在SQL - - SQL escape & 逃生的SQL & - - sql escape 数据库逃生 - - special character in oracle 特殊性质的甲骨 - - escape character in oracle 转义字符在甲骨文 - - oracle, sql, escape character 大型数据库,转义字符 - - oracle escape & 甲骨文逃避& - - Oracle escape ' 甲骨文逃脱' - - oralce import excape char oralce进口excape焦炭 - - pl/sql find percent character in clause 特等/数据库找到百分之性质的条款 - - SQL escape character 的SQL转义字符 - - escape SQL 逃跑的SQL - - escape character oracle 转义字符甲骨文 - - escape character for oracle pl/sql 转义字符甲骨文特等/数据库 - - oracle escaping 甲骨文逃避 - - oracle sql & escape 甲骨文公司数据库及逃生 - - oracle escape 甲骨文逃生 - - pl/sql escape string 特等/数据库字符串逃避 - - pl sql escape quote 的PL SQL逃避报价 - - plsql escape plsql逃生 - - special character in search string SQL oracle 特殊性质的搜索字符串的SQL数据库 - - sql character escape 数据库字符逃生 - - escape characters in oracle 转义字符在甲骨文 - - find special character in string PL/SQL 查找特殊字符的字符串特等/数据库 - - oracle insert error with special characteres 甲骨文插入错误有特殊字符 - - oracle sql escape & character 甲骨文的SQL逃避与性质 - - PL SQL ESCAPE CHAR 的PL SQL逃脱字符 - - select oracle escape 甲骨文公司选择逃避 - - sql escape characters 的SQL转义字符 - - character oracle 甲骨文公司性质 - - character escaping poland 字符转义波兰 - - display characters ¿ instead of ' in oracle 显示字符¿而不是'在神谕 - - display special characters+oracle database 显示特殊字符+ Oracle数据库 - - escape apostrophes oracle 甲骨文公司逃避撇号 - - escape characters used in Inserts in Oracle 10g 转义字符用刀片在Oracle 10g的 - - escape sql wild character 逃跑的SQL野生性质 - - escape+apostrophe+oracle 越狱+撇+甲骨文 - - escape sql entry 逃跑的SQL入门 - - escape character for quote in sql 转义字符的报价在SQL - - escape '/' character in sql in oracle 逃脱' / '字在甲骨文的SQL - - escape sequences in oracle 转义序列在甲骨文 - - escaping special character + oracle 逃跑特殊字符+甲骨文 - -