许多人都知道,通过SYS_CONTEXT函数可以获得部分信息,当前用户的ip等信息则可以通过下面的命令来进行获取:
SQL> select sys_context('userenv','host') from dual;
SYS_CONTEXT('USERENV','HOST')
---------------------------------------------------
WORKGROUP\GQGAI
SQL> select sys_context('userenv','ip_address') from dual;
SYS_CONTEXT('USERENV','IP_ADDR
---------------------------------------------------
172.16.34.20 |
假如你需要获取其它session的地址等信息,SYS_CONTEXT函数则只能通过LOGON触发器来完成。
在没有触发器记录的前提下,你可以通过UTL_INADDR Package来实现。
下面具体介绍一下UTL_INADDR包获取ip等信息的工作原理。
首先,在数据库中进行下面的查询:
[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Wed Oct 25 11:24:22 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> !
[oracle@jumper oracle]$ ps -ef|grep sql
oracle 14700 14663 1 11:24 pts/0 00:00:00 sqlplus
oracle 14732 14702 0 11:24 pts/0 00:00:00 grep sql
[oracle@jumper oracle]$ ps -ef|grep LO
oracle 14701 14700 0 11:24 ? 00:00:00 oracleeygle
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14734 14702 0 11:24 pts/0 00:00:00 grep LO
[oracle@jumper oracle]$ exit
exit
SQL> SELECT UTL_INADDR.get_host_address('www.anysql.net') from dual;
UTL_INADDR.GET_HOST_ADDRESS('WWW.ANYSQL.NET')
---------------------------------------------------------
208.113.151.109 |
转贴于:Oracle认证考试_考试大【责编:冷客 纠错】
[1] [2]