Cloning Pluggable Databases



    This tutorial covers the steps required to clone a pluggable database (PDB) from a container database (CDB) into the same CDB.

    Time to Complete

    Approximately 15 minutes


    You can copy a source PDB from a CDB and plug the copy into the same CDB or into another CDB. This capability is suitable for the following situations:

    • You want to test the application patch of your production PDB. You first clone your production application in a cloned PDB, patch the cloned PDB, and test it.
    • You want to diagnose performance issues or perform performance regression tests on your application. Because you cannot perform this operation in parallel with the production in the same database, you clone the PDB into another CDB.


In this tutorial, you will use SQL*Plus to perform a PDB cloning operation within the same CDB.
Note: If you want to clone a PDB from a CDB into another CDB, you identify the source CDB by creating a database link to it from the CDB in which you want to create the clone.


Before starting this tutorial, you should:

    • Ensure that you have enough disk space to hold a complete clone of the PDB.
    • Install Oracle Database 12c.
    • Create one CDB with one PDB in it.

    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

Preparing the Source PDB to Clone

    In this section, you prepare the source PDB to be cloned and the target new PDB to be created.

    Setting the Source PDB to READ ONLY Mode

      Use SQL*Plus to close the PDB that you want to clone.

      . oraenv

      [enter cdb1 at the prompt]

      sqlplus / as sysdba

      alter pluggable database pdb1 close immediate;

      Open the PDB that you want to clone in READ ONLY mode.

      alter pluggable database pdb1 open read only;


    Creating a Directory for the New Clone PDB

      Navigate to /stage or wherever you can find enough available space to store the data files for pdb1_clone.

      cd /stage

      Create a subdirectory called pdb1_clone under /stage. Note: You may need to log in as root to create the subdirectory, and then change the owner to oracle and the group to oinstall.

      mkdir pdb1_clone

    Configuring OMF to the Directory of the Clone PDB

      Use SQL*Plus to connect as sysdba and set the following parameter:

      sqlplus / as sysdba
      alter system set db_create_file_dest='/stage/pdb1_clone';

Cloning the PDB Within the CDB

    Use SQL*Plus to clone the PDB within the same CDB.

    Execute the following statement:

    create pluggable database pdb1_clone from pdb1;

    Open the new pdb.

    alter pluggable database pdb1_clone open;

    Connect to the new pdb.

    connect system/oracle@localhost:1521/pdb1_clone;

    Verify that you are connected to the new PDB:

    show con_name

Setting the Source PDB Back to Open Mode

    Connect to the root in the CDB.

    connect / as sysdba

    alter session set container=cdb$root;

    Execute the following statement:

    alter pluggable database pdb1 close immediate;

    Open the source pdb.

    alter pluggable database pdb1 open;

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 clone PDB.

    alter pluggable database pdb1_clone close immediate;

    Delete the clone PDB and its data files.

    drop pluggable database pdb1_clone including datafiles;


    In this tutorial, you learned how to:

    • Prepare an existing PDB to be cloned within the same CDB
    • Clone the PDB



    Curriculum Developers: Dominique Jeunot, Jean-Francois Verrier

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

Hide Header Buttons:
Click the title to hide the buttons in the header. To show the buttons again, click the title again.
Topic List:
Click a topic to navigate to that section.
Expand All Topics:
Click the button to show or hide the details for the sections. By default, all topics are collapsed.
Hide All Images:
Click the button to show or hide the screenshots. By default, all images are displayed.
Click the button to print the content. The content that is currently displayed or hidden is printed.

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