查看当前链接的IP(查看当前自己链接IP,不能查看其它的链接的IP):
SELECT USER,SID,SERIAL#,UTL_INADDR.GET_HOST_ADDRESS AS HOST,SYS_CONTEXT('USERENV','IP_ADDRESS') AS LOCAL,SYSDATE FROM V$SESSION WHERE AUDSID=SYS_CONTEXT('USERENV','SESSIONID');
查看所有链接Oracle的客户端的IP等信息:
step1: 查看每个oracle帐户的连接总数:
select username,count(username) from v$session where username is not null group by username;
USERNAME COUNT(USERNAME)
ORCL 117
SYS 1
step2: 缺省从 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;
/
step3: 比较常用的显示客户端信息的sql(通过step2执行以后,再执行step3,新链接上来的客户端信息,就能显示ip了)
select sid,serial#,username,program,machine,client_info
from v$session
where username is not null
order by username,program,machine;
|