DBAtlas · Database operations atlas

Clone a PDB from another CDB over a DB link (remote clone)

OracleMultitenant

Command

-- 1) In the SOURCE CDB, a common user:
CREATE USER c##clone_user IDENTIFIED BY "<password>" CONTAINER = ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##clone_user CONTAINER = ALL;

-- 2) In the TARGET CDB root, DB link and test:
CREATE DATABASE LINK clone_link
  CONNECT TO c##clone_user IDENTIFIED BY "<password>"
  USING '//<source_host>:1521/<source_cdb_service>';
SELECT * FROM dual@clone_link;

-- 3) Clone and open:
CREATE PLUGGABLE DATABASE <new_pdb> FROM <pdb>@clone_link
  FILE_NAME_CONVERT = ('/<pdb>/', '/<new_pdb>/');
ALTER PLUGGABLE DATABASE <new_pdb> OPEN;

-- 4) Violations (version, options, parameters, patches):
SELECT name, cause, type, message
FROM   pdb_plug_in_violations
WHERE  name = UPPER('<new_pdb>') AND status <> 'RESOLVED';

What it does

Copies a PDB from the source CDB to the target CDB over the network through a DB link; no intermediate files or unplug needed.

When to use it

To move a PDB to another server/CDB, create a test copy of production on a separate server, or move to a CDB with a newer release.

Caution

The source and target CDBs must be compatible in endianness, character set (or target AL32UTF8) and options; a PDB cloned to a newer release opens RESTRICTED at first and needs datapatch/upgrade. Drop the DB link and the common user when the clone is finished. Hot clone requires local undo + ARCHIVELOG on the source.

Open in DBAtlas →

Related