Before You Begin
This 15-minute tutorial shows you how to use Database Configuration Assistant (DBCA) to relocate a remote pluggable database (PDB) into a container database (CDB).
Background
In Oracle Database 18c, relocating 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 Relocation
- 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
asSYS
.CONNECT sys@ORCL AS SYSDBA Enter password: password
- Create a common user in
ORCL
, used in the database link automatically created inCDB19
to connect toORCL
during the relocation operation.CREATE USER c##remote_user IDENTIFIED BY password CONTAINER=ALL;
- Grant the privileges.
GRANT create session, create pluggable database, sysoper TO c##remote_user CONTAINER=ALL;
- Quit the session.
EXIT
Use
DBCA to Relocate a Remote PDB
In this section, you use DBCA in silent mode to relocate
PDB1
from ORCL
as PDB1_IN_CDB19
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 relocate
PDB1
fromORCL
asPDB1_IN_CDB19
inCDB19
.dbca -silent -relocatePDB -remotePDBName PDB1 -remoteDBConnString ORCL -sysDBAUserName SYSTEM -sysDBAPassword password -remoteDBSYSDBAUserName SYS -remoteDBSYSDBAUserPassword password -dbLinkUsername c##remote_user -dbLinkUserPassword password -sourceDB CDB19 -pdbName PDB1_IN_CDB19
Prepare for db operation Prepare for db operation 50% complete Create pluggable database using relocate PDB operation 100% complete Pluggable database "PDB1_IN_CDB19" plugged successfully. Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/CDB19/PDB1_IN_CDB19/CDB19.log" for further details.
Check
that the PDB Is Relocated
- Connect to
CDB19
asSYS
. Check thatPDB1
is relocated inCDB19
.sqlplus sys@CDB19 AS SYSDBA Enter password: password
SHOW PDBS
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1_IN_CDB19 READ WRITE NO - Check that
PDB1_IN_CDB19
contains theHR.EMPLOYEES
table as inPDB1
.CONNECT hr@PDB1_IN_CDB19 Enter password: password
SELECT count(*) FROM employees;
COUNT(*) ---------- 107 - Connect to
ORCL
asSYS
. Check thatPDB1
does not exist anymore inORCL
.CONNECT sys@ORCL AS SYSDBA Enter password: password
SHOW PDBS
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO
Clean
Up the PDB Relocated
- Connect to
CDB19
asSYS
.CONNECT sys@CDB19 AS SYSDBA Enter password: password
- Close
PDB1_In_CDB19
.ALTER PLUGGABLE DATABASE pdb1_in_cdb19 CLOSE;
- Drop
PDB1_IN_CDB19
.DROP PLUGGABLE DATABASE pdb1_in_cdb19 INCLUDING DATAFILES;
- Quit the session.
EXIT