I want to check SID and current database name.
I am using following query for checking oracle SID
select instance from v$thread;
bu
If, like me, your goal is get the database host and SID to generate a Oracle JDBC url, as
jdbc:oracle:thin:@:1521:
the following commands will help:
Oracle query command to check the SID (or instance name):
select sys_context('userenv','instance_name') from dual;
Oracle query command to check database name (or server host):
select sys_context('userenv', 'server_host') from dual;
Att. Sergio Marcelo