GET HOST NAME & IP IN ORACLE 10G

Use the Oracle 10g utility “UTL_INADDR” to get the Local Host Name and IP of the machine your Oracle 10g is running on. You can do this by executing the following commands: 

BEGIN
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_NAME);
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS);
END;
/

Output :-

USER
192.168.1.16

PL/SQL procedure successfully completed.



Get current database name:-



for connected instance - 
SELECT ora_database_name FROM dual; 
OR
SELECT global_name FROM global_name;

OR
SELECT * FROM global_name;


Output :-

ORA_DATABASE_NAME
----------------------------------------------------------------
ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM


or
Get User name, Databse name, Terminal name and Session ID:-

select 'User: '|| user || ' on database ' || global_name, ' (term='||USERENV('TERMINAL')|| ', audsid='||USERENV('SESSIONID')||')' as MYCONTEXT from global_name;

thnks....

0 comments :