In this article i’m going to show you how to convert non-cdb database into cdb database. Convert non-container database to multitenant pluggable database with Oracle Database 12c Enterprise Edition Release 18.104.22.168.0 – 64bit.
Run following commands on both machines.
SQL> select * from v$version;
SQL>select dbid,name,cdb from v$database;
Output from Non-cdb database.
Output from cdb database.
SQL>select pdb_id,dbid,pdb_name,status from cdb_pdbs;
Output from cdb database.
Run following commands on Non-cdb database step by step.
SQL>shut immediate SQL>startup mount exclusive SQL>alter database open read only; SQL>exec dbms_pdb.describe (pdb_descr_file=>'/u01/aarav.xml'); SQL>shudown immediate
Run following commands on CDB database step by step.
SQL>SET SERVEROUTPUT ON; SQL>DECLARE Compatible CONSTANT VARCHAR2(3) :=CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY (pdb_descr_file => '/u01/aarav.xml') WHEN TRUE THEN 'YES' ELSE 'NO' END; BEGIN DBMS_OUTPUT.PUT_LINE(compatible); END; /
After running above code then check the Violations, if any.
SQL>select name, cause, type, message, status FROM PDB_PLUG_IN_VIOLATIONS WHERE name='AARAV';
Note:- In above query it’s showing two warnings, these warnings can be safely ignore.
Create pluggable database with any name using following command.
SQL>CREATE PLUGGABLE DATABASE pdb12c USING '/u01/aarav.xml' COPY FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/aarav', '/u01/app/oracle/oradata/pdb12c');
Set your session with newly created pluggable database using following command.
SQL>alter session set container=pdb12c;
Now it’s final time to migrate a non-cdb database to cdb database, just run following script.
Note:- The above script taking few minutes in execution, so don’t be panic.
After completing above script, now you can open newly pluggable database, using following command.
SQL>alter pluggable database open;
Now you can check your database name and open mode using following command.
SQL>select name, open_mode FROM v$pdbs;
When you convert a non-CDB database to a CDB pluggable database, you can choose from several options depending upon the size of the database.
If the database is very large, you might use the NOCOPY option. This minimizes the amount of extra space needed and reduces the time it takes to perform the conversion operation. The NOCOPY option is risky, however, because you don’t keep the original database files intact. Thus, if you need to restore the database to the previous state, you must restore the database using the backups taken before the conversion activity.
If database size is smaller, you should use the COPY option so that, if there are any issues, the fallback to the old non-CDB is straightforward because the original files are always intact.
You Can subscribe my YouTube channel
If you liked this blog, please write in comment box.