Cloning a PDB from Oracle 12.1 to Oracle 12.2

Is cloning a PDB from Oracle 12.1 to Oracle 12.2 possible?

A colleague raised this question recently. And a customer did ask me the same question a few days before at a user group conference. There are several ways to move a PDB from Oracle 12.1. to 12.2. But the documentation does not say explicitly if you can do a cloning operation between Oracle 12.1 and 12.2.

Cloning a PDB from Oracle 12.1 to Oracle 12.2

You can clone a non-CDB and make it a PDB but you need to run noncdb_to_pdb.sql afterwards. When I wrote this blog post, Oracle 12.2 was not available yet. Now, as it is available, I will clone a PDB between different Oracle versions.

You can redo the same steps by yourself with our Hands-On Lab environment if you have no Multitenant environment to play with.

Cloning a PDB from Oracle 12.1 to Oracle 12.2

Clone a PDB from Oracle (CDB1) to Oracle (CDB2)

Requirements and Prerequisites

Please see the description in the documentation:

The important topic to mention is whether the source CDB has local undo on or not. When cloning from an Oracle database there’s no local undo – and therefore the source PDB has to remain in read-only mode during the entire operations.

Step by Step

At first, you must prepare the source PDB for the cloning.

Oracle – CDB1
  1. Login as SYS as SYSDBA to the CDB$ROOT container
    sqlplus / as sysdba
  2. Create a test PDB first, then open it:
    create pluggable database pdb1
    admin user adm identified by adm
    file_name_convert=('/u02/oradata/CDB1/pdbseed', '/u02/oradata/CDB1/pdb1');
    alter pluggable database PDB1 open;
  3. Switch into the new PDB and prepare a cloning user.
    Afterwards the PDB has to be set into read-only mode due to the non-existence of local undo in Oracle

    alter session set container=PDB1;
    create user hugo identified by hugo;
    grant create session, create pluggable database to hugo;
    alter pluggable database PDB1 close;
    alter pluggable database pdb1 open read only;
Oracle – CDB2
  1. Make sure you’ll have TNS setup correctly so PDB1 is visible and reachable. Then create a database link from the destination CDB into the source PDB1 and initiate the cloning operation.
    create database link sourcedblink
    connect to hugo identified by hugo using 'PDB1';
    create pluggable database CDB2_PDB1 from pdb1@sourcedblink
    file_name_convert=('/u02/oradata/CDB1/pdb1', '/u02/oradata/CDB2/pdb1');
    alter pluggable database CDB2_PDB1 open;
  2. At this point you’ll see that the PDB1 will open but signal the following error:
    Warning: PDB altered with errors.
    Query PDB_PLUG_IN_VIOLATIONS to learn more about the error:

    column name format a9
    column cause format a20
    column message format a50
    column action format a36
    set line 200
    set pages 1000
    select name, cause, message, action from PDB_PLUG_IN_VIOLATIONS
     where status<>'RESOLVED' and CON_ID=3
     order by time;

    This will result in the following output:

    NAME       CAUSE               MESSAGE                                            ACTION
    ---------- ------------------- -------------------------------------------------- ------------------------------------
    CDB2_PDB1  VSN not match       PDB's version does not match CDB's version: PDB's  Either upgrade the PDB or reload the
                                   version CDB's version      components in the PDB.
  3. You need to upgrade the CDB2_PDB1 now. In case you haven’t run preupgrade.jar before cloning the PDB you should now switch PDB1 in CDB1 into read-write mode again and execute preupgrade.jar within the source environment against it:
    java -jar $OH12/rdbms/admin/preupgrade.jar -c "PDB1" TEXT TERMINAL

    Fix potential issues and execute the preupgrade_fixups.sql in the destination environment.
    Afterwards you can initiate the upgrade of the pluggable database.

    cd $ORACLE_HOME/rdbms/admin
    $ORACLE_HOME/perl/bin/perl -c "CDB2_PDB1" -l /home/oracle catupgrd.sql

    Run the postupgrade_fixups.sql once the upgrade is completed.
    For further details on how to upgrade a PDB please see Upgrade PDBs – One at a time.
    And finally, I don’t know what the ACTION “… or reload the components in the PDB” means.


Share this:

6 thoughts on “Cloning a PDB from Oracle 12.1 to Oracle 12.2

  1. Hi Mike,
    when i try to create a new PDB On Version 12.2 from version 12.1 i get the follwing error:

    SQL> create pluggable database PDB2 from pdb1l@pdb121_link;
    create pluggable database PDB2 from pdb1l@pdb121_link
    ERROR at line 1:
    ORA-17628: Oracle error 17630 returned by remote Oracle server
    ORA-17630: Mismatch in the remote file protocol version client server

    Do you have any idea was getting wrong?

    Best Regards

    • Hi Kai,

      I think the TNS setup is the crucial point. When I tried the test blindly I hit the same error as you do.
      Can you please verify that your TNS setup is done correctly and that you could connect from both environments on the command prompt with:
      $ sqlplus “hugo/oracle@pdb1”

      It’s is also important to follow the “clone user” approach. Not 100% sure anymore but I believe with the out-of-the-box SYSTEM user I saw the error as well. But not 100% anymore …


  2. Downloaded latest Hands on Lab but I’m running into this error when running the command preupgrade.jar “file name too long”. Deleted virtual box image and started with fresh image but still running into same error.

    • Sam,

      sorry for that – this is credited to the old VBox image on OTN. Roy will take care and exchange it as soon as possible (but may take a few days).


Leave a Reply

Your email address will not be published. Required fields are marked *

* Checkbox to comply with GDPR is required


I agree

This site uses Akismet to reduce spam. Learn how your comment data is processed.