DBAtlas · Database operations atlas

Clone a PDB within the same CDB (local / hot clone)

OracleMultitenant

Command

-- 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.

Open in DBAtlas →

Related