In the examples below, I am unplugging the databases pdb1 and pdb2 into two different manifest files:
sqlplus / as sysdba alter pluggable database pdb1 close immediate; alter pluggable database pdb1 unplug into '/u01/app/oracle/oradata/pdb1.xml'; alter pluggable database pdb2 close immediate; alter pluggable database pdb2 unplug into '/u01/app/oracle/oradata/pdb2.xml';The XML file created in the unplug operation contains information about the names and the full paths of the tablespaces, as well as data files of the unplugged PDB.
This information will then be used by a subsequent plugg-in operation.
After having unplugged a pdb you can drop the pluggable database but physically keep the datafiles belonging to it, like this:
drop pluggable database pdb1 keep datafiles;If you wish to plug the database into a different CDB, it is a good idea to check the compatability of the database with the CDB first. This is particulary true if the new CDB is created with newer binaries than the original CDB, or if it is on a different host.In the new CDB, execute the following pl/sql code:
set serveroutput on DECLARE compatible BOOLEAN := FALSE; BEGIN compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY( pdb_descr_file => '/u01/app/oracle/oradata/pdb1.xml'); if compatible then DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? YES'); else DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? NO'); end if; END; /If the output shows that the database is compatible with the new CDB, proceed to plugin the database.
Plug operations can be done using two different methods: NOCOPY and COPY.
Using the NOCOPY method will use the data files of the unplugged PDB to plug the PDB into another (or the same) CDB without any physical file copy:
create pluggable database pdb_plug_nocopy using '/u01/app/oracle/oradata/pdb1.xml' NOCOPY TEMPFILE REUSE;When using the NOCOPY option, the plugin operation lasts a few seconds. The original data files of the unplugged PDB now belong to the new plugged-in PDB in the new (or the same) CDB. A file with the same name as the temp file specified in the XML file exists in the target location. Therefore, the TEMPFILE_REUSE clause is required.
Using the COPY method, will physically move datafiles from the original destination to a new destination:
mkdir -p /u01/app/oracle/oradata/cdb2/pdb_plug_copy create pluggable database pdb_plug_copy using '/u01/app/oracle/oradata/pdb2.xml' COPY FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdb2','/u01/app/oracle/oradata/cdb2/pdb_plug_copy');Verify the status, open mode and the file location of the plugged-in PDB (In the example below, I am showing the output for the pdb created using the COPY method, but it should always be done regardless of the method used):
select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_COPY'; --> should return PDB_PLUG_COPY and NEW select open_mode from v$pdbs where name='PDB_PLUG_COPY'; --> should return MOUNTED select name from v$datafile where con_id=(select con_id from v$pdbs where name='PDB_PLUG_COPY';) --> should return the full path and name of the datafiles belonging to the system and sysaux tablespaces.Whether or not you are using the NOCOPY or COPY method, you will now have to open the newly plugged in database in the new CDB:
alter pluggable database pdb_plug_nocopy open; alter pluggable database pdb_plug_copy open; show con_name show pdbsSource: Oracle 12cR1 tutorial