Moving PDB's (Unplugging/Plugging in PDB)

Exporting/Unplugging An Existing PDB
To unplug a database, use the following commands. It is recommended that the path used match the datafile storage location.
ALTER PLUGGABLE DATABASE <pdb_name> CLOSE;

ALTER PLUGGABLE DATABASE <pdb_name> UNPLUG INTO '</path/><name>.xml';

DROP PLUGGABLE DATABASE <pdb_name> KEEP DATAFILES;


Importing/Plugging in PDB into a CDB
Before importing/plugging in a PDB into a CDB a small procedure should be run to Validate the integrity and compatibility of the PDB.
SET SERVEROUTPUT ON

DECLARE

     l_result     BOOLEAN;

BEGIN

     l_result := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(

                          PDB_DESCR_FILE => '</path/><name>.xml',

                          PDB_NAME       => '<name>');

     IF l_result THEN

          DBMS_OUTPUT.PUT_LINE('Compatible, OK to Proceed');

     ELSE

          DBMS_OUTPUT.PUT_LINE('Incompatible, See PDB_PLUG_IN_VIOLATIONS for details');

     END IF;

END;


If the pdb is validated, then use the following commands to import/plug it in. Reference the xml file path specified during export, and the datafile path...
CREATE PLUGGABLE DATABASE <new_pdb_name> USING '</path/><name>.xml'

       FILE_NAME_CONVERT=('</source path/>','</dest path/>');

ALTER PLUGGABLE DATABASE <new_pdb_name> OPEN;
Comments