CONVERTING NON-CONTAINER DATABASE TO CONTAINER DATABASE

CONVERTING NON-CONTAINER DATABASE TO CONTAINER DATABASE

In this tutorial, we are going to learn about how to convert a non-container database to a container database.

Before that, we need to install both the database i.e non container database and non – container database in dbca or manually.

Here i have a mentioned below details of noncontainer database and container database name:

Non-Container database name – gdb1

Container database – ndb1

Step1: 

At first, we want to ensure both the database is running or not using

$ps – ef |grep pmon

Step 2: 

Open the Non-Container database as read-only mode.

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount exclusive

ORACLE instance started.

Total System Global Area 1862270976 bytes

Fixed Size     8621952 bytes

Variable Size   553648256 bytes

Database Buffers  1291845632 bytes

Redo Buffers     8155136 bytes

Database mounted.

SQL> alter database open read-only;

Database altered.

Step3: Create the XML file needed for cdb conversion using the DBMS_PDB.DESCRIBE procedure.

The above pl/SQL procedure will create the XML file in which you mention on that.

Step 3:Shutdown the NON-CDB database.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

Step 4: Open the cdb database.

export ORACLE_SID=ndb1

[oracle@gg1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Jan 23 17:18:20 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 1862270976 bytes

Fixed Size     8794024 bytes

Variable Size   553648216 bytes

Database Buffers  1291845632 bytes

Redo Buffers     7983104 bytes

Database mounted.

Database opened.

SQL> select name,open_mode,cdb from v$database;

NAME   OPEN_MODE        CDB

——— ——————– —

NDB1   READ WRITE        YES

Step 5: Check the compatibility of PDB on ( ORA_CDB)

SET SERVEROUTPUT ON;

DECLARE

Compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => ‘/tmp/gdb1.xml’)

WHEN TRUE THEN ‘YES’

ELSE ‘NO’

END;

BEGIN

DBMS_OUTPUT.PUT_LINE(compatible);

END;

/

YES

PL/SQL procedure successfully completed.

Step 6: Check the violations :

Step 7: Create a pluggable database in container DB 

SQL> create pluggable database gdb1 using ‘/tmp/gdb1.xml’ NOCOPY tempfile reuse;

Pluggable database created.

Step 8: Switch the Newly created pdb .

SQL> ALTER SESSION SET CONTAINER=GDB1;

Session altered.

Step 9: Run the noncdb_to_pdb.sql script

SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

SQL> SET SERVEROUTPUT ON

SQL> SET FEEDBACK 1

SQL> SET NUMWIDTH 10

SQL> SET LINESIZE 80

SQL> SET TRIMSPOOL ON

SQL> SET TAB OFF

SQL> SET PAGESIZE 100

SQL> SET VERIFY OFF

SQL>

SQL> — save settings

SQL> STORE SET ncdb2pdb.settings.sql REPLACE

Wrote file ncdb2pdb.settings.sql

SQL>

SQL> SET TIME ON

16:12:03 SQL> SET TIMING ON

16:12:03 SQL>

16:12:03 SQL> WHENEVER SQLERROR EXIT;

16:12:03 SQL>

16:12:03 SQL> DOC

Step 10: Open the PDB 

SQL> alter Pluggable database gdb1 open;

Pluggable database altered.

SQL> SELECT name, open_mode FROM v$pdbs;

NAME                 OPEN_MODE

——————– ———-

GDB1                  READ WRITE

Recent Posts