In this comprehensive guide, we'll walk you through the process of converting a Non-CDB (Non-Container Database) to a Pluggable Database (PDB) using an existing CDB (Container Database). Follow these clear and concise steps for a seamless transformation:
Assumption: Before converting a Non-CDB oracle instance
into CDB , it is assumed an oracle CDB instance is already running.
Step 1: Cleanly Shutdown the Non-CDB Database(orcl)
- Execute
the following commands to gracefully shut down the Non-CDB Database named
"orcl":
Invoke environment for orcl
[oracle@ocisoumya
~]$ . oraenv ORACLE_SID =
[orcl] ? orcl The Oracle
base remains unchanged with value /u01/app |
[oracle@ocisoumya ~]$ sqlplus / as
sysdba SQL*Plus: Release 19.0.0.0.0 -
Production on Mon Jan 15 15:45:10 2024 Version 19.21.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition
Release 19.0.0.0.0 - Production Version 19.21.0.0.0 SQL> show pdbs SQL> shu immediate Database closed. Database dismounted. ORACLE instance shut down. |
Step 2: Open the Database in Read-Only Mode
- Once
the database is cleanly shutdown, open it in read-only mode
SQL> startup open read only ORACLE instance started. Total System Global Area 4949276544
bytes Fixed Size 8935296 bytes Variable Size 973078528 bytes Database Buffers 3959422976 bytes Redo Buffers 7839744 bytes Database mounted. Database opened. |
Step 3: Describe the Database and Generate the XML File
- Generate
an XML file describing the database:
SQL>
BEGIN PL/SQL
procedure successfully completed. |
Step 4: Shutdown the Database
- Shutdown
the database again:
SQL> shu immediate Database closed. Database dismounted. ORACLE instance shut down. |
Step 5: Check Compatibility and Resolve Issues
- Verify
compatibility with the target CDB and address any issues:
Invoke CDB environment and login to
sqlplus
[oracle@ocisoumya ~]$ . oraenv ORACLE_SID = [orcl] ? orclcdb The Oracle base remains unchanged with
value /u01/app SQL> SET SERVEROUTPUT ON; DECLARE
compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file
=> '/u01/orcl.xml')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END; BEGIN
DBMS_OUTPUT.PUT_LINE(compatible); END; / |
- Check
the PDB_PLUG_IN_VIOLATIONS view from the CDB for any errors.
SQL> select
NAME,ERROR_NUMBER,type,MESSAGE,STATUS from PDB_PLUG_IN_VIOLATIONS; NAME ERROR_NUMBER TYPE MESSAGE
STATUS --------------- ------------ ---------
------------------------------------------------------------ --------- PDB$SEED 0 ERROR '19.21.0.0.0 Release_Update 2309301519'
is installed in the RESOLVED CDB
but no release updates are installed in the PDB ORCL 0 WARNING PDB plugged in is a non-CDB, requires
noncdb_to_pdb.sql be r PENDING un. ORCL 0 WARNING Undo mode mismatch: PDB using LOCAL
undo. CDB using SHARED PENDING undo. |
Step 6: Connect to the Target CDB
- Connect
to the CDB where the database will be plugged in:
[oracle@ocisoumya ~]$ . oraenv ORACLE_SID = [orcl] ? orclcdb The Oracle base remains unchanged with
value /u01/app |
Step 7: Create a Pluggable
Database
- Execute
the following SQL command to create a Pluggable Database:
SQL> CREATE PLUGGABLE DATABASE
ORCLPDB USING '/u01/orcl.xml' COPY FILE_NAME_CONVERT =
('/u01/app/oradata/ORCL/', '/u01/app/oradata/ORCLCDB/ORCLPDB/'); Pluggable database created. |
Step 8: Run the
noncdb_to_pdb.sql Script
·
Switch to the PDB container and run the script for the
conversion:
sql> ALTER
SESSION SET CONTAINER=ORCLPDB; sql> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql |
Step 9: Startup the PDB and
Verify
· Start
up the PDB and confirm its open mode:
SQL> ALTER PLUGGABLE DATABASE OPEN; Pluggable database altered. SQL> SELECT name, open_mode FROM
v$pdbs; NAME OPEN_MODE --------------- ---------- ORCLPDB READ WRITE |