In this article, we will see how we can plug the Non-CDB database as a Pluggable Database in a Container Database.

Step 1: Check non-cdb Database

SQL> SELECT NAME,OPEN_MODE,CDB FROM V$DATABASE;

NAME	  OPEN_MODE	       CDB
--------- -------------------- ---
NCDB	  READ WRITE	       NO

Step 2: Gracefully shut down Non-CDB database and open it in READ ONLY stage

SQL> SHUT IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP OPEN READ ONLY;
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size		    8622624 bytes
Variable Size		  436211168 bytes
Database Buffers	   75497472 bytes
Redo Buffers		    3956736 bytes
Database mounted.
ORA-16000: database or pluggable database open for read-only access

SQL> SELECT NAME,OPEN_MODE FROM V$DATABASE;

NAME	  OPEN_MODE
--------- --------------------
NCDB	  READ ONLY

SQL>

Step 3 : Call DBMS_PDB.DESCRIBE procedure, that will create the XML file

SQL> BEGIN
DBMS_PDB.DESCRIBE(pdb_descr_file => '/u02/ncdb.xml');
END;
/  2    3    4  

PL/SQL procedure successfully completed.

Step 4: Shut down the non-cdb database

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

Step 5: Connect to the CDB database

SQL> SELECT NAME,OPEN_MODE,CDB FROM V$DATABASE;

NAME	  OPEN_MODE	       CDB
--------- -------------------- ---
TESTCDB   READ WRITE	       YES

Step 6: Create the new pluggable database using XML file we have created with a non-cdb database

SQL> CREATE PLUGGABLE DATABASE PDB1 USING '/u02/ncdb.xml' copy;

Pluggable database created.

Step 7: Connect to PDB1

SQL>alter session set container=PDB1;

Step 8: Run noncdb_to_pdb.sql file this file will delete redundant metadata and convert non-cdb to pluggable database:

SQL>@?/rdbms/admin/noncdb_to_pdb

Step 9: Connect to CDB or PDB and open pluggable database :

sql>alter pluggable database pdb1 open;
Pluggable database altered.

Step 10: Connect to PDB1 and check database details :

SQL> ALTER SESSION SET CONTAINER=PDB1;

Session altered.

SQL> SELECT NAME,OPEN_MODE FROM V$DATABASE;            

NAME	  OPEN_MODE
--------- --------------------
TESTCDB   READ WRITE

SQL>

Stay tuned for More articles on Oracle Multitenant

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

About The Author

Leave a Reply

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