Convert non-CDB database to Pluggable database in Oracle 12c

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 12.1.0.1 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.

shutdown immediate;

Step 2: Open in read only mode

startup mount
alter database open read only;

Step 3:  Generate the xml file

BEGIN
DBMS_PDB.DESCRIBE(
pdb_descr_file => 'C:\k.xml');
END;
/

Step 4: Open the database in read write mode

shutdown immediate;
startup;

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
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => 'C:\k.xml',
pdb_name       => 'k')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/

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
C:\APP\ADMINISTRATOR\ORADATA\K\DATAFILE\O1_MF_SYSTEM_9C5K017B_.DBF
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;
show con_id
------------
Testdb2/rdbms/admin/noncdb_to_pdb.sql

Step 9: Open the database in normal read/write state.

connect with cdb
sqlplus sys as sysdba
password
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;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s