oracle 函数处理IP地址的一个办法

来源:互联网 发布:阿里云虚拟主机搭建ss 编辑:程序博客网 时间:2024/06/05 16:07

截取IP地址的前三位,作为IP段:

SQL> select   substr(ip,1,regexp_instr(ip,'[.]+',1,3)-1)  from  table_name ;

 

SQL> select   substr(ip,1,regexp_instr(ip,'[.]+',1,3)-1) ,  count(*)   from  table_name

           group by substr(ip,1,regexp_instr(ip,'[.]+',1,3)-1);

 

截取IP地址的某一位,如第三位

SQL> select regexp_substr('210.51.19.79','[^.]+',1,3) from dual;

 

原创粉丝点击