You can remove a plugged-in PDB from a CDB by unplugging it, dropping it, or relocating it.
Just as you can plug a PDB into a CDB, you can unplug a PDB from a CDB.
Unplugging a PDB
Unplugging a PDB disassociates the PDB from a CDB. A PDB is usable only when it is plugged into a CDB.
Unplug a PDB when you want to do any of the following:
- Move the PDB to a different CDB
- Archive the PDB for later use
- Make the PDB unavailable for use
To unplug a PDB, connect to its CDB root or application root and use the ALTER PLUGGABLE DATABASE
statement to specify either of the following:
- XML file
An XML file (.xml extension) contains metadata about the PDB after it is unplugged. This metadata contains the required information to enable a CREATE PLUGGABLE DATABASE
statement on a target CDB to plug in the PDB.
- .pdb file
A .pdb file contains a compressed archive of the XML file that describes the PDB and the files used by the PDB (such as the data files and wallet file). A .pdb file enables you to copy a single, compressed file (instead of multiple files) to a new location to plug the PDB into a CDB.
The PDB must be closed before it can be unplugged. When you unplug a PDB, the unplugged PDB is in mounted mode. The unplug operation makes some changes in the PDB’s data files to record, for example, that the PDB was successfully unplugged. Because it is still part of the CDB, the unplugged PDB is included in an RMAN backup of the entire CDB. Such a backup provides a convenient way to archive the unplugged PDB in case it is needed in the future.
To completely remove the PDB from the CDB, drop the PDB. The only operation supported on an unplugged PDB is dropping the PDB. The PDB must be dropped from the CDB before it can be plugged back into the same CDB.
Unplugging a PDB
Unplug a PDB with a ALTER PLUGGABLE DATABASE ... UNPLUG INTO
statement.
Prerequisites
To unplug a PDB:
- In SQL*Plus, ensure that the current container is the root of the PDB.
If the PDB is plugged into the CDB root, then the current container must be the CDB root. If the PDB is plugged into an application root, then the current container must be the application root.
If you are unplugging an application container, then the current container must be the CDB root, and the application container must not have any application PDBs plugged into it.
- Close the PDB.
In an Oracle Real Application Clusters (Oracle RAC) environment, the PDB must be closed on all instances.
- Run the
ALTER PLUGGABLE DATABASE
statement with theUNPLUG INTO
clause, and specify the PDB to unplug and the name and location of the PDB’s XML metadata file or .pdb file.
Unplugging PDB salespdb Into an XML Metadata File
This ALTER PLUGGABLE DATABASE
statement unplugs the PDB salespdb
and creates the salespdb.xml
metadata file in the /oracle/data/
directory:
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/salespdb.xml';
Unplugging PDB salespdb Into an Archive File
This ALTER PLUGGABLE DATABASE
statement unplugs the PDB salespdb
and creates the sales.pdb
archive file in the /oracle/data/
directory. The sales.pdb
archive file is a compressed file that includes the XML metadata file and the PDB’s files (such as the data files and wallet file).
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/sales.pdb';
Dropping a PDB
Drop a PDB when you want to move the PDB to a new CDB or when you no longer need it.
When you drop a PDB, the control file of the CDB is modified to eliminate all references to the dropped PDB. Archived redo log files and backups associated with the PDB are not removed, but you can use Oracle Recovery Manager (RMAN) to remove them.
When dropping a PDB, you can either keep or delete the PDB’s data files by using one of the following clauses of the DROP PLUGGABLE DATABASE
statement:
KEEP DATAFILES
, the default, retains the data files.
The PDB temp file is removed even when KEEP DATAFILES
is specified because the temp file is no longer needed.
When KEEP DATAFILES
is specified, the PDB must be unplugged.
INCLUDING DATAFILES
removes the data files from disk.
If a PDB was created with the SNAPSHOT COPY
clause, then you must specify INCLUDING DATAFILES
when you drop the PDB.
To drop a PDB:
- In SQL*Plus, ensure that the current container is the CDB root, or, for an application PDB, the application root that contains the application PDB.
If the PDB is plugged into the CDB root, then the current container must be the CDB root. If the PDB is plugged into an application root, then the current container must be that application root or the CDB root.
If you are dropping an application container, then the current container must be the CDB root, and the application container must not have any application PDBs plugged into it.
- Run the
DROP PLUGGABLE DATABASE
statement and specify the PDB to drop.
Dropping PDB salespdb While Keeping Its Data Files
DROP PLUGGABLE DATABASE salespdb
KEEP DATAFILES;
Dropping PDB salespdb and Its Data Files
DROP PLUGGABLE DATABASE salespdb
INCLUDING DATAFILES;