Oracle SQL to Check the Database / Instance Name to Which the Current Session Is Connected using a Non DBA user

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
There are couple of options to find out the database name for the current session. If you are a DBA a privileged user/session you can query any data dictionary views. But it is not the same case for non-dba user session.

Here are the options.

Non DBA user session

SQL> SELECT SYS_CONTEXT ('USERENV', 'DB_NAME') dbname FROM DUAL;

DBNAME
------------------------------------
ORCL

SQL> SELECT SYS_CONTEXT ('USERENV', 'INSTANCE_NAME') instance from dual;
 
INSTANCE
------------------------------------
ORCL

DBA user session
 
SQL> select name from v$database;

NAME
---------
ORCL
SQL> select * from global_name; 

GLOBAL_NAME
----------------------------------------
ORCL 

SQL> select instance_name from v$instance; 

INSTANCE_NAME
----------------
ORCL

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer