Get Current Schema and DB name

Some times we do not know about our schema exist in which db and which is our schema hare is the method to find db and schema name.

DECLARE
   CURSOR ashish_db_name
   IS
      SELECT NAME
      FROM   v$database;
   My_db_name   VARCHAR2 (4000);
BEGIN
   OPEN ashish_db_name;
   FETCH ashish_db_name
   INTO  My_db_name   ;
   CLOSE ashish_db_name;

htp.p('Schema Name:'||SYS_CONTEXT ('USERENV',
                              'CURRENT_SCHEMA'
                              ));
htp.p('My DB Name:'|| My_db_name   );
END;


Result

Schema Name:ASH_SCHEMA
My DB Name:ORCL

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *