Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the server name for an Oracle database

Tags:

oracle

Is there a way of finding the name of the server an Oracle database is hosted on?

like image 263
darreljnz Avatar asked Mar 02 '10 21:03

darreljnz


People also ask

How do I find my Oracle server name?

You can use sys_context('USERENV', 'SERVICE_NAME') to get the database service name instead of the machine name.

How do I find the instance name of a database in Oracle?

Answer: You can retrieve the instance name and database name using the sys_context function.

Which server is used for Oracle?

The Oracle Parallel Server: Multiple Instance Systems In appropriate applications, the Oracle Parallel Server allows access to a single database by the users on multiple machines with increased performance.


2 Answers

If you don't have access to the v$ views (as suggested by Quassnoi) there are two alternatives

select utl_inaddr.get_host_name from dual 

and

select sys_context('USERENV','SERVER_HOST') from dual 

Personally I'd tend towards the last as it doesn't require any grants/privileges which makes it easier from stored procedures.

like image 67
Gary Myers Avatar answered Oct 09 '22 20:10

Gary Myers


SELECT  host_name FROM    v$instance 
like image 39
Quassnoi Avatar answered Oct 09 '22 19:10

Quassnoi