加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle-ESCAPE转义字符

发布时间:2020-12-12 14:04:44 所属栏目:百科 来源:网络整理
导读:为了更好的理解ESCAPE转义字符,我们首先建立一个view作为数据源 create or replace view v as select 'ABCEDF' as vname from dual union all select '_bcefg' from dual union all select '_bcedf' from dual union all select '_bcedf' from dual union

为了更好的理解ESCAPE转义字符,我们首先建立一个view作为数据源

create or replace view v as
select 'ABCEDF' as vname from dual union all
select '_bcefg' from dual union all
select '_bcedf' from dual union all
select '_bcedf' from dual union all
select '_%bcedg' from dual union all

select 'xycef' from dual;


查询看下结果:

select * from v;


要求:查出vname中包含_ced的记录

select * from v where vname like '_bce%'


结果多了一个abcef记录。因为like子句中有两个通配符“%”“_”

这里“_”被当做的通配符,我们需要给它转义成字符串“_”。

下面操作:

select * from v where vname like '_bce%' escape '';


总结:escape '' 起到转义的作用。 后面的_不再是通配符的作用了而是字符串的意思。


如果没有oracle环境执行sql,可以试试下面的地址:

oracle的scott学习环境

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读