Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Is the database server on the local machine?

Re: Is the database server on the local machine?

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 2 Dec 2004 09:29:52 -0800
Message-ID: <92eeeff0.0412020929.db7b7bd@posting.google.com>


"Mark C. Stock" <mcstockX_at_Xenquery .com> wrote in message news:<pMqdnUtdvsRInDLcRVn-qQ_at_comcast.com>...
> <rs_arwar_at_hotmail.com> wrote in message
> news:1101982692.106489.36970_at_f14g2000cwb.googlegroups.com...
> | SYS_CONTEXT and V$SESSION as mentioned in the other posts will give
> | you information about the client PC that is connected to the database.
> | If you want the database server (where the database is running)
> | IP/Hostname then you can call
> | select UTL_INADDR.Get_Host_Name from dual;
> | or
> | select UTL_INADDR.Get_Host_Address from dual;
> | I believe this is only available in 8i and above.
> |
> | Regards
> | /Rauf
> |
>
> works as well as the other suggestions, which also both worked
>
> v$session gives client and server machine information depending on the
> session -- the post regarding that suggested getting the machine for SID 1,
> which is one of the server background process
>
> sys_context('USERENV','HOST') also provides the DBMS server machine name --
> returns the same value as "select UTL_INADDR.Get_Host_Name from dual";
> tested on my 8.1.7 laptop and on 10g at htmldb.oracle.com
>
> additionally, SELECT HOSTNAME FROM V$INSTANCE gives the DBMS server machine
> name
>
> ++mcs

You are partially correct about v$session and v$instance but sys_context will still give you client PC machine name. Here is a screen dump. I have obviously changed the machine name and IP. This is from 9.2.0.5.0. The only advantage with utl_inaddr (aside from v$session) is that it is granted to public with an option to get both hostname and IP address.

SQL> select sys_context('USERENV','HOST') from dual;

SYS_CONTEXT('USERENV','HOST')



MYDOMAIN\RAUF SQL> select machine from v$session where sid = 1;

MACHINE



MYSERVER SQL> SELECT HOST_NAME FROM V$INSTANCE; HOST_NAME

MYSERVER SQL> select utl_inaddr.get_host_name from dual;

GET_HOST_NAME



MYSERVER SQL> select utl_inaddr.get_host_address from dual;

GET_HOST_ADDRESS



195.XXX.XXX.XXX Thanks for the correction about v$session.

Regards
/Rauf Received on Thu Dec 02 2004 - 11:29:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US