Tuesday, April 29, 2025

How to check and list pluggable database in oracle ?

 


SQL> 

SQL> select name from v$pdbs;


NAME

--------------------

PDB$SEED

PDB


SQL> 




SQL> select pdb_name from cdb_pdbs;


PDB_NAME

--------------------

PDB

PDB$SEED





SQL> 

SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

SQL> 

SQL> 



Oracle Error : ORA-65040: operation not allowed from within a pluggable database

 

ORA-65040: operation not allowed from within a pluggable database


SQL> drop pluggable database demo1 including datafiles;

drop pluggable database demo1 including datafiles

*

ERROR at line 1:

ORA-65040: operation not allowed from within a pluggable database



SQL> 



Solution :


=> connect to the container database 

=> close the pluggable database 

=> unplug the pluggable database (optional)

=> drop the pluggable database 

    .if we are using the command without including datafiles , this only remove pdb not underline datafiles etc .




SQL> alter session set container =cdb$root;


Session altered.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

4 DEMO1   READ WRITE NO

SQL> 

SQL> alter pluggable database demo1 close immediate;


Pluggable database altered.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

4 DEMO1   MOUNTED

SQL> drop pluggable database demo1 including datafiles;


Pluggable database dropped.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

SQL> 

How to check pdb database name and dbid in oracle 19c ?

 check pdb database name and dbid in oracle



SQL> 

SQL> select dbid , name from v$pdbs;


      DBID NAME

---------- ----------------------------------------

3326623803 PDB


SQL> 

How to start pluggable database in oracle 19c ?

 Start pluggable database in oracle 


SQL> 

SQL> alter session set container=pdb$seed;


Session altered.


SQL> 

SQL> show con_name


CON_NAME

------------------------------

PDB$SEED

SQL> 

SQL> 

SQL> alter pluggable database pdb open read write;

alter pluggable database pdb open read write

*

ERROR at line 1:

ORA-65118: operation affecting a pluggable database cannot be performed from

another pluggable database



SQL> alter session set container=pdb;


Session altered.


SQL> show con_name


CON_NAME

------------------------------

PDB

SQL> 

SQL> alter pluggable database pdb open read write;


Pluggable database altered.


SQL> 



SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

3 PDB   READ WRITE NO

SQL>