一、摘要
PSQL转义字符
![](https://i-blog.csdnimg.cn/blog_migrate/1f85081e847523939293ab05df559e97.png)
PLSQL对应的字符和序号关系
![](https://i-blog.csdnimg.cn/blog_migrate/6e406e33b34ad092fd0ccaa228aca594.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f85081e847523939293ab05df559e97.png)
PLSQL对应的字符和序号关系
1. 转义字符为' ';
select * from bxj_test where testchar like 'sdd _%' escaape ' ';
--sdd_kk
2. 转义字符为'\';
select
*
from
bxj_test
where
testchar
like
'sdd\_%'
escape
'\'
;
--sdd_kk
3. 转义字符为'=';
select
*
from
bxj_test
where
testchar
like
'sdd=_%'
escape
'='
;
--sdd_kk
4. 转义字符为'/';
select
*
from
bxj_test
where
testchar
like
'sdd/_%'
escape
'/'
;
--sdd_kk
5. 查找包含所有'_'的字段。
select
*
from
bxj_test
where
testcharlike '%\_%'
escape
'\'
;
--sdd_kk
6. 查找含有'%'的所有字段:
select
*
from
bxj_test
where
testchar
like
'%\%%'
escape
'\'
;
--dffa%asfs
--1%2345
--1%54321
--2%54321
--%%54321
7. 是'&'不能通过转义字符查找,通过ASCII进行装换
select
*
from
bxj_test
where
testchar
like
'%\&%'
escape
'\'
;
--ORA-01424: 转义符之后字符缺失或非法
select ascii('&') from dual;
--38
select * from bxj_test where testchar like '%'||chr(38)||'%';
--A&B
Thanks and Regards
2015-05-06 Created By BaoXinjian
ERP技术讨论群: 288307890
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建