Clone an Oracle pluggable database

There are multiple methods of cloning a database.  Before 12c this was slightly more time-consuming.  With 12c, and later, Pluggable Databases (PDB) this process is streamlined.

This short post will be helpful if you either:

You of course need to ensure that you have enough disk space to hold a complete clone of the PDB.

First set the environment and connect to the container which contains the PDB you want to clone.

export ORACLE_SID=cdb1

sqlplus / as sysdba

Next, open the source PDB you want to clone into READ ONLY mode

ALTER PLUGGABLE DATABASE PRODPDB CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE PRODPDB OPEN READ ONLY;

Next, create a new PDB.  In this example, we are calling our new PDB “TESTPDB”

CREATE PLUGGABLE DATABASE TESTPDB FROM PRODPDB;

Finally re-open your production database

ALTER PLUGGABLE DATABASE PRODPDB CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE PRODPDB OPEN;

There are other ways of cloning a PDB.  For example, creating an XML schema.  Above is one way to get the job done.