Friday, September 3, 2021

Pluggable Database Cloning on Local Host (Local CDB)

 Cloning a pluggable database locally or remotely has become a routine task for DBAs. Different DBAs use different methods to clone a pluggable database. The cloning may be needed on the local host where source pluggable database exists, or requirement could be to clone it on a different host. In this article, I will explain how to clone a pluggable database on the local host (local container database). Click here to learn about how to clone a pluggable database from a remote host using database link.

Cloning a PDB on the host (or local container database) is very easy and it only requires a single command to be executed. First, you may look at the currently available PDBs and select which one you want to clone.

SQL> show pdbs

    
CON_ID CON_NAME                       OPEN MODE       RESTRICTED
---------- ------------------------------ ---------- --------------------------------------
         2 PDB$SEED                                 READ ONLY       NO
         3 PDB1                                           READ WRITE      NO

 

If you want to clone PDB1 as PDB2, you will execute following command.

SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1;
 

Pluggable database created.
 

SQL> ALTER PLUGGABLE DATABASE pdb2 OPEN;

Pluggable database altered.
 

SQL> show pdbs
 

    CON_ID CON_NAME                       OPEN MODE       RESTRICTED
---------- ------------------------------ ---------- --------------------------------------
         2 PDB$SEED                                 READ ONLY       NO
         3 PDB1                                           READ WRITE      NO
         4 PDB2                                           READ WRITE      NO

 There are several parameters that can be used with CREATE PLUGGABLE DATABASE command. For example, if you want to specify a location for the destination datafiles, you will use FILE_NAME_CONVERT parameter, which is even mandatory if you are not using ASM or OMF.

SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 FILE_NAME_CONVERT= ('d:\app\oracle\oradata\salman12c\pdb1\','d:\app\oracle\oradata\salman12c\pdb2\');
 

Pluggable database created.
 

SQL> ALTER PLUGGABLE DATABASE pdb2 OPEN;
 

Pluggable database altered
 

SQL> show pdbs
 

    CON_ID CON_NAME                       OPEN MODE       RESTRICTED
---------- ------------------------------ ---------- --------------------------------------
         2 PDB$SEED                                 READ ONLY       NO
         3 PDB1                                           READ WRITE      NO
         4 PDB2                                           READ WRITE      NO

 
SQL> alter pluggable database pdb2 open;
 

Pluggable database altered.

 Even if you are able to open the new PDB successfully, still it is good to check PDB_PLUG_IN_VIOLATIONS for any errors or warnings, and resolve them before handing over to end users.

No comments:

Post a Comment

Popular Posts - All Times