缺省从 v$session 中不能直接获得客户端 IP,可以在数据库中创建一个追踪客户端IP地址的触发器:
create or replace trigger on_logon_trigger after logon on database
begin
dbms_application_info.set_client_info(sys_context('userenv', 'ip_address'));
end;
/
现在就可以在 V$SESSION 视图的 CLIENT_INFO 列中看到新登录的客户端IP地址了。
col sid for 9999
col serial# for 999999
col username for a15
col program for a20
col machine for a30
col client_info for a15
select sid,serial#,username,program,machine,client_info
from v$session
where username is not null
order by username,program,machine;
create or replace trigger on_logon_trigger after logon on database
begin
dbms_application_info.set_client_info(sys_context('userenv', 'ip_address'));
end;
/
现在就可以在 V$SESSION 视图的 CLIENT_INFO 列中看到新登录的客户端IP地址了。
col sid for 9999
col serial# for 999999
col username for a15
col program for a20
col machine for a30
col client_info for a15
select sid,serial#,username,program,machine,client_info
from v$session
where username is not null
order by username,program,machine;
本文介绍了一种在Oracle数据库中通过创建触发器来记录客户端IP地址的方法,并提供了实现的具体SQL语句。使用该方法可以在V$SESSION视图中查看到客户端的IP地址。
6255

被折叠的 条评论
为什么被折叠?



