To unplug the database, use the ALTER Pluggable Database command with the UNPLUG INTO clause to specify the location of the XML metadata file.
Here, we are unplugging PDB2 Database.
First, you need to close pluggable database.
SQL>ALTER PLUGGABLE DATABASE pdb2 close;
Next unplug it using below command.
SQL>ALTER PLUGGABLE DATABASE pdb2 UNPLUG INTO ‘/u01/app/oracle/oradata/CDB1/PDB2/pdb2.xml’;
Once, unplugging of PDB2 database is completed successfully, DELETE PDB2 database choosing to keep the files on the file system.
SQL>SELECT name,open_mode FROM v$pdbs ORDER BY name;
SQL>DROP PLUGGABLE DATABASE pdb2 KEEP DATAFILES;
SQL>SELECT name,open_mode FROM v$pdbs ORDER BY name;
Next, Plugin a Pluggable Database Manually.
To Plugin PDB ,First check the PDB is compatible with the CDB by calling the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function , passing in the XML metadata file and the name of the PDB.
SQL>SET SERVEROUTPUT ON;
SQL>DECLARE
l_result BOOLEAN;
BEGIN
l_result := DBMS_PDB.check_plug_compatibility(pdb_descr_file => ‘ ‘/u01/app/oracle/oradata/CDB1/PDB2/pdb2.xml’,pdb_name=>’pdb2′);
IF l_result THEN
DBMS_OUTPUT.PUT_LINE(‘compatible’);
ELSE
DBMS_OUTPUT.PUT_LINE(‘incompatible’);
END IF;
END;
If the PDB is not compatible, violations are listed in the PDB_PLUG_IN_VIOLATIONS view.
If the PDB is compatible, then create new PDB using XML file.
SQL> CREATE PLUGGABLE DATABASE pdb4 using ‘/u01/app/oracle/oradata/CDB1/PDB2/pdb2.xml’ FILE_NAME_CONVERT=(‘/u01/app/oracle/oradata/CDB1/PDB2/’,’/u01/app/oracle/oradata/CDB1/PDB4/’);
SQL>SELECT name,open_mode FROM v$pdbs ORDER BY name;
SQL>ALTER PLUGGABLE DATABASE pdb4 OPEN READ WRITE;
The post Unplug and Plug a Pluggable database (PDB) Manually in Oracle Database 12c. appeared first on DBA Trainer.