Use of Oracle escape Functions

Source: Internet
Author: User

SQL> select * from t_char;
--------------------
A_ B
Acb
A % B
A' B
A/B
A \ B
%
_
ASQL> select * from t_char where a like 'A _ B ';
--------------------
A_ B
Acb
A % B
A' B
A/B
A \ bSQL> select * from t_char where a like 'a \ _ B 'escape' \ ';
--------------------
A_ B -- visible to query strings with wildcard characters, you must use the escape Function SQL> select * from t_char where a like 'a \ 'B' escape '\';
ERROR:
ORA-01756: quoted string not properly terminated
SQL> select * from t_char where a like 'A' B 'escape' \ ';
--------------------
A' B -- but the character 'still needs two ''to replace the single quotation mark SQL> select * from t_char where a like 'ax _ B' escape 'X';
--------------------
A_ B SQL> select * from t_char where a like 'A' _ B 'escape ''';
--------------------
A_ B SQL> select * from t_char where a like 'A _ % B 'escape' _ ';
--------------------
A % B -- other characters or even "'", "_", and "%" can be used as escape characters, but \ is generally used \, to avoid logical errors SQL> select * from t_char where a like 'a \/B 'escape '\';
Select * from t_char where a like 'a \/B 'escape '\'
*
ERROR at line 1:
ORA-01424: missing or illegal character following the escape character
SQL> select * from t_char where a like 'A _/B 'escape '_';
Select * from t_char where a like 'A _/B 'escape '_'
*
ERROR at line 1:
ORA-01424: missing or illegal character following the escape character SQL> select * from t_char where a like 'a // B 'escape'/';
--------------------
A/bSQL> select * from t_char where a like 'A/\ B 'escape '/';
Select * from t_char where a like 'A/\ B 'escape '/'
*
ERROR at line 1:
ORA-01424: missing or illegal character following the escape characterSQL> select * from t_char where a like 'a \ B 'escape' \ ';
--------------------
A \ B
-- To search for "/" or "\", you must use the same symbol as the Escape Character. Otherwise, the usage is basically invalid. Pay attention to this, the escape function is irrelevant to the escape environment parameters in sqlplus.
SQL> show escape
Escape OFF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.