Thursday, 20 August 2015

Plugging a Non-CDB into a CDB in Oracle Database 12C

Hello DBAs. Here we are going to learn how to plug a (Non Container Database) Non-CDB into a CDB(Container Database) database.

Step 1: You need to check if your database is CDB or Non-CDB.
             a) Connect to root container(CDB) and execute the query:             
           


           b) SQL query to check if your DB is in PDB list.

                       
           If your database is not in this output , it means you need to plugin the database into this container database.

Step 2: Start the database "test" in Open Read Only mode and connect to Non-CDB database. Here I have "test" database.























Step 3: Create description file for new PDB.

exec dbms_pdb.describe (PDB_DESCR_FILE=>'<path_of_dir>/ncdb12c.xml');















Step 4: Shutdown the Non-CDB database.

Step 5: Connect to target CDB.






























Step 6: Run this PL/SQL code on sql prompt as sysdba in container database.
------------------------------------------------------------------------------------
DECLARE
   compatible BOOLEAN := FALSE;
    BEGIN
       compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
            pdb_descr_file => '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/test.xml');
       if compatible then
            DBMS_OUTPUT.PUT_LINE('Is pluggable PDB compatible? YES');
       else
            DBMS_OUTPUT.PUT_LINE('Is pluggable PDB compatible? NO');
       end if;
   END;
/
-------------------------------------------------------------------------------------
Step 7: If the output of the above code is NO, check PDB_PLUG_IN_VIOLATIONS view.





















































Note : You can ignore warning message and if there is error you need to fix them before proceeding further.

Step 8: Now plugin the non-cdb database into CDB.

 Here, test database has OMF files , so I need to convert it into normal file name. If you have normal file name convention you can use following command:







Step 9: Check the status for newly added PDB.














Step 10: Connect to newly added PDB and run the script given below:














Step 11: Now the newly plugged database must be in CDB.






I hope it will help you a lot. Please leave your query in comment section.

All the best !!!