Home » SQL & PL/SQL » SQL & PL/SQL » Oracle server address (11g)
Oracle server address [message #620239] Wed, 30 July 2014 09:47 Go to next message
andrewscharles89
Messages: 25
Registered: July 2014
Junior Member
How to get the ipaddress of the oracle server?

SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;

This would give the IP address of the client machine.

burleson says
this would get local IP addr
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS); -- get local IP addr

http://www.dba-oracle.com/t_get_ip_address_utl_inaddr_sys_context.htm
Re: Oracle server address [message #620240 is a reply to message #620239] Wed, 30 July 2014 09:55 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
utl_inaddr.get_host_address will give the IP address of the database server.

http://www.oracle-base.com/articles/misc/identifying-host-names-and-addresses.php
Re: Oracle server address [message #620241 is a reply to message #620239] Wed, 30 July 2014 09:56 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
it works for me

SQL> exec DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS);
127.0.0.1

PL/SQL procedure successfully completed.
Re: Oracle server address [message #620242 is a reply to message #620241] Wed, 30 July 2014 10:10 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Ah, BS posted too, so I can't add more to the same post with edit.

@OP, perhaps you got confused when Burleson says "local IP address". So what local here means, client or server? Is that what you are in doubt with?

P.S. : To avoid getting confused further, stop believing what you see in that site. The surprising fact is, Burleson's site mostly comes up first in google search.

[Updated on: Wed, 30 July 2014 10:13]

Report message to a moderator

Re: Oracle server address [message #620243 is a reply to message #620239] Wed, 30 July 2014 10:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
burleson says


Forget it and his site, most of what he says is b... and the rest is a copy of other sources.

Re: Oracle server address [message #620244 is a reply to message #620239] Wed, 30 July 2014 11:48 Go to previous message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
andrewscharles89 wrote on Wed, 30 July 2014 10:47
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;

This would give the IP address of the client machine.


Not entirely true. Only if client session is connected via tcpip. We will not get client IP address if client is connected, for example, locally or via named pipe:

C:\>set ORACLE_SID=ORCL

C:\>sqlplus scott/tiger

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 30 11:58:34 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;

SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------------------------



SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\>sqlplus scott@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=NMP)(SERVER=localhost)(PIPE=ORAPIPE)))(CONNECT_DATA=(SID=ORCL)))/tiger

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 30 11:58:49 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;

SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------------------------



SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\>sqlplus scott@orcl/tiger

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 30 11:59:00 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;

SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------------------------

127.0.0.1

SQL>



SY.
Previous Topic: REG_EXP csv and double quotes
Next Topic: SQL query to retrieve one record for each employee
Goto Forum:
  


Current Time: Wed Apr 24 23:12:42 CDT 2024