Pages

Unplug and Plug a PDB

Unplug and plug a PDB into different CDB:


NOTE ; Oracle 12.2 allows a PDB to be unplugged to a ".pdb" archive file. The resulting archive file contains the ".xml" file  describing the PDB as well as all the datafiles associated with the PDB.

At Source :

show con_name

CON_NAME
------------------------------
CDB$ROOT

show pdbs

ALTER PLUGGABLE DATABASE salespdb close immediate;

ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/salespdb.xml';

Note : Since unplugged PDB is closed forever. You cannot open it again.So drop it :
           Drop salespdb  in a manner that preserves the data files (because they’re needed to plug in database )


drop pluggable database salespdb   keep datafiles;


Copy the files (XML + database files) to the target location



At Target :

show con_name

CON_NAME
------------------------------
CDB$ROOT

show pdbs

Run DBMS_PDB.CHECK_PLUG_COMPATIBILITY function

CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml' 
  SOURCE_FILE_DIRECTORY = '/disk2/oracle/sales/'  
  MOVE
  FILE_NAME_CONVERT = ('/disk2/oracle/sales/', '/disk3/oracle/sales/');

  NOTE : All datafiles from /disk1 on remote was copied to /disk2 on target.
               SOURCE_FILE_DIRECTORY where you have actually copied source datafiles i.e /disk2.                  Even SOURCE_FILE_NAME_CONVERT can be used
               MOVE : Move files from /disk2  to /disk3 . You can also use COPY
              TEMPFILE REUSE  : use it if some temp files already exist in the target with the same name


show pdbs

alter pluggable database salespdb open;