Convert non-CDB database to Pluggable database in Oracle 12c
First database is in the same version, if you want convert non-CDB database into pluggable then you have same version and patch set applied on binaries. Example testdb2 is non-CDB database and convert into pluggable both binaries is exact match 184.108.40.206 and patches applied are also same.
Note: If you want to convert 11g to pluggable then you first need to upgrade into 12c then follow the following steps:
Steps to convert Non-CDB to pluggable database
Step 1 : Connect with non-CDB database and Shutdown it.
Note: Take full backup as precautions.
Step 2: Open in read only mode
alter database open read only;
Step 3: Generate the xml file
pdb_descr_file => 'C:\k.xml');
Step 4: Open the database in read write mode
Step 5: Contact to Container Database(CNDB) inwhich we need to migrate the database:
Note: Patch on both Oracle binaries should be same.
SET SERVEROUTPUT ON
compatible CONSTANT VARCHAR2(3) :=
pdb_descr_file => 'C:\k.xml',
pdb_name => 'k')
WHEN TRUE THEN 'YES'
Step 6: Shutdown the existing non container CDB database otherwise got the following error:
ERROR at line 1:
ORA-65028: Unable to open plugin data file at path
ORA-27086: unable to lock file - already in use
OSD-00002: additional error information
O/S-Error: (OS 32) The process cannot access the file because it is being used
Step 7: Create a pluggable database with following commmand:
CREATE PLUGGABLE DATABASE testdb2 using 'c:\k.xml' nocopy tempfile reuse;
Note: nocopy donot change the location of datafiles.
Step 8: Connect with cdb and run the following command :
ALTER SESSION SET CONTAINER =testdb2;
Step 9: Open the database in normal read/write state.
connect with cdb
sqlplus sys as sysdba
alter pluggable database testdb2 open;
Step 10: Check the list of PDB databases and check alert log file.
alter session SET CONTAINER =CDB$ROOT;
select PDB_NAME, DBID, CON_ID, STATUS from CDB_PDBS;