Mastering Oracle 19c Hot Clone: A Complete Step‑by‑Step Guide
This article explains the background of Oracle 19c hot clone, lists the prerequisites, details the three‑phase cloning process, provides exhaustive local, remote, subset and refreshable PDB scenarios with exact SQL commands, highlights common errors and their solutions, and concludes with best‑practice recommendations.
Background
Oracle 11g has entered extended support, while Oracle 19c is the final stable release of the 12c family and is widely used in production. The author’s team evaluated the hot‑clone feature of Oracle 19c during a deployment and upgrade project.
Prerequisites for Using Hot Clone
Oracle version : 12c R2 or later is required. In 12c R1 the source PDB must be shut down, which is a "cold clone".
Local undo : If the database uses shared undo, it must be converted to local undo. This can be done in upgrade mode with ALTER DATABASE LOCAL UNDO ON.
Working Principle of Hot Clone
Hot clone follows three stages, similar to an RMAN backup/restore:
Stage 1 (t0‑t1) : The source PDB’s data files are read block‑by‑block and copied to the target PDB. Changes made to already‑copied blocks during this interval may cause physical inconsistency.
Stage 2 : Changes made to the source PDB between t0 and t1 are applied to the target PDB, making the target a physical copy of the source at t1, but it may contain both committed and uncommitted transactions.
Stage 3 : At t1 all committed transactions are retained, while uncommitted ones are rolled back, resulting in a transaction‑consistent target PDB. The key to hot clone is the use of local undo.
Common Application Scenarios
1. Local Clone
1) Clone via seed template
SYS@ora19c>SHOW PDBS; CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ---------------- -------------- ----------
2 PDB$SEED READ ONLY NOCheck the seed template datafiles:
SYS@ora19c>SELECT CON_ID, NAME FROM V$DATAFILE WHERE CON_ID=2; CON_ID NAME
---------- ------------------------------------------------------------
2 /u01/app/oracle/oradata/ORA19C/pdbseed/system01.dbf
2 /u01/app/oracle/oradata/ORA19C/pdbseed/sysaux01.dbf
2 /u01/app/oracle/oradata/ORA19C/pdbseed/undotbs01.dbfCreate a new PDB from the seed template (no operation on the source is required):
SYS@ora19c>CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb_mgr1 IDENTIFIED BY oracle
ROLES=(DBA) FILE_NAME_CONVERT=('/u01/app/oracle/oradata/ORA19C/pdbseed','/u01/app/oracle/oradata/ORA19C/pdb1');
Pluggable database created.Open and verify the new PDB:
SYS@ora19c>SHOW PDBS; CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTEDOpen it for read/write:
SYS@ora19c>ALTER PLUGGABLE DATABASE pdb1 OPEN;
Pluggable database altered.2) Clone an existing PDB
Create a user in the new PDB to verify that users and privileges are cloned:
SYS@ora19c>ALTER SESSION SET CONTAINER=pdb1;
SYS@ora19c>CREATE USER u1 IDENTIFIED BY oracle;
User created.
SYS@ora19c>GRANT CONNECT, RESOURCE TO u1;
Grant succeeded.Clone the existing PDB:
SYS@ora19c>CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 FILE_NAME_CONVERT=('pdb1','pdb2');
Pluggable database created.Open and verify:
SYS@ora19c>ALTER PLUGGABLE DATABASE pdb2 OPEN;
Pluggable database altered.2. Remote Clone
Remote cloning copies a PDB from a source CDB to a target CDB without stopping the source.
Grant the source user the required privilege:
SYS@ora19c>GRANT CREATE PLUGGABLE DATABASE TO pdb_mgr1;
Grant succeeded.Create a public database link in the target CDB:
SYS@ora19c>CREATE PUBLIC DATABASE LINK lk_pdb1 CONNECT TO pdb_mgr1 IDENTIFIED BY oracle
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.101)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=pdb1)))';
Database link created.Perform the remote clone:
SYS@ora19c>CREATE PLUGGABLE DATABASE pdb1_r FROM pdb1@lk_pdb1
FILE_NAME_CONVERT=('pdb1','pdb1_r');
Pluggable database created.Open and verify the remote clone:
SYS@ora19c>ALTER PLUGGABLE DATABASE pdb1_r OPEN;
Pluggable database altered.3. Remote Non‑CDB Clone
Clone a non‑CDB source to a new PDB in a CDB:
SYS@ora19c>CREATE PUBLIC DATABASE LINK lk_noncdb CONNECT TO system IDENTIFIED BY oracle
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.101)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=noncdb)))';
Database link created. SYS@ora19c>CREATE PLUGGABLE DATABASE noncdb_pdb FROM noncdb@lk_noncdb
FILE_NAME_CONVERT=('/u01/app/oracle/oradata/NONCDB','/u01/app/oracle/oradata/ORA19C/noncdb_pdb');
Pluggable database created.Open and verify:
SYS@ora19c>ALTER PLUGGABLE DATABASE noncdb_pdb OPEN;
Pluggable database altered.Special Scenarios
1. Subset Clone (User Tablespaces)
From 12.1.0.2 onward Oracle supports cloning only selected user tablespaces. USER_TABLESPACES=ALL – default, clones all tablespaces. USER_TABLESPACES=NONE – excludes all user tablespaces. USER_TABLESPACES=('ts1') – clones only ts1. USER_TABLESPACES=ALL EXCEPT ('ts1') – clones everything except ts1.
Create tablespaces in the source:
SYS@ora19c>CREATE TABLESPACE ts1 DATAFILE '/u01/app/oracle/oradata/ORA19C/pdb1/ts1.dbf' SIZE 10M;
Tablespace created.
SYS@ora19c>CREATE TABLESPACE ts2 DATAFILE '/u01/app/oracle/oradata/ORA19C/pdb1/ts2.dbf' SIZE 10M;
Tablespace created.Clone only ts1:
SYS@ora19c>CREATE PLUGGABLE DATABASE pdb1_z FROM pdb1
FILE_NAME_CONVERT=('pdb1','pdb1_z') USER_TABLESPACES=('ts1');
Pluggable database created.Open and verify that only ts1 files exist in the new PDB.
2. Refreshable PDB for Data Migration
A refreshable PDB builds on hot‑clone and allows periodic incremental updates.
Source must have ARCHIVELOG mode and local undo enabled.
Refresh can be manual or scheduled; the target must be in MOUNTED state.
During refresh the target can be READ ONLY; to keep it READ WRITE set REFRESH MODE NONE (cannot be changed later).
Refresh uses a database link.
Create a DB link in the target:
SYS@ora19c>CREATE PUBLIC DATABASE LINK lk_pdb1 CONNECT TO pdb_mgr1 IDENTIFIED BY oracle
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.101)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=pdb1)))';
Database link created.Create the refreshable PDB:
SYS@ora19c>CREATE PLUGGABLE DATABASE pdb1_ref FROM pdb1@lk_pdb1
FILE_NAME_CONVERT=('pdb1','pdb1_ref') REFRESH MODE EVERY 60 MINUTES;
Pluggable database created.When the source is set to READ ONLY, refresh the target:
SYS@ora19c>ALTER PLUGGABLE DATABASE pdb1_ref REFRESH;
Pluggable database altered.If the target is in REFRESH mode, it can only be opened READ ONLY or stay MOUNTED. Attempting to open READ WRITE yields ORA‑65341.
Common Errors and Solutions
ORA‑65040 : Operation not allowed from within a pluggable database. Solution: ALTER SESSION SET CONTAINER=CDB$ROOT; ORA‑17628 / ORA‑01031 : Insufficient privileges. Solution: Grant CREATE PLUGGABLE DATABASE to the source user.
ORA‑19504 / ORA‑27038 : File already exists. Solution: Ensure correct file‑name mapping and that target directories do not contain existing files.
ORA‑65005 : Invalid file name pattern. Solution: Verify the path and case sensitivity.
ORA‑01578 / ORA‑01110 / ORA‑26040 : Data block corrupted because the source lacked ARCHIVELOG mode. Solution: Enable ARCHIVELOG before creating a refreshable PDB.
Conclusion
Hot clone in Oracle 19c is a mature feature that can be used for rapid creation of full or subset copies of a PDB, as well as for low‑downtime migrations. It minimizes business interruption and is relatively simple, but it requires proper configuration of local undo, archive logging, and correct file‑mapping to avoid common pitfalls.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
