oracle方法
CREATE OR REPLACE FUNCTION IpToLong(ip in varchar2) return number is p1 number; p2 number; p3 number; begin p1 := instr(ip, ‘.‘, 1, 1); p2 := instr(ip, ‘.‘, 1, 2); p3 := instr(ip, ‘.‘, 1, 3); return to_number(substr(ip, 1, p1-1))*256*256*256 + to_number(substr(ip, p1+1, p2-p1-1))*256*256 + to_number(substr(ip, p2+1, p3-p2-1))*256 + to_number(substr(ip, p3+1)); end;
sql语句:
select * from test_ip where IpToLong(ip) between IpToLong(start_ip) and IpToLong(end_ip);
oralce 判断ip是否在ip段里,布布扣,bubuko.com
原文地址:http://my.oschina.net/yafeiok/blog/289237