Skip to main content

Clone PDB in same container

We can clone a pluggable database from existing PDB ( PROD), residing on the same container.


1. First start the PDB in read only , which needs to be cloned.

SQL> select name,open_mode from v$pdbs;


NAME OPEN_MODE

------------------------------ ----------

PDB$SEED READ ONLY

ORCL READ WRITE

PROD READ WRITE



SQL> alter session set container=PROD;


Session altered.


SQL> select file_name from dba_data_files;


FILE_NAME

--------------------------------------------------------------------------------

/home/oracle/app/oracle/oradata/cdb1/prod/system01.dbf

/home/oracle/app/oracle/oradata/cdb1/prod/sysaux01.dbf


SQL> show con_name


CON_NAME

------------------------------

PROD



SQL> shutdown immediate;

Pluggable Database closed.


SQL> startup open read only

Pluggable Database opened.


2. Connect to the container and clone the pluggable:

-- connect to container CDB1


SQL> conn sys/oracle@cdb1 as sysdba

Connected.

SQL> show con_name


CON_NAME

------------------------------

CDB$ROOT


-- Clone pluggable


SQL> create pluggable database PROD_CL from PROD FILE_NAME_CONVERT=('/home/oracle/app/oracle/oradata/cdb1/prod','/home/oracle/app/oracle/oradata/cdb1/PROD_CL');


Pluggable database created.


3. Now make the existing PDB ( PROD) from read only to read write:

SQL> select name,open_mode from v$pdbs;


NAME OPEN_MODE

------------------------------ ----------

PDB$SEED READ ONLY

ORCL READ WRITE

PROD READ ONLY

PROD_CL MOUNTED


SQL> alter session set CONTAINER=PROD;


Session altered.


SQL> shutdown immediate;

Pluggable Database closed.

SQL> startup

Pluggable Database opened.

SQL> show con_name



4. Start the new cloned PDB( PROD_CL)

SQL> alter session set container=PROD_CL;


Session altered.


SQL> startup

Pluggable Database opened.



SQL> conn sys/oracle@cdb1 as sysdba

Connected.

SQL> select name,open_mode from v$pdbs;


NAME OPEN_MODE

------------------------------ ----------

PDB$SEED READ ONLY

ORCL READ WRITE

PROD READ WRITE

PROD_CL READ WRITE


Popular posts from this blog

Clone PDB to another CDB

Actually, we can clone a PDB from any PDB over the network, as long as they are connected and compatible. Step 1. Create a database link to the source CDB. SQL> create database link link_to_test1 connect to system identified by oracle using 'finanpdb'; Database link created. Step 2: Clone the target PDB from the remote database via a database link. SQL> create pluggable database finance_pdb from finanpdb@link_to_test1 file_name_convert=('/u01/app/oracle/oradata/orcl/FINANPDB','/u01/app/oracle/oradata/orcl/FINANCE_PDB'); Pluggable database created. Parallel Creation If you want to clone a big database, say 10 TB from the source, you can add some degrees of parallelism on it. SQL> create pluggable database finance_pdb from finanpdb@link_to_test1 file_name_convert=('/u01/app/oracle/oradata/orcl/FINANPDB','/u01/app/oracle/oradata/orcl/FINANCE_PDB') parallel 8; Pluggable database created. Step 3: Open the target PDB to READ WRITE. SQL> alt