Before You Begin
This 15-minute tutorial shows you how to use Database Configuration Assistant (DBCA) to clone a remote pluggable database (PDB) into a container database (CDB).
Background
In Oracle Database 18c, cloning a remote PDB requires several commands to be executed.
What Do You Need?
- Oracle Database 19c installed
- Two CDBs:
ORCL
withPDB1
andCDB19
, both in archivelog mode. You can use the dbca.sh shell script to createCDB19
. Download the shell script to the labs directory created on your server/home/oracle/labs
. Replace the password in the shell script by your own complex password. PDB relocation PDB and remote PDB clone operations with DBCA do not support Oracle Managed Files (OMF) enabled CDB. Verify that the PDB to be cloned does not use OMF. HR
schema installed inPDB1
as an example of application tables. If you want to use theHR.EMPLOYEES
table, use the hr.sql. Download the SQL script to the labs directory created on your server/home/oracle/labs.
In the script, update the password of the user connected to the database.
Prepare the PDB Before Cloning
- Log in to
PDB1
inORCL
asSYSTEM
.sqlplus system@PDB1
Enter password: password - Use the hr.sql
script to create the
HR
user andEMPLOYEES
table inPDB1
.@/home/oracle/labs/hr.sql
- Verify that
PDB1
contains theHR.EMPLOYEES
table.SELECT count(*) FROM hr.employees;
COUNT(*) ---------- 107 - Connect to
ORCL
asSYSTEM
.CONNECT system@ORCL Enter password: password
- Create a common user in
ORCL
, used in the database link automatically created inCDB19
to connect toORCL
during the cloning operation.CREATE USER c##remote_user IDENTIFIED BY password CONTAINER=ALL;
- Grant the privileges.
GRANT create session, create pluggable database TO c##remote_user CONTAINER=ALL;
- Quit the session.
EXIT
Use DBCA to Clone a Remote PDB
In this section, you use DBCA in silent mode to clone PDB1
from ORCL
as PDB19
in CDB19
.
- If
CDB19
does not exist, launch the/home/oracle/labs/dbca.sh
shell script. The script creates the CDB with no PDB.In the script, update the password of the user connected to the database.
/home/oracle/labs/dbca.sh
- Launch DBCA in silent mode to clone
PDB1
fromORCL
asPDB19
inCDB19
.dbca -silent -createPluggableDatabase -createFromRemotePDB -remotePDBName PDB1 -remoteDBConnString ORCL -remoteDBSYSDBAUserName SYS -remoteDBSYSDBAUserPassword password -sysDBAUserName sys -sysDBAPassword password -dbLinkUsername c##remote_user -dbLinkUserPassword password -sourceDB CDB19 -pdbName PDB19
Prepare for db operation 50% complete Create pluggable database using remote clone operation 100% complete Pluggable database "PDB19" plugged successfully. Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/CDB19/PDB19/CDB19.log" for further details.
Check that the PDB Is Cloned
- Connect to
CDB19
asSYS
.sqlplus sys@CDB19 AS SYSDBA Enter password: password
SHOW PDBS
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB19 READ WRITE NO - Check that
PDB19
contains theHR.EMPLOYEES
table as inPDB1
.CONNECT hr@PDB19 Enter password: password
SELECT count(*) FROM employees;
COUNT(*) ---------- 107
Clean Up the PDB Cloned
- Connect to
CDB19
asSYS
.CONNECT sys@CDB19 AS SYSDBA Enter password: password
- Close
PDB19
.ALTER PLUGGABLE DATABASE pdb19 CLOSE;
- Drop
PDB19
.DROP PLUGGABLE DATABASE pdb19 INCLUDING DATAFILES;
- Quit the session.
EXIT