Checking oracle sid and database name

Adnan picture Adnan · Jun 9, 2011 · Viewed 706.6k times · Source

I want to check SID and current database name.

I am using following query for checking oracle SID

select instance from v$thread;

but table or view does not exist error is coming.

I am using following query for checking current database name

select name from v$database;

but table or view does not exist error is coming.

Any idea for above two problems?

Answer

V4Vendetta picture V4Vendetta · Jun 9, 2011

I presume SELECT user FROM dual; should give you the current user

and SELECT sys_context('userenv','instance_name') FROM dual; the name of the instance

I believe you can get SID as SELECT sys_context('USERENV', 'SID') FROM DUAL;