首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Oracle中轮换like的方法

2012-10-14 
Oracle中替换like的方法数据库中存储了海量的数据,当查询时使用like,速度明显变慢。我在做项目时,发现可以

Oracle中替换like的方法
数据库中存储了海量的数据,当查询时使用like,速度明显变慢。我在做项目时,发现可以使用instr函数来取代like的作用。

1.%a%方式:

select * from pub_yh_bm twhere instr(t.chr_bmdm,'2')>0

等份于:
select * from pub_yh_bm twhere t.chr_bmdm like '%2%'


2.%a方式:
select * from pub_yh_bm twhere instr(t.chr_bmdm,'110101')=length(t.chr_bmdm)-length('110101')+1

等份于:
select * from pub_yh_bm twhere t.chr_bmdm like '%110101'


3.a%方式:
select * from pub_yh_bm twhere instr(t.chr_bmdm,'11010101')=1

等份于:
select * from pub_yh_bm twhere t.chr_bmdm like '11010101%'

热点排行