易截截图软件、单文件、免安装、纯绿色、仅160KB

获取oracle client登录IP的方法

 一、UTL_INADDR包获取ip地址
今天有朋友在MSN上问我如何获得已经连接用户的IP地址。
我们知道,通过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
在Linux中我们通过strace跟踪这个进程,可以得到以下堆栈信息:
[oracle@jumper oracle]$ strace -p 14701
Process 14701 attached - interrupt to quit
read(7, "\0\313\0\0\6\0\0\0\0\0\3^\10a\200\0\0\0\0\0\0@\342\22\10"..., 2064) = 203
gettimeofday({1161746697, 269895}, NULL) = 0
getrus


相关文档:

Oracle入门书籍推荐《转》

Oracle入门书籍推荐
链接:http://www.eygle.com/archives/2006/08/oracle_fundbook_recommand.html
很多朋友要我帮忙推荐一下Oracle的入门书籍,能够了解Oracle的基本概念、基本知识的那种。
我就免为其难,推荐几本。
首先我想强调的一点是,任何一本系统的Oracle书籍只要认真读下来,都会有不错的收获,读书最忌讳的 ......

Oracle 存储过程

 
create or replace procedure p   //有就替换,没有就创建
is
     cursor c is
         select * from emp for update;
begin
  for v_emp in c loop
      if (v_emp.deptno =10) then
 &nb ......

Virtual Columns in Oracle Database 11g

When queried, virtual columns appear to be normal table columns, but
their values are derived rather than being stored on disc. The syntax
for defining a virtual column is listed below.
column_name [datatype] [GENERATED ALWAYS] AS (expression) [VIRTUAL]
If the datatype is omitted, it is determin ......

Oracle中TO_DATE格式

 TO_DATE格式(以时间:2007-11-02   13:45:25为例)
  
        Year:     
        yy two digits 两位年              ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号