CONVERT NON-CDB TO CDB IN 19C
Generally, lower version non- CDB cannot be both converted and upgraded to a PDB at the same time.
Example: If 12c non-CDB should be upgraded to 19c PDB, then
- Either upgrade 12c non-CDB to 19c non-CDB and then convert to PDB
- Or convert 12c non-CDB to 12c PDB and then upgrade to 19c
Source – 19c non-CDB ; Target – 19c PDB
source NON-CDB – shutdown the database and open in read only mode.
SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup open read only;
ORACLE instance started.
Total System Global Area 1778381840 bytes
Fixed Size 8897552 bytes
Variable Size 419430400 bytes
Database Buffers 1342177280 bytes
Redo Buffers 7876608 bytes
Database mounted.
Database opened.
Export the manifest file into server. This xml file contains all the tablespaces and datafile information of non cdb to be plugged in to target CDB.
SQL> exec DBMS_PDB.DESCRIBE(pdb_descr_file => '/tmp/non_cdb.xml');
PL/SQL procedure successfully completed.
target CDB:
Always, dont skip or forget this step. This step is important in verifying the compatibility of the source non cdb to be eligible for plug in. If the output is “YES”, then well and good to go. If output is “NO”, then there are certain violations which are related to mismatch and compatibility which need to be cleared.
SQL> SET SERVEROUTPUT ON;
DECLARE
compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/tmp/non_cdb.xml')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/SQL> 2 3 4 5 6 7 8 9
YES <================
PL/SQL procedure successfully completed.
Check PDB_PLUG_IN_VIOLATIONS irrespectively, either the above procedure return YES or NO.
SQL> SELECT count(*) FROM PDB_PLUG_IN_VIOLATIONS;
COUNT(*)
----------
2
SQL> col NAME for a20
SQL> col CAUSE for a20
SQL> col MESSAGE for a20
SQL> SELECT name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS;
XSCALIBA Non-CDB to PDB WARNING PDB plugged in is a PENDING
non-CDB, requires no
ncdb_to_pdb.sql be r
un.
Create a new pluggable database in CDB so that the non CDB can be plugged into this PDB
SQL> CREATE PLUGGABLE DATABASE newpdb USING '/tmp/ncdb.xml'
2 COPY
3 FILE_NAME_CONVERT=('/u01/app/oracle/oradata/XSCALIBAL/datafile/o1_mf','/apps01/oradata/HYDRA/');
Pluggable database created.
Execute the noncdb_to_pdb.sql script to convert the non CDB to PDB
SQL> @?/rdbms/admin/noncdb_to_pdb.sql
Below are the logs which are generated as part of noncdb_to_pdb.sql script
-rw-r--r-- 1 oracle oinstall 543 May 22 15:58 apxremov1_con_catcon_12797.lst
-rw-r--r-- 1 oracle oinstall 42 May 22 15:58 apxremov1_con_catcon_12989.done
-rw-r--r-- 1 oracle oinstall 42 May 22 15:58 apxremov1_con_catcon_12988.done
-rw-r--r-- 1 oracle oinstall 439 May 22 15:58 apxremov1_con0.log
-rw-r--r-- 1 oracle oinstall 439 May 22 15:58 apxremov1_con1.log
-rw-r--r-- 1 oracle oinstall 543 May 22 15:59 apxremov2_con_catcon_13009.lst
-rw-r--r-- 1 oracle oinstall 42 May 22 15:59 apxremov2_con_catcon_13030.done
-rw-r--r-- 1 oracle oinstall 439 May 22 15:59 apxremov2_con0.log
-rw-r--r-- 1 oracle oinstall 42 May 22 15:59 apxremov2_con_catcon_13031.done
-rw-r--r-- 1 oracle oinstall 439 May 22 15:59 apxremov2_con1.log
-rw-r--r-- 1 oracle oinstall 2360 May 26 16:06 ncdb2pdb.settings.sql
Open the pdb and check the converted new pdb.
SQL> alter pluggable database newpdb open;
Pluggable database altered.
SQL> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
8 NEWPDB READ WRITE NO
SQL> alter session set container=newpdb;
Session altered.
SQL> SELECT name from v$datafile;
NAME
--------------------------------------------------------------------------------
/apps01/oradata/HYDRA/_system_l70lf69m_.dbf
/apps01/oradata/HYDRA/_sysaux_l70lfzfy_.dbf
/apps01/oradata/HYDRA/_undotbs1_l70lggjf_.dbf
/apps01/oradata/HYDRA/_users_l70lghln_.dbf