
用了一个比较笨的方法 暂时没想到很好的方法
select LOCATION from T_Base_IPAddressInfo
where substr('21806182',1,instr('21806182','')-1)
between substr(startip,1,instr(startip,'')-1) and substr(endip,1, instr('20298068','',1,1)-1)
and substr('21806182',instr('20298068','',1,1),instr('21806182','',1,2)-1)
between substr(startip,instr('20298068','',1,1),instr(startip,'',1,1)-1) and substr(endip,instr('20298068','',1,1), instr('20298068','',1,2)-1)
and substr('21806182',instr('20298068','',1,2),instr('21806182','',1,3)-1)
between substr(startip,instr('20298068','',1,2),instr(startip,'',1,2)-1) and substr(endip,instr('20298068','',1,2), instr('20298068','',1,3)-1)
and substr('21806182',instr('20298068','',1,3))
between substr(startip,instr('20298068','',1,3),instr(startip,'',1,3)-1) and substr(endip,instr('20298068','',1,3), instr('20298068','',1,3)-1)
select client_net_address '客户端IP',local_net_address '服务器的IP' from sysdm_exec_connections where Session_id=@@spid
@@spid的作用是返回当前进程的会话ID。
oracle查看服务器IP方法。
1、打开plsql,登录到指定数据库。
2、新建查询,输入sql语句,如下:
select sys_context('userenv','ip_address') from dual;
3、查询结果就是服务器的IP地址,
select
LOCATION
from
T_Base_IPAddressInfo
where
'192168072'
between
startip
and
endip
这样可以查,但是不准确
select
SUBSTR('21806182',
1,length('21806182')
-
instr('',
reverse('21806182')))
from
(select
from
T_Base_IPAddressInfo
where
'21806182'
between
startip
and
endip)
t
where
startip
=
SUBSTR('21806182',
1,length('21806182')
-
instr('',
reverse('21806182')))
||
SUBSTR(startip,
instr('',
reverse(startip)))
需要了解下substr
好instr
的用法
可以得到对应IP的 , 如果是10G的话可以使用,10G之前的不知道有没有这个函数
declare
v_machi varchar2(100);
v_ip varchar2(100);
cursor c1 is select machine from v$session where machine not like 'W%';
begin
open c1;
loop
fetch c1 into v_machi;
exit when c1%notfound;
你先自己去看下
substr
好instr
两个的用法。
实现你说的方法可以:
select
substr('21806182',
1,length('21806182')
-
instr('',
reverse('21806182')))
from
(select
from
t_base_ipaddressinfo
where
'21806182'
between
startip
and
endip)
t
where
startip
=
substr('21806182',
1,length('21806182')
-
instr('',
reverse('21806182')))
||
substr(startip,
instr('',
reverse(startip)))
select startip,endip,location from T_Base_IPAddressInfo where cint(replace(ip,"",""))>= cint(replace(startip,"","")) and cint(repalce(ip,"","") <= cint(replace(endip,"",""))
以上就是关于Oracle中查询IP地址SQL全部的内容,包括:Oracle中查询IP地址SQL、如何在SqlServer中获取前端连接的IP地址,计算机名等信息、如何获取oracle服务器的ip地址等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)