Home  >  Article  >  Database  >  How to use escape in oracle

How to use escape in oracle

WBOY
WBOYOriginal
2022-05-30 18:27:295012browse

In Oracle, the escape keyword is used to escape some special characters to the meaning of the original characters. The syntax is "select * from table name where column name like '% character_%' escape '/' "; If "/" is used as the search character, "/" must also be used as the escape character.

How to use escape in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to use escape in oracle

Definition: The escape keyword is often used to escape certain special characters, such as wildcard characters: '%', '_' to their original character meanings , the defined escape character is usually '\', but other symbols can also be used.

Example:

How to use escape in oracle

Note: If '/' is used as the search character, '/' must be used as the escape character, and the same is true for forward and slash characters.

select * from wan_test where psid like ‘%//%’ escape ‘/‘

1. Use the ESCAPE keyword to define the escape character. When an escape character precedes a wildcard character in a pattern, the wildcard character is interpreted as an ordinary character.

2.ESCAPE ‘escape_character’ allows searching for wildcard characters in a string instead of using them as wildcard characters. escape_character is the character placed before the wildcard to represent this special purpose.

select * from a WHERE name LIKE ‘%/%ab’ ESCAPE ‘/‘

The result is:

name
-————-
11%ab
12%ab
www.123.com
==================================================================================
SQL> select * from test;
TEST
-—————————-
sdd_kk
d’d
dfsfsa
dffa%asfs
12345
1%2345
1%54321
2%54321
%%54321
A&B

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to use escape in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn