Migrating PDBs with Near-Zero Downtime: Refreshable Clones and PDB Relocation in Oracle Database 23ai — Runbook
Updated: Oct 24
Environment used in this runbook:
Source: CDB SRCCDB on host old-host
Target: CDB CDB23 on host new-host
Version and platform: both Oracle Database 23ai, same endian platform (for example Linux → Linux)
PDB to move: SALESPDB
Cross-platform moves: cross-platform and cross-endian moves are covered by the XTTS runbook
Upgrades: covered by the AutoUpgrade runbook; a PDB cloned into a newer CDB must be upgraded after plug-in
Three ways to move a PDB — pick one
Method | Downtime | Best for |
Unplug / plug (.pdb archive or NOCOPY) | Full copy time | Small PDBs, shared storage, one-off moves |
Refreshable clone → cutover | Minutes (final refresh + open) | Large PDBs, rehearsals, you control the moment of cutover |
PDB relocation (RELOCATE) | Seconds; connections are forwarded | Same-network moves where you want Oracle to handle the switch |
All three need: a database link from the target CDB to the source CDB, compatible character sets, ARCHIVELOG mode and local undo on the source, and, if TDE is on, the keystore password or exported keys.
Step 1 — Prerequisites on the source CDB
SQL |
-- on SRCCDB (root) SELECT log_mode FROM v$database; -- ARCHIVELOG SELECT property_value FROM database_properties WHERE property_name = 'LOCAL_UNDO_ENABLED'; -- TRUE SELECT name, open_mode FROM v$pdbs WHERE name = 'SALESPDB';
-- common user the target will connect as CREATE USER c##clone_user IDENTIFIED BY "Clone#Pwd2026" CONTAINER = ALL; GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##clone_user CONTAINER = ALL; GRANT SYSOPER TO c##clone_user CONTAINER = ALL; -- required for RELOCATE |
Why: hot cloning while the source is open needs archived redo and local undo; CREATE PLUGGABLE DATABASE is the privilege that authorises remote cloning, SYSOPER allows relocation to close the source PDB.
Step 2 — Prerequisites on the target CDB
SQL |
-- on CDB23 (root) SELECT * FROM nls_database_parameters WHERE parameter IN ('NLS_CHARACTERSET','NLS_NCHAR_CHARACTERSET'); SHOW PARAMETER db_create_file_dest -- OMF makes file placement automatic SHOW PARAMETER max_pdbs
CREATE DATABASE LINK src_link CONNECT TO c##clone_user IDENTIFIED BY "Clone#Pwd2026" USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=old-host)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=srccdb)))';
SELECT * FROM dual@src_link; |
Why: the link points at the source CDB root service (not the PDB service). Character sets must be identical or the source must be a subset of the target (AL32UTF8 target is the safe choice). Check MAX_PDBS and licensing for the number of PDBs allowed.
Step 3 — Check plug-in compatibility before you spend copy time
SQL |
-- on the source, in the PDB: describe it into an XML file ALTER SESSION SET CONTAINER = salespdb; EXEC DBMS_PDB.DESCRIBE(pdb_descr_file => '/tmp/salespdb.xml'); |
Shell |
scp old-host:/tmp/salespdb.xml new-host:/tmp/ |
SQL |
-- on the target root SET SERVEROUTPUT ON DECLARE l_ok BOOLEAN; BEGIN l_ok := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/tmp/salespdb.xml', pdb_name => 'SALESPDB'); DBMS_OUTPUT.PUT_LINE(CASE WHEN l_ok THEN 'COMPATIBLE' ELSE 'NOT COMPATIBLE - see PDB_PLUG_IN_VIOLATIONS' END); END; / SELECT type, message, action FROM pdb_plug_in_violations WHERE name = 'SALESPDB' AND status <> 'RESOLVED'; |
Why: finds missing options, patch-level differences, parameter conflicts and character-set problems before the clone. WARNING rows are usually fine; ERROR rows must be fixed.
Method A — Refreshable clone with controlled cutover
Step A1 — Create the refreshable clone (source stays online)
SQL |
-- on CDB23 root CREATE PLUGGABLE DATABASE salespdb FROM salespdb@src_link REFRESH MODE EVERY 30 MINUTES KEYSTORE IDENTIFIED BY "TargetWallet#Pwd"; -- only if TDE is enabled on the target -- FILE_NAME_CONVERT = ('/u02/oradata/SRCCDB/SALESPDB','/u02/oradata/CDB23/SALESPDB') -- if no OMF |
Why: the initial copy runs over the DB link in parallel (PARALLEL 8 clause to control it); afterwards the clone is refreshed with the source's archived redo every 30 minutes (REFRESH MODE MANUAL if you prefer to trigger it). The source PDB remains fully read-write.
Step A2 — Use the clone while it syncs (optional)
SQL |
ALTER PLUGGABLE DATABASE salespdb OPEN READ ONLY; -- run smoke tests, compare row counts, test application connectivity to new-host ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE; ALTER PLUGGABLE DATABASE salespdb REFRESH; -- manual catch-up (must be closed) |
Why: a refreshable clone can be opened read-only between refreshes — perfect for rehearsing the cutover days in advance and for reporting offload. Refresh needs the PDB closed.
Monitor lag:
SQL |
SELECT p.name, p.refresh_mode, p.refresh_interval, p.last_refresh_scn FROM dba_pdbs p WHERE p.pdb_name = 'SALESPDB'; SELECT current_scn FROM v$database@src_link; -- compare with last_refresh_scn |
Step A3 — Cutover (downtime starts)
SQL |
-- 1. stop the application on old-host; on SRCCDB, block new work: ALTER SESSION SET CONTAINER = salespdb; ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE; ALTER PLUGGABLE DATABASE salespdb OPEN READ ONLY; -- final state of the source: read-only, redo complete
-- 2. on CDB23: final refresh and detach from the source ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE; ALTER PLUGGABLE DATABASE salespdb REFRESH; ALTER PLUGGABLE DATABASE salespdb REFRESH MODE NONE; -- becomes a normal PDB, irreversible ALTER PLUGGABLE DATABASE salespdb OPEN; ALTER PLUGGABLE DATABASE salespdb SAVE STATE; |
Why: putting the source read-only guarantees the last refresh captures everything. REFRESH MODE NONE converts the clone into an ordinary read-write PDB; from this point the two PDBs diverge, so decommission the source (Step 6).
Method B — PDB relocation (Oracle does the switch)
SQL |
-- on CDB23 root CREATE PLUGGABLE DATABASE salespdb FROM salespdb@src_link RELOCATE AVAILABILITY MAX KEYSTORE IDENTIFIED BY "TargetWallet#Pwd"; -- if TDE
ALTER PLUGGABLE DATABASE salespdb OPEN; |
Why: RELOCATE copies the PDB while the source stays open, then, at OPEN on the target, applies the final redo, closes and drops the source PDB, and — with AVAILABILITY MAX — keeps a listener forwarding entry so clients still connecting to old-host are redirected to new-host until they update their connect strings. Both CDBs should use the same listener/SCAN setup for the forwarding to work; in other cases use AVAILABILITY NORMAL and repoint the clients yourself.
Verify afterwards:
SQL |
SELECT name, open_mode FROM v$pdbs WHERE name = 'SALESPDB'; -- on CDB23: READ WRITE SELECT name FROM v$pdbs@src_link; -- SALESPDB gone from source ALTER PLUGGABLE DATABASE salespdb SAVE STATE; |
Method C — Unplug / plug (for completeness)
SQL |
-- source ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE; ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/u01/transfer/salespdb.pdb'; -- .pdb = zip of XML + datafiles DROP PLUGGABLE DATABASE salespdb KEEP DATAFILES;
-- target (after copying the file) CREATE PLUGGABLE DATABASE salespdb USING '/u01/transfer/salespdb.pdb' KEYSTORE IDENTIFIED BY "TargetWallet#Pwd"; ALTER PLUGGABLE DATABASE salespdb OPEN; |
Why: simplest mechanics, but the PDB is unavailable for the entire copy. With shared storage use the .xml manifest and NOCOPY to plug without copying files.
Step 4 — Post-move validation (all methods)
SQL |
ALTER SESSION SET CONTAINER = salespdb;
SELECT type, message, action FROM pdb_plug_in_violations WHERE name = 'SALESPDB' AND status <> 'RESOLVED'; SELECT owner, object_type, COUNT(*) FROM dba_objects WHERE status = 'INVALID' GROUP BY owner, object_type; @?/rdbms/admin/utlrp.sql
-- services and TNS SELECT name, network_name FROM dba_services; SELECT name, value FROM v$parameter WHERE name IN ('service_names','local_listener');
-- TDE: keys present? SELECT status, wallet_type FROM v$encryption_wallet; SELECT tablespace_name, encrypted FROM dba_tablespaces;
-- statistics still valid (same DB -> yes); refresh anyway if you changed storage |
Then: register the PDB services with the listener, update tnsnames.ora/connection pools, re-register with OEM / Data Safe / backup schedules, and take a full RMAN backup of the target CDB.
Step 5 — Application-level checks
Database links inside the PDB still point at old hosts? SELECT owner, db_link, host FROM dba_db_links;
Scheduler jobs that must run only on the primary copy: SELECT job_name, enabled FROM dba_scheduler_jobs; — disable them on the source before cutover to avoid double execution.
Directory objects with host paths: SELECT directory_name, directory_path FROM dba_directories;
Wallets for UTL_HTTP/SMTP, external tables, DBMS_NETWORK_ACL entries — all host-specific.
Step 6 — Decommission the source PDB
SQL |
-- on SRCCDB (Method A only; RELOCATE already dropped it) ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE; -- keep it for the fallback window, then: DROP PLUGGABLE DATABASE salespdb INCLUDING DATAFILES; DROP USER c##clone_user CASCADE; |
Why: two open copies of the same PDB with the same service names on one network is the classic "split brain" outage. Close first, drop later.
Timing guidance
PDB size | Initial copy (refreshable clone, 8 parallel, 10 GbE) | Cutover |
100 GB | ~10–20 min | < 2 min |
1 TB | ~2–3 h | 2–5 min |
10 TB | ~1 day | 5–15 min (last refresh + open) |
The copy runs while users work; only the cutover is downtime. Rehearse with Step A2.
Common errors
ORA-65035: unable to create pluggable database from SALESPDB → source PDB must be open or read-only; check LOCAL_UNDO_ENABLED and archivelog mode.
ORA-17628 / ORA-19505 during copy → file placement on the target: set DB_CREATE_FILE_DEST or FILE_NAME_CONVERT.
ORA-65136: PDB CLONE with REFRESH MODE requires ... → source in NOARCHIVELOG or missing local undo.
ORA-46697: Keystore password required → add KEYSTORE IDENTIFIED BY on a TDE-enabled target.
ORA-65177: cannot open PDB ... refreshable clone → refreshable clones open read-only only; run REFRESH MODE NONE first for read-write.
Plug-in violation "PDB's version does not match CDB's version" → target CDB is newer/patched differently: run datapatch -verbose (RU difference) or AutoUpgrade (release difference) after plugging in.
Comments