oracle查询语句中对特殊字符%与_的处理

我顶 字号:

转自:http://cjs0550.blog.hexun.com/34769901_d.html

ESCAPE Clause Example

You can include the actual characters "%" or "_" in the pattern by using the ESCAPE clause, which identifies the escape character. If the escape character appears in the pattern before the character "%" or "_" then Oracle interprets this character literally in the pattern, rather than as a special pattern matching character.

To search for employees with the pattern 'A_B' in their name:



   
   
SELECT  last_name      FROM  employees      WHERE  last_name  LIKE   ' %A\_B% '   ESCAPE   ' \ ' ;

The ESCAPE clause identifies the backslash (\) as the escape character. In the pattern, the escape character precedes the underscore (_). This causes Oracle to interpret the underscore literally, rather than as a special pattern matching character.

对于&符号,在PL/SQL里面是定义变量,如果想&符号不是定义变量的作用,可以使用两个&符号!

你可能感兴趣的:(html,oracle,sql,Blog)