--instr()函数,检查字段tb_col中是否含有n_int: select tb_col from table_name where instr(tb_col,n_int)>0
SQL> with t as( 2 select 1 id,'james,tom,scott,102,a' name from dual union all 3 select 3,'bbc,cnn,tvb,cctv' from dual union all 4 select 4,'beijing,shanghai,guangzhou,dalian' from dual) 5 select * 6 from t 7 where instr(name,'tvb,cctv')>0 8 or instr(name,'beijing')>0; ID NAME ---------- --------------------------------- 3 bbc,cnn,tvb,cctv 4 beijing,shanghai,guangzhou,dalian
这N个数,每一次只能检查一次。算法类似于: get iCheck; while(iCheck++ < 2^32-1) { if(iCheck exist in the oracle table) break; else do some action }2,3楼的好像效率上太低了吧。得注意数据范围我在想是不是能先把DB的数据读出来放在内存,然后再进行比较。 想用位操作的方法,但是没有什么思路。。
--instr()函数,检查字段tb_col中是否含有n_int:
select tb_col
from table_name
where instr(tb_col,n_int)>0
SQL> with t as(
2 select 1 id,'james,tom,scott,102,a' name from dual union all
3 select 3,'bbc,cnn,tvb,cctv' from dual union all
4 select 4,'beijing,shanghai,guangzhou,dalian' from dual)
5 select *
6 from t
7 where instr(name,'tvb,cctv')>0
8 or instr(name,'beijing')>0; ID NAME
---------- ---------------------------------
3 bbc,cnn,tvb,cctv
4 beijing,shanghai,guangzhou,dalian
get iCheck;
while(iCheck++ < 2^32-1)
{
if(iCheck exist in the oracle table)
break;
else
do some action
}2,3楼的好像效率上太低了吧。得注意数据范围我在想是不是能先把DB的数据读出来放在内存,然后再进行比较。
想用位操作的方法,但是没有什么思路。。
2、写一个游标,把所有数据放在申请的空间里
3、写一公共函数用二分、冒泡、堆等算法实现查找。