Tuesday, June 9, 2009

Identifying ORACLE DB Host Name and its IP Address

Identifying ORACLE DB Host Name and its IP Address including client IP address (from which client is connected):

SYS_CONTEXT function returns the current session information:

There are various ways to find db name to which connection is made are as follows:

select sys_context('userenv','db_name') from dual;
select ora_database_name from dual;
select global_name from global_name;

select sys_context('USERENV','IP_ADDRESS' ) FROM DUAL;
-- returns the IP address of client machine from which connection is established

few more..
select USERENV('LANGUAGE') ,
USERENV('ISDBA') from dual;
..etc..

We can find local and remote hosts information using UTL_INADDR package in oracle 10g.
more info just type desc UTL_INADDR

SELECT UTL_INADDR.get_host_address from dual;
-- returns the IP address of database physical system

there is lot more info we can find with UTL_INADDR and SYS_CONTEXT.

... cheers...

No comments:

Post a Comment