Disclaimer

These scripts come without warranty of any kind. Use them at your own risk. I assume no liability for the accuracy, correctness, completeness, or usefulness of any information provided by this site nor for any sort of damages using these scripts may cause.
Showing posts with label verify. Show all posts
Showing posts with label verify. Show all posts

Monday, May 3, 2021

How to check if connected to Oracle Pluggable Database (PDB)

 To know if you are connected to a Pluggable Database ( PDB) which is part of Container Database(CDB)

Execute below SQL script.

SELECT DECODE (SYS_CONTEXT ('Userenv', 'CDB_NAME')

                                         ,null,'NO','YES'),

                                  Sys_Context('Userenv', 'CON_ID'),

                                  Sys_Context('Userenv', 'CON_NAME')

                          From dual;


If connected to PDB you will get first column value as YES , a non zero number for second column and PDB Name in third column


If connected to a normal database (non CDB/PDB) you will get first column value as NO, zero for second column and Database Name in third column.