Cloning to PDB and Implication of OMF

This blog post is applicable only for >=12c, If you are using any non-container database or PDB and if in case you are migrating or unplug/plug to another container database. First you will describe the PDB into XML file, after that we will create pluggable database using the XML manifest file and also we mention the FILE_NAME_CONVERT in order to ensure if the source and destination datafiles location are different.

SQL> select name from v$pdbs;
NAME
------------------------------
PDB$SEED
EBSPDB
SQL> create pluggable database tdepdb as clone using '/u02/app/oracle/oradata/tdepdb/noncdb_to_cdb.xml' file_name_convert=('/u02/app/oracle/oradata/TEDDB/datafile','/u02/app/oracle/oradata/tdepdb') copy;
create pluggable database tdepdb as clone using '/u02/app/oracle/oradata/tdepdb/noncdb_to_cdb.xml' file_name_convert=('/u02/app/oracle/oradata/TEDDB/datafile','/u02/app/oracle/oradata/tdepdb') copy
*
ERROR at line 1:
ORA-01276: Cannot add file
/u02/app/oracle/oradata/tdepdb/o1_mf_system_blw4d3l0_.dbf.  File has an Oracle
Managed Files file name.

From the above command of “create pluggable database” its failed with the error ORA-01276 which states the datafiles are OMF and hence we need to retry the operation with a new file name. So for that we cannot go and change whole database configuration from source database, Instead of that we can convince the database that we also have configured OMF in new container where we are going to plug PDB. So we need to configure OMF for that as below.

SQL> alter system set db_create_file_dest='/u02/app/oracle/oradata/tdepdb';
 System altered.
 SQL>

After configuring later when creating pluggable database it can redirect the files by default to OMF and we can safely create the new PDB.

SQL> create pluggable database tdepdb as clone using '/u02/app/oracle/oradata/tdepdb/noncdb_to_cdb.xml' copy;
Pluggable database created.
SQL> select name from v$Pdbs;
NAME
------------------------------
PDB$SEED
EBSPDB
TDEPDB

SQL>

Finally , we able to plug the PDB to the container database.