大家都知道在v$session 中记录着客户端的机器名称,但是没有IP , 如果记录clinet ip 呢?
1. 利用triger 这里不介绍.
2. 利用 DBMS_SESSION 过程包.
BEGIN
DBMS_SESSION.set_identifier(SYS_CONTEXT('USERENV', 'IP_ADDRESS'));
END;
这里才查询v$session ,你会发现 v$session.CLIENT_IDENTIFIER 记录客户端的IP.
SQL*Plus: Release 10.2.0.3.0 - Production on Tue May 31 23:37:44 2011
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
system@db> exec DBMS_SESSION.set_identifier(SYS_CONTEXT('USERENV', 'IP_ADDRESS'));
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
system@db> select * from v$mystat where rownum < 2;
SID STATISTIC# VALUE
---------- ---------- ----------
517 0 1
Elapsed: 00:00:00.04
system@db> select CLIENT_IDENTIFIER from v$session where sid=517;
CLIENT_IDENTIFIER
----------------------------------------------------------------
20.1.4.201
Elapsed: 00:00:00.04
system@db>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11417069/viewspace-709242/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/11417069/viewspace-709242/