Use the DUPLICATE command to duplicate a PDB to an existing CDB.

To duplicate a PDB to an existing CDB:

  • Ensure that the required prerequisites are met.
  • Review the limitations of duplicating a PDB to an existing CDB
  • Create the directories that store the duplicate database files on the destination CDB
  • Establish Oracle net connectivity between the source CDB and the destination CDB
  • Duplicate the PDB by using the DUPLICATE PLUGGABLE DATABASE command.

In this scenario, we have 2 CDBs

  • CDB18C which contains two PDBs
  • NEWCDB which is empty CDB

After the creating the connection between both the CDBs, we can run RMAN command

[oracle@18c ~]$ rman target sys/sys@CDB18C auxiliary sys/sys@NEWCDB

Recovery Manager: Release 18.0.0.0.0 - Production on Mon Apr 23 16:13:52 2018
Version 18.1.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.

connected to target database: CDB18C (DBID=297354551)
connected to auxiliary database: NEWCDB (DBID=63374299)

RMAN>

Now run DUPLICATE PLUGGABLE DATABASE

RMAN> DUPLICATE PLUGGABLE DATABASE PDB18C2 TO NEWCDB DB_FILE_NAME_CONVERT('CDB18C','NEWCDB') FROM ACTIVE DATABASE SECTION SIZE 400M;

Starting Duplicate PDB at 23-APR-18
using channel ORA_AUX_DISK_1
current log archived

contents of Memory Script:
{
set newname for datafile 13 to
"/u01/app/oracle/oradata/NEWCDB/PDB18C2/system01.dbf";
set newname for datafile 14 to
"/u01/app/oracle/oradata/NEWCDB/PDB18C2/sysaux01.dbf";
set newname for datafile 15 to
"/u01/app/oracle/oradata/NEWCDB/PDB18C2/undotbs01.dbf";
set newname for datafile 16 to
"/u01/app/oracle/oradata/NEWCDB/PDB18C2/users01.dbf";
restore
from nonsparse section size
400 m clone foreign pluggable database
"PDB18C2"
from service 'CDB18C' ;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 23-APR-18
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 13 to /u01/app/oracle/oradata/NEWCDB/PDB18C2/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 14 to /u01/app/oracle/oradata/NEWCDB/PDB18C2/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 15 to /u01/app/oracle/oradata/NEWCDB/PDB18C2/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 16 to /u01/app/oracle/oradata/NEWCDB/PDB18C2/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 23-APR-18
current log archived

contents of Memory Script:
{
set archivelog destination to '/u01/app/oracle/oradata/NEWCDB/PDB18C2';
restore clone force from service 'CDB18C'
foreign archivelog from scn 1806248;
}
executing Memory Script

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 23-APR-18
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to user-specified destination
archived log destination=/u01/app/oracle/oradata/NEWCDB/PDB18C2
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=7
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting archived log restore to user-specified destination
archived log destination=/u01/app/oracle/oradata/NEWCDB/PDB18C2
channel ORA_AUX_DISK_1: using network backup set from service CDB18C
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 23-APR-18

Performing import of metadata...
Finished Duplicate PDB at 23-APR-18

RMAN>

Let’s connect to NEWCDB to check whether the PDB is created or not.

[oracle@18c ~]$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 Production on Mon Apr 23 16:15:57 2018
Version 18.1.0.0.0

Copyright (c) 1982, 2017, Oracle. All rights reserved.

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.1.0.0.0

SQL> show parameter db_n

NAME              TYPE     VALUE
------------      -------  ----------
db_name           string   NEWCDB
SQL> show pdbs

CON_ID     CON_NAME  OPEN MODE   RESTRICTED
---------- --------- ----------- -----------
2          PDB$SEED  READ ONLY   NO
3          PDB18C2   READ WRITE  NO
SQL>

Stay tuned for more articles on Oracle 18c 

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Telegram Channel: https://t.me/helporacle

Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/

Joel Perez’s LinkedIn: Joel Perez’s Profile

LinkedIn Group: Oracle Cloud DBAAS

Facebook Page: OracleHelp

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.