Eng. Samer T
Eng. Samer T

Reputation: 6536

How to know oracle database server ip?

Is there any function in oracle database to provide the current connected server name (or ip) on which the database is running?

The question in other way, in oracle tnsnames.ora file I have the following

ORA9 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.14.208)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.14.209)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

How to know if the connected server ip is 192.168.14.208 or 192.168.14.209 in my application?

Upvotes: 2

Views: 16441

Answers (2)

rainu
rainu

Reputation: 763

PFB some of the ways in which oracle database server IP can be identified in SQL environment.

Get the server IP of the database in which you are connected to.

SELECT UTL_INADDR.get_host_address FROM dual;

Get the server IP based on server hostname

SELECT UTL_INADDR.get_host_address('hostname') FROM dual;

Fetch IP details of the host system from which the query is being invoked.

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

Additional information in link.

Upvotes: 1

Yogendra Singh
Yogendra Singh

Reputation: 34387

Try:

SELECT UTL_INADDR.get_host_address from dual;

Upvotes: 5

Related Questions