FIND HOSTNAME FROM SQL*PLUS ORACLE

Use bang character to use host commands from sqlplus

kish@exdbx<>!hostname
exdbadm01

You can filter the hostname from uname transparently

kish@exdbx<>!uname -a|awk '{print $2}'
exdbadm01

Use v$instance

kish@exdbx<>select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
exdbadm01

Use v$session to get machine details from sys

kish@exdbx<>select distinct machine from v$session where username='SYS';

MACHINE
----------------------------------------------------------------
exdbadm01

Use ASH to get the machine details

kish@exdbx<>select distinct machine from v$active_session_history where machine <> 'NULL';

MACHINE
----------------------------------------------------------------
exdbadm01

Use sys_context function to get the host from pseudo view

kish@exdbx<>select sys_context('userenv','host') as host from dual;

HOST
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
exdbadm01

Use utl_inaddr function to invoke get_host_name

kish@exdbx<>select utl_inaddr.get_host_name as host from dual;

HOST
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
exdbadm01

Use local or remote listener to get the host from tns entry

kish@exdbx<>show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string       (ADDRESS=(PROTOCOL=TCP)(HOST=
                                                 exdbadm01)(PORT=1521))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s