Introduction to OracleDB 6: Use DB LINK to clone non-CDB into CDB architecture

Version description:

    Original library: ORACLE 12cR1 non-CDB architecture

    Target library: ORACLE 12cR1 CDB architecture

1. Target database installation


Two, dbca creates a CDB database instance

#dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-GDBNAME  T24_CDB                        \
-SID  T24_CDB                            \
-EMCONFIGURATION  "NONE"                   \
-SYSPASSWORD  "Password_4U"                 \
-SYSTEMPASSWORD  "Password_4U"              \
-DBSNMPPASSWORD  "Password_4U"              \
-STORAGETYPE  FS                             \
-NUMBEROFPDBS  1                                 \
-PDBNAME  SGP_DEV                                   \
-DATAFILEDESTINATION  "/odata/datafile/"                 \
-RECOVERYAREADESTINATION "/odata/fast_recovery_area/"              \
-MEMORYPERCENTAGE  "15"                        \
-CHARACTERSET  "AL32UTF8"                   \


  1. Here the CREATEASCONTAINERDATABASE option identifies (TRUE) to create a CDB container database;
  2. NUMBEROFPDBS specifies the initial number of PDBs, except for pdb$seed, the system automatically creates the number of pluggable database PDBs;
  3. PDBNAME specifies the name of the created PDB , or not specified, the system defaults;
  4. Other GDBNAME, SID, DATAFILEDESTINATION, etc. are the same as the non-CDB architecture;

Three, configure the tns connection string to the source library

Such as: tnsnames.ora

   (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))
        (CONNECT_DATA =
           (SERVER = DEDICATED)
           (SERVICE_NAME = SGP_DEV2)

Use tnsping test after configuration :

bash-4.2$ tnsping SGP_DEV2
TNS Ping Utility for Linux: Version - Production on 08-JUL-2019 19:27:57
Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
OK (10 msec)

Fourth, the target library to create a DB link

SQL> create database link OLDDB connect to system identified by XXX using ‘TNS_NAME’;


  1. TNS_NAME is the name of the tns connection string created in the third step;
  2. OLDDB is the name of the db link object;
  3. XXX represents the password of the user SYSTEM

Five, set the original library to read only

SQL>shutdown immediate;
SQL>startup open read only;

 Note: Because the undo tablespace of 12cR1 only supports the share mode , that is, all PDBs in the C DB architecture share the UNDO tablespace , and to prevent the original database from changing during the clone process, the original database must be set to read-only. Otherwise, an error will be reported in the subsequent steps.

6. Use db link to clone remote database

SQL> create pluggable database PDB_DEV from NON$CDB@OLDDB file_name_convert=(‘PATH1’,’PATH2’);


  1. The cloned PDB name is: PDB_DEV
  2. This command uses the NON$CDB user to connect to the DB link . Is NON$CDB the official Oracle user dedicated to non-CDB migration? ?
  3. F ile_name_convert file path for conversion;

After the command is executed, theoretically the PDB PDB_DEV has been created successfully, and the related service is also ready (check lsnrctl status);

Seven, noncdb_to_pdb.sql conversion

  • Modify session:
SQL> alter session set container= PDB_DEV
  • Convert to PDB
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql


1. This step may take 5~10min , please wait patiently;

2. It is said that the 12cR1 version may report an error (ORA-600) when calling this script. This error is a bug in oracle, and the author did not appear at the time of conversion;

8. Finally

The converted PDB is in the read only state (or mount state) and is changed to the open state:

SQL> alter pluggable database PDB_DEV open

End--------------------Welcome to discuss


Guess you like