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:
ORCLwithPDB1andCDB19, 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. HRschema installed inPDB1as an example of application tables. If you want to use theHR.EMPLOYEEStable, 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
PDB1inORCLasSYSTEM.sqlplus system@PDB1
Enter password: password - Use the hr.sql
script to create the
HRuser andEMPLOYEEStable inPDB1.@/home/oracle/labs/hr.sql - Verify that
PDB1contains theHR.EMPLOYEEStable.SELECT count(*) FROM hr.employees;
COUNT(*) ---------- 107 - Connect to
ORCLasSYS.CONNECT sys@ORCL AS SYSDBA Enter password: password
- Create a common user in
ORCL, used in the database link automatically created inCDB19to connect toORCLduring 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
CDB19does not exist, launch the/home/oracle/labs/dbca.shshell 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
PDB1fromORCLasPDB1_IN_CDB19inCDB19.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
CDB19asSYS. Check thatPDB1is 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_CDB19contains theHR.EMPLOYEEStable as inPDB1.CONNECT hr@PDB1_IN_CDB19 Enter password: password
SELECT count(*) FROM employees;
COUNT(*) ---------- 107 - Connect to
ORCLasSYS. Check thatPDB1does 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
CDB19asSYS.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
Relocate
PDBs using DBCA in Silent Mode