Adopting a Non-CDB as a Pluggable Database in a Multitenant Container Database



    This tutorial covers the steps for cloning an Oracle Database 12c non-CDB, and plugging it as a pluggable database (PDB) into a container database (CDB).

    Time to Complete

    Approximately 30 minutes


    You can easily plug an Oracle Database 12c non-CDB into a CDB. Just create a PDB manifest file for the non-CDB, and then use the manifest file to create a cloned PDB in the CDB.


    Before starting this tutorial, you should:

    • Ensure that you have enough disk space to hold a second copy of the non-CDB.
    • Install Oracle Database 12c.
    • Create a non-CDB and a CDB.

The environment used in the development of this tutorial is as follows:

  • ORACLE_HOME: /u01/app/oracle/product/12.1.0
  • TNS Listener port: 1521
  • Container databases:
    • SID: cdb1
    • SID: cdb2
  • Pluggable databases (in cdb1):
    • pdb1
    • pdb2

Setting the Non-CDB to Read-Only Mode

    Set the ORACLE_SID variable to noncdb.

    . oraenv
    [enter noncdb at the prompt]

    Connect to the noncdb instance.

    sqlplus / as sysdba

    If the instance is up, shut it down.

    shutdown immediate

    Start the database in mount exclusive mode.

    startup mount exclusive

    Open the database in read-only mode.

    alter database open read only;

Generating a Pluggable Database Manifest File for the Non-CDB

    Execute the dbms_pdb.describe procedure to generate the manifest file.

    exec dbms_pdb.describe(pdb_descr_file=>'/u01/app/oracle/oradata/noncdb/noncdb.xml');

    Shut down the noncdb instance to prepare to copy the data files in the next section.

    shutdown immediate


Creating and Plugging in a PDB into cdb2 by Using the noncdb Manifest File

    Connect to cdb2. If it is down, start it.

    . oraenv
    [enter cdb2 at the prompt]

    sqlplus / as sysdba

    Create a PDB by using the noncdb manifest file. Use the file_name_convert parameter to place the copied data files in a different location.

    create pluggable database exnoncdb
    as clone
    using '/u01/app/oracle/oradata/noncdb/noncdb.xml'

    Finalize the plug-in by opening the new PDB, closing it, and then reopening it.

    alter pluggable database exnoncdb open;

    alter pluggable database exnoncdb close;

    alter pluggable database exnoncdb open;


Converting to the PDB Data Dictionary (Optional)

    At this point, the new PDB cloned from the non-CDB will work fine. However, if you need to upgrade the CDB later, you should run the noncdb_to_pdb.sql script to remove superfluous non-CDB data from the PDB data dictionary. This step is optional in this tutorial, but it is recommended in a production environment.

    Connect to the new exnoncdb PDB.

    sqlplus sys/oracle@localhost:1521/exnoncdb as sysdba

    Run $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql. This script can take a long time to run (more than 20 minutes).


Resetting Your Environment

    Perform the following steps to reset your environment prior to repeating the activities covered in this OBE or starting another OBE.

    Close the newly created exnoncdb PDB.

    . oraenv

    [enter cdb2 at the prompt]

    sqlplus / as sysdba

    alter pluggable database exnoncdb close immediate;

    Delete the exnoncdb PDB and its data files.

    drop pluggable database exnoncdb including datafiles;


    In this tutorial, you learned how to clone and plug a non-CDB as a PDB into a CDB.



    • Adapted from a lab created by Bryn Llewellyn, Oracle Product Manager

To help navigate this Oracle by Example, note the following:

Hiding Header Buttons:
Click the Title to hide the buttons in the header. To show the buttons again, simply click the Title again.
Topic List Button:
A list of all the topics. Click one of the topics to navigate to that section.
Expand/Collapse All Topics:
To show/hide all the detail for all the sections. By default, all topics are collapsed
Show/Hide All Images:
To show/hide all the screenshots. By default, all images are displayed.
To print the content. The content currently displayed or hidden will be printed.

To navigate to a particular section in this tutorial, select the topic from the list.