After learning creating pluggable database, we will discuss about dropping pluggable database(PDB) in 12c, 19c and above versions
Here we will drop pluggable database PDB_TECHNO, below are the steps for the same
Pluggable database altered.
- Dropping pluggable database is similar to dropping any other regular database, you have two options while dropping pluggable database related to its datafiles
 - Dropping PDB including datafiles
 - Dropping PDB keeping datafiles
 
Here we will drop pluggable database PDB_TECHNO, below are the steps for the same
- Check status of pluggable database using v$containers you want to drop
 
SQL>
select con_id, name,open_mode from v$containers;
    CON_ID NAME                           OPEN_MODE
----------
------------------------------ ----------
         1 CDB$ROOT                       READ WRITE
         2 PDB$SEED                       READ ONLY
         3 PDB_1                          READ WRITE
         4 PDB_TECHNO                     READ WRITE
you can see this PDB exists and save is in READ WRITE mode- Close the database using alter database command before dropping database and check the status
 
Pluggable database altered.
SQL>
select con_id, name,open_mode from v$containers;
 
  CON_ID NAME               
           OPEN_MODE
----------
------------------------------ ----------
 
       1 CDB$ROOT           
           READ WRITE
 
       2 PDB$SEED           
           READ ONLY
 
       3 PDB_1           
              READ WRITE
 
       4 PDB_TECHNO         
           MOUNTED
Now drop the PDB using including datafiles
In this way we can drop any pluggable database, dropping container database is like dropping any other database but we have to be sure before dropping it as it will drop all pluggable databases including seed PDB present under it.
SQL> drop pluggable database
PDB_TECHNO including datafiles;
Pluggable
database dropped.
SQL>
select con_id, name,open_mode from v$containers;
 
  CON_ID NAME               
           OPEN_MODE
----------
------------------------------ ----------
 
       1 CDB$ROOT           
           READ WRITE
 
       2 PDB$SEED           
           READ ONLY
         3 PDB_1           
              READ WRITE
In this case we have dropped pluggable database including datafiles as we do not need these datafiles but in case if we need datafile even after dropping pluggable database, we can simply use drop command excluding option of "including datafiles", 
- By default oracle drops pluggable database with keeping datafiles so below both commands are equivalent
 
drop pluggable database PDB_TECHNO keep
datafiles;
drop pluggable database PDB_TECHNO;
In case we try to drop non closed (open) pluggable database using including datafiles, it will throw and error but same can be dropped with option keep datafiles
SQL> drop pluggable database PDB_TECHNO
including datafiles;
drop pluggable database PDB_TECHNO including
datafiles
*
ERROR at line 1:
ORA-65025: Pluggable database PDB_TECHNO is
not closed on all instances.
SQL> drop pluggable database PDB_TECHNO
keep datafiles;
Pluggable database dropped.
In this way we can drop any pluggable database, dropping container database is like dropping any other database but we have to be sure before dropping it as it will drop all pluggable databases including seed PDB present under it.

Thank you for such a wonderful article. I got a quick question,
ReplyDeleteCan we convert a container database in Oracle12c R2 to non-container database by first dropping a container database and re-create a non-container database via DBCA