Hot clone pdb same container


PDBs can be hot cloned, i.e. you don’t need to put the source PDB in read-only for cloning 
so that it can be cloned to a CDB online. In Oracle, a pluggable database can be cloned only if it is read-only.

SQL> select name, cdb from v$database;

NAME CDB
--------- ---
CDBISTDB YES

SQL> col name for a25
SQL> select con_id, name, open_mode from v$pdbs;

CON_ID NAME OPEN_MODE
---------- ------------------------- ----------
2 PDB$SEED READ ONLY
3 PDBISTDB READ WRITE

SQL> col name for a80
SQL> select name from v$datafile where con_id = 3;

NAME
--------------------------------------------------------------------------------
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/system.272.1041127527
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/sysaux.273.1041127529
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/undotbs1.271.1041127527
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/users.275.1041127535

ASMCMD> ls
SYSAUX.258.1041127041
SYSTEM.257.1041127005
UNDOTBS1.259.1041127065
USERS.260.1041127067
ASMCMD> pwd
+DATA/CDBISTDB/DATAFILE

Using the CREATE PLUGGABLE DATABASE ... FROM command we will clone the existing PDB (PDBISTDB) to

create a new PDB (PDBCLONE) in the same container database (CDB$ROOT).

This statement copies the files associated with the source PDB to a new location and associates the files with the target PDB.


[oracle@dm10db11 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jun 6 09:09:39 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle. All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBISTDB READ WRITE NO
SQL>
SQL>
SQL> create pluggable database PDBCLONE from PDBISTDB;

Pluggable database created.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBISTDB READ WRITE NO
4 PDBCLONE MOUNTED
SQL>
SQL> alter pluggable database PDBCLONE open read write;

Pluggable database altered.

SQL> col name for a80
SQL> select name from v$datafile where con_id = 3;

NAME
--------------------------------------------------------------------------------
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/system.272.1041127527
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/sysaux.273.1041127529
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/undotbs1.271.1041127527
+DATA/CDBISTDB/A6439189E16E2715E0537C040A0A119E/DATAFILE/users.275.1041127535

SQL> select name from v$datafile where con_id = 4;

NAME
--------------------------------------------------------------------------------
+DATA/CDBISTDB/A76324BE10F43BD7E0537C040A0A81B5/DATAFILE/system.277.1042362651
+DATA/CDBISTDB/A76324BE10F43BD7E0537C040A0A81B5/DATAFILE/sysaux.279.1042362651
+DATA/CDBISTDB/A76324BE10F43BD7E0537C040A0A81B5/DATAFILE/undotbs1.278.1042362651
+DATA/CDBISTDB/A76324BE10F43BD7E0537C040A0A81B5/DATAFILE/users.276.1042362651

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBISTDB READ WRITE NO
4 PDBCLONE READ WRITE NO
Previous
Next Post »

2 comments

Click here for comments
Anonymous
admin
June 9, 2021 at 10:14 PM ×

FYI, if you have an encryption wallet defined you have to use this syntax...

create pluggable database XTEST2 from XTEST1 keystore identified by "wallet pswd here";

Reply
avatar