Clone a PDB within the same CDB (local / hot clone)
OracleMultitenantCommand
-- Hot clone prerequisites: local undo + ARCHIVELOG
SELECT property_value AS local_undo
FROM database_properties WHERE property_name = 'LOCAL_UNDO_ENABLED';
SELECT log_mode FROM v$database;
CREATE PLUGGABLE DATABASE <new_pdb> FROM <pdb>
FILE_NAME_CONVERT = ('/<pdb>/', '/<new_pdb>/');
-- OMF/ASM: CREATE PLUGGABLE DATABASE <new_pdb> FROM <pdb> CREATE_FILE_DEST = '+DATA';
ALTER PLUGGABLE DATABASE <new_pdb> OPEN;
SELECT name, open_mode FROM v$pdbs WHERE name = UPPER('<new_pdb>');What it does
Creates a new PDB in the same CDB by copying the datafiles of the source PDB; with local undo and ARCHIVELOG it can run while the source is open read-write (hot clone).
When to use it
To create a test/development copy of a production PDB, rehearse an upgrade or patch, or take a quick copy before a risky change.
Caution
The copy generates extra I/O on the source and needs as much space as the source on the target. In shared undo mode or in NOARCHIVELOG the source must be READ ONLY (19c documentation). The clone contains production data: check masking, DB links, jobs (DBMS_SCHEDULER) and connections to external systems before opening it.
Related
- Create a new PDB from PDB$SEED
- Clone a PDB from another CDB over a DB link (remote clone)
- Unplug a PDB and plug it into another (or the same) CDB
- Open PDBs and keep them open across CDB restarts (SAVE STATE)
- Set per-PDB CPU, memory, I/O and storage limits
- Confirm which container you are in and query all PDBs from the root (CDB_ / CONTAINERS)