Announcements

Oracle training based on real-time expertise as per industry standards. Upcoming batch details are here.

View batch schedule

Free Oracle mock interview. Register using the link.

Register

#DBAchallenge: submit your questions.

Ask questions
Swipe for more →
Browse by Topic
Latest Posts

    Saturday, August 6, 2022

    Convert Non-CDB database as PDB inside CDB database

    Converting a non-CDB to a PDB

    Source: DEVDB (Normal 19c database)
    Target: DEVCDB (CDB database)

    Task: 
    Convert this DEVDB(Normal database) as PDB inside DEVCDB database.

    High level Steps:
    1. Create xml file from Non-CDB database
    2. Check plug in compatibility check for created xml file from CDB database
    3. Create or plugin Non-CDB database as PDB inside CDB database
    4. Run noncdb_to_pdb.sql sql script inside newly create PDB 

    1. Create xml file from Non-CDB database
    [oracle@oraclelab1 patches]$ ps -ef|grep smon
    oracle    2827     1  0 19:59 ?        00:00:00 ora_smon_TESTCDB
    oracle    6556  2545  0 20:52 pts/1    00:00:00 grep --color=auto smon
    oracle   12924     1  0 Aug02 ?        00:00:08 ora_smon_DEVDB
    oracle   15033     1  0 Aug02 ?        00:00:03 ora_smon_DEVCDB
    [oracle@oraclelab1 patches]$

    [oracle@oraclelab1 patches]$ . oraenv
    ORACLE_SID = [TESTCDB] ? DEVDB
    The Oracle base remains unchanged with value /u01/app/oracle
    [oracle@oraclelab1 patches]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 5 20:52:59 2022
    Version 19.14.0.0.0

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


    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0

    SQL> shut immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.

    Total System Global Area  268434272 bytes
    Fixed Size                  8895328 bytes
    Variable Size             218103808 bytes
    Database Buffers           33554432 bytes
    Redo Buffers                7880704 bytes
    Database mounted.
    SQL> alter database open read only;

    Database altered.

    SQL> begin
    DBMS_PDB.DESCRIBE(pdb_descr_file => '/u01/patches/DEVDB.xml');
    end;
    /  2    3    4

    PL/SQL procedure successfully completed.

    SQL> exit
    Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0
    [oracle@oraclelab1 patches]$ 

    begin 
    DBMS_PDB.DESCRIBE(pdb_descr_file => '/u01/patches/DEVDB.xml');
    end;
    /

    2. Check plug in compatibility check for created xml file from CDB database
    [oracle@oraclelab1 patches]$ . oraenv
    ORACLE_SID = [DEVDB] ? DEVCDB
    The Oracle base remains unchanged with value /u01/app/oracle
    [oracle@oraclelab1 patches]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 5 20:56:34 2022
    Version 19.14.0.0.0

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


    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0

    SQL> SET SERVEROUTPUT ON
    DECLARE
      l_result BOOLEAN;
    BEGIN
      l_result := DBMS_PDB.check_plug_compatibility(
                    pdb_descr_file => '/u01/patches/DEVDB.xml',
                    pdb_name       => 'DEVDB');

      IF l_result THEN
        DBMS_OUTPUT.PUT_LINE('compatible');
      ELSE
        DBMS_OUTPUT.PUT_LINE('incompatible');
      END IF;
    END;
    /
    SQL> 
    incompatible >>>>>>>>>>>>>>>>>>>>>>>>> Issue here

    PL/SQL procedure successfully completed.

    SQL>

    SET SERVEROUTPUT ON
    DECLARE
      l_result BOOLEAN;
    BEGIN
      l_result := DBMS_PDB.check_plug_compatibility(
                    pdb_descr_file => '/u01/patches/DEVDB.xml',
                    pdb_name       => 'DEVDB');

      IF l_result THEN
        DBMS_OUTPUT.PUT_LINE('compatible');
      ELSE
        DBMS_OUTPUT.PUT_LINE('incompatible');
      END IF;
    END;
    /

    Issue1:
    For alert log we got to know the database patch level miss match between source DB and target CDB

    [root@oraclelab1 ~]# locate alert_DEVCDB.log
    /u01/app/oracle/diag/rdbms/devcdb/DEVCDB/trace/alert_DEVCDB.log
    [root@oraclelab1 ~]# tail -f /u01/app/oracle/diag/rdbms/devcdb/DEVCDB/trace/alert_DEVCDB.log
    DEVPDB(3):Clearing Resource Manager plan via parameter
    PDB2(5):Closing scheduler window
    PDB2(5):Closing Resource Manager plan via scheduler window
    PDB2(5):Clearing Resource Manager plan via parameter
    2022-08-05T16:30:02.138175+05:30
    Thread 1 advanced to log sequence 31 (LGWR switch),  current SCN: 4303253
      Current log# 1 seq# 31 mem# 0: /u01/app/oracle/oradata/DEVCDB/onlinelog/o1_mf_1_kfypzdy8_.log
      Current log# 1 seq# 31 mem# 1: /u01/app/oracle/fast_recovery_area/DEVCDB/onlinelog/o1_mf_1_kfypzf45_.log
    2022-08-05T20:56:50.597761+05:30
    Opatch validation is skipped for PDB DEVDB (con_id=0)

    DEVDB:
    ======
    QL> set pagesize 1000;
    set linesize 1000;
    col STATUS for a10;
    col ACTION_TIME format a30;
    col DESCRIPTION format a55;
    select PATCH_ID,status,ACTION_TIME,DESCRIPTION from dba_registry_sqlpatch;
    SQL> SQL> SQL> SQL> SQL>
      PATCH_ID STATUS      ACTION_TIME                    DESCRIPTION
    ---------- ----------- ------------------------------ -------------------------------------------------------
      29517242 SUCCESS     11-JUL-22 09.09.12.789728 AM   Database Release Update : 19.3.0.0.190416 (29517242)
      33515361 WITH ERRORS 02-AUG-22 09.59.05.092960 AM   Database Release Update : 19.14.0.0.220118 (33515361)
    SQL>

    SQL> column comp_name format a40
    column version format a12
    column status format a15
    select comp_name,version,status from dba_registry;
    SQL> SQL> SQL>
    COMP_NAME                                VERSION      STATUS
    ---------------------------------------- ------------ ---------------
    Oracle Database Catalog Views            19.0.0.0.0   VALID
    Oracle Database Packages and Types       19.0.0.0.0   INVALID
    Oracle Real Application Clusters         19.0.0.0.0   OPTION OFF
    JServer JAVA Virtual Machine             19.0.0.0.0   VALID
    Oracle XDK                               19.0.0.0.0   VALID
    Oracle Database Java Packages            19.0.0.0.0   VALID
    OLAP Analytic Workspace                  19.0.0.0.0   VALID
    Oracle XML Database                      19.0.0.0.0   INVALID
    Oracle Workspace Manager                 19.0.0.0.0   INVALID
    Oracle Text                              19.0.0.0.0   VALID
    Oracle Multimedia                        19.0.0.0.0   VALID

    COMP_NAME                                VERSION      STATUS
    ---------------------------------------- ------------ ---------------
    Spatial                                  19.0.0.0.0   INVALID
    Oracle OLAP API                          19.0.0.0.0   VALID
    Oracle Label Security                    19.0.0.0.0   VALID
    Oracle Database Vault                    19.0.0.0.0   VALID

    15 rows selected.

    SQL> 

    DEVCDB:
    =======
    SQL> set pagesize 1000;
    set linesize 1000;
    col STATUS for a10;
    col ACTION_TIME format a30;
    col DESCRIPTION format a55;
    select PATCH_ID,status,ACTION_TIME,DESCRIPTION from dba_registry_sqlpatch;
    SQL> SQL> SQL> SQL> SQL>
      PATCH_ID STATUS     ACTION_TIME                    DESCRIPTION
    ---------- ---------- ------------------------------ -------------------------------------------------------
      29517242 SUCCESS    26-JUL-22 08.46.22.698373 AM   Database Release Update : 19.3.0.0.190416 (29517242)
      33515361 SUCCESS    02-AUG-22 10.21.30.647761 AM   Database Release Update : 19.14.0.0.220118 (33515361)
    SQL>

    Solution 1:
    Lots of Registry componets were invalid due to that datapatch was failed with error inside DEVDB.
    I have fixed the registry componets re-ran the datapatch which went fine.

    SQL> column comp_name format a40
    column version format a12
    column status format a15
    select comp_name,version,status from dba_registry;SQL> SQL> SQL>

    COMP_NAME                                VERSION      STATUS
    ---------------------------------------- ------------ ---------------
    Oracle Database Catalog Views            19.0.0.0.0   VALID
    Oracle Database Packages and Types       19.0.0.0.0   VALID
    Oracle Real Application Clusters         19.0.0.0.0   OPTION OFF
    JServer JAVA Virtual Machine             19.0.0.0.0   VALID
    Oracle XDK                               19.0.0.0.0   VALID
    Oracle Database Java Packages            19.0.0.0.0   VALID
    OLAP Analytic Workspace                  19.0.0.0.0   VALID
    Oracle XML Database                      19.0.0.0.0   VALID
    Oracle Workspace Manager                 19.0.0.0.0   VALID
    Oracle Text                              19.0.0.0.0   VALID
    Oracle Multimedia                        19.0.0.0.0   VALID

    COMP_NAME                                VERSION      STATUS
    ---------------------------------------- ------------ ---------------
    Spatial                                  19.0.0.0.0   VALID
    Oracle OLAP API                          19.0.0.0.0   VALID
    Oracle Label Security                    19.0.0.0.0   VALID
    Oracle Database Vault                    19.0.0.0.0   VALID

    15 rows selected.

    SQL>

    SQL> set pagesize 1000;
    set linesize 1000;
    col STATUS for a10;
    col ACTION_TIME format a30;
    col DESCRIPTION format a55;
    select PATCH_ID,status,ACTION_TIME,DESCRIPTION from dba_registry_sqlpatch;SQL> SQL> SQL> SQL> SQL>

      PATCH_ID STATUS     ACTION_TIME                    DESCRIPTION
    ---------- ---------- ------------------------------ -------------------------------------------------------
      29517242 SUCCESS    11-JUL-22 09.09.12.789728 AM   Database Release Update : 19.3.0.0.190416 (29517242)
      33515361 SUCCESS    06-AUG-22 07.58.22.273849 AM   Database Release Update : 19.14.0.0.220118 (33515361)

    SQL>

    [oracle@oraclelab1 ~]$ . oraenv
    ORACLE_SID = [oracle] ? DEVCDB
    The Oracle base has been set to /u01/app/oracle
    [oracle@oraclelab1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 6 20:34:57 2022
    Version 19.14.0.0.0

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


    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0

    SQL> SET SERVEROUTPUT ON
    DECLARE
      l_result BOOLEAN;
    BEGIN
      l_result := DBMS_PDB.check_plug_compatibility(
                    pdb_descr_file => '/u01/patches/DEVDB.xml',
                    pdb_name       => 'DEVDB');

      IF l_result THEN
        DBMS_OUTPUT.PUT_LINE('compatible');
      ELSE
        DBMS_OUTPUT.PUT_LINE('incompatible');
      END IF;
    END;
    /SQL>   
    compatible >>>>>>>>>>>>>>>>>>>>>>>>>>> Its succeeded now which failed earlier 

    PL/SQL procedure successfully completed.

    SQL>

    3. Create or plugin Non-CDB database as PDB inside CDB database
    Issue 2: 
    While creating DEVDB as PDB inside CDB which failed with error message temp file exists. 

    SQL> create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy;
    create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy
    *
    ERROR at line 1:
    ORA-27038: created file already exists
    ORA-01119: error in creating database file
    '/u01/app/oracle/oradata/DEVDB/datafile/o1_mf_temp_kgvmybcv_.tmp'

    SQL>

    Alert log error message:
    **************************************************************
    Undo Create of Pluggable Database DEVDB with pdb id - 4.
    **************************************************************
    ORA-27038 signalled during: create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy...
    2022-08-06T20:55:18.071973+05:30
    create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy
    2022-08-06T20:55:18.084888+05:30
    Opatch validation is skipped for PDB DEVDB (con_id=6)
    **************************************************************
    Undo Create of Pluggable Database DEVDB with pdb id - 6.
    **************************************************************
    ORA-27038 signalled during: create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy...
    2022-08-06T20:55:51.372436+05:30
    create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy TEMPFILE REUSE
    2022-08-06T20:55:51.385142+05:30
    Opatch validation is skipped for PDB DEVDB (con_id=7)
    DEVDB(7):Endian type of dictionary set to little
    ****************************************************************
    Pluggable Database DEVDB with pdb id - 7 is created as UNUSABLE.
    If any errors are encountered before the pdb is marked as NEW,
    then the pdb must be dropped
    local undo-1, localundoscn-0x0000000000000009
    ****************************************************************

    Solution 2:
    We I have used temp file reuse command to create DEVDB as PDB inside CDB.

    SQL> create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy TEMPFILE REUSE;

    Pluggable database created.

    SQL>

    Alert log message:
    ****************************************************************
    DEVDB(7):Pluggable database DEVDB pseudo opening
    DEVDB(7):SUPLOG: Initialize PDB SUPLOG SGA, old value 0x0, new value 0x18
    DEVDB(7):Autotune of undo retention is turned on.
    DEVDB(7):Undo initialization recovery: Parallel FPTR complete: start:1597465044 end:1597465045 diff:1 ms (0.0 seconds)
    DEVDB(7):Undo initialization recovery: err:0 start: 1597465044 end: 1597465045 diff: 1 ms (0.0 seconds)
    DEVDB(7):[4463] Successfully onlined Undo Tablespace 2.
    DEVDB(7):Undo initialization online undo segments: err:0 start: 1597465046 end: 1597465070 diff: 24 ms (0.0 seconds)
    DEVDB(7):Undo initialization finished serial:0 start:1597465044 end:1597465071 diff:27 ms (0.0 seconds)
    DEVDB(7):Database Characterset for DEVDB is AL32UTF8
    DEVDB(7):Pluggable database DEVDB pseudo closing
    DEVDB(7):JIT: pid 4463 requesting stop
    DEVDB(7):Closing sequence subsystem (1597465245122).
    2022-08-06T20:55:52.429393+05:30
    DEVDB(7):Buffer Cache flush started: 7
    DEVDB(7):Buffer Cache flush finished: 7
    Completed: create pluggable database DEVDB using '/u01/patches/DEVDB.xml' nocopy TEMPFILE REUSE

    SQL> ALTER PLUGGABLE DATABASE DEVDB open;

    Warning: PDB altered with errors.

    SQL>

    Alert log message:
    DEVDB(7):Deleting old file#1 from file$
    DEVDB(7):Deleting old file#2 from file$
    DEVDB(7):Deleting old file#3 from file$
    DEVDB(7):Deleting old file#4 from file$
    DEVDB(7):Deleting old file#5 from file$
    DEVDB(7):Deleting old file#7 from file$
    DEVDB(7):Adding new file#25 to file$(old file#1).             fopr-0, newblks-128000, oldblks-64000
    DEVDB(7):Adding new file#26 to file$(old file#3).             fopr-0, newblks-98560, oldblks-51200
    DEVDB(7):Adding new file#27 to file$(old file#4).             fopr-0, newblks-78720, oldblks-3200
    DEVDB(7):Adding new file#28 to file$(old file#7).             fopr-0, newblks-640, oldblks-640
    DEVDB(7):Successfully created internal service DEVDB at open
    ****************************************************************
    Post plug operations are now complete.
    Pluggable database DEVDB with pdb id - 7 is now marked as NEW.
    ****************************************************************
    DEVDB(7):Database Characterset for DEVDB is AL32UTF8
    Violations: Type: 1, Count: 1
    DEVDB(7):***************************************************************
    DEVDB(7):WARNING: Pluggable Database DEVDB with pdb id - 7 is
    DEVDB(7):         altered with errors or warnings. Please look into
    DEVDB(7):         PDB_PLUG_IN_VIOLATIONS view for more details.
    DEVDB(7):***************************************************************
    2022-08-06T20:57:05.441349+05:30
    DEVDB(7):SUPLOG: Set PDB SUPLOG SGA at PDB OPEN, old 0x18, new 0x0 (no suplog)
    DEVDB(7):Opening pdb with no Resource Manager plan active
    DEVDB(7):joxcsys_required_dirobj_exists: directory object does not exist, pid 4463 cid 7
    DEVDB(7):joxcsys_ensure_directory_object: created directory object with path /u01/app/oracle/product/19.0.0.0/dbhome_1/javavm/admin/, pid 4463 cid 7
    Pluggable database DEVDB opened read write
    Completed: ALTER PLUGGABLE DATABASE DEVDB open

    4. Run noncdb_to_pdb.sql sql script inside newly create PDB 
    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  YES
             3 DEVPDB                         READ WRITE YES
             5 PDB2                           READ WRITE YES
             7 DEVDB                          READ WRITE YES
    SQL> alter session set container=DEVDB;

    Session altered.

    SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql;
    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> WHENEVER SQLERROR EXIT;
    SQL>
    SQL> DOC
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>   The following statement will cause an "ORA-01403: no data found"
    DOC>   error if we're not in a PDB.
    DOC>   This script is intended to be run right after plugin of a PDB,
    DOC>   while inside the PDB.
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>#
    SQL>
    SQL> VARIABLE cdbname VARCHAR2(128)
    SQL> VARIABLE pdbname VARCHAR2(128)
    SQL> BEGIN
      2    SELECT sys_context('USERENV', 'CDB_NAME')
      3      INTO :cdbname
      4      FROM dual
      5      WHERE sys_context('USERENV', 'CDB_NAME') is not null;
      6    SELECT sys_context('USERENV', 'CON_NAME')
      7      INTO :pdbname
      8      FROM dual
      9      WHERE sys_context('USERENV', 'CON_NAME') <> 'CDB$ROOT';
     10  END;
     11  /

    PL/SQL procedure successfully completed.

    SQL>
    SQL> @@?/rdbms/admin/loc_to_common0.sql
    SQL> Rem
    ...........................
    ...........................
    ...........................
    ...........................
    SQL> alter session set "_enable_view_pdb"=false;

    Session altered.

    SQL>
    SQL> SELECT dbms_registry_sys.time_stamp('utlrp_bgn') as timestamp from dual;

    TIMESTAMP
    --------------------------------------------------------------------------------
    COMP_TIMESTAMP UTLRP_BGN              2022-08-06 21:00:37

    1 row selected.

    SQL>
    SQL> DOC
    DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
    DOC>   objects in the database. Recompilation time is proportional to the
    DOC>   number of invalid objects in the database, so this command may take
    DOC>   a long time to execute on a database with a large number of invalid
    DOC>   objects.
    DOC>
    DOC>   Use the following queries to track recompilation progress:
    DOC>
    DOC>   1. Query returning the number of invalid objects remaining. This
    DOC>      number should decrease with time.
    DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
    DOC>
    DOC>   2. Query returning the number of objects compiled so far. This number
    DOC>      should increase with time.
    DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
    DOC>
    DOC>   This script automatically chooses serial or parallel recompilation
    DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
    DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
    DOC>   On RAC, this number is added across all RAC nodes.
    DOC>
    DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
    DOC>   recompilation. Jobs are created without instance affinity so that they
    DOC>   can migrate across RAC nodes. Use the following queries to verify
    DOC>   whether UTL_RECOMP jobs are being created and run correctly:
    DOC>
    DOC>   1. Query showing jobs created by UTL_RECOMP
    DOC>         SELECT job_name FROM dba_scheduler_jobs
    DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
    DOC>
    DOC>   2. Query showing UTL_RECOMP jobs that are running
    DOC>         SELECT job_name FROM dba_scheduler_running_jobs
    DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
    DOC>#
    SQL>
    SQL> DECLARE
      2     threads pls_integer := &&1;
      3  BEGIN
      4     utl_recomp.recomp_parallel(threads);
      5  END;
      6  /
    ...........................
    ...........................
    ...........................
    ...........................
    SQL> alter session set "_enable_view_pdb"=false;

    Session altered.

    SQL>
    SQL> -- leave the PDB in the same state it was when we started
    SQL> BEGIN
      2    execute immediate '&open_sql &restricted_state';
      3  EXCEPTION
      4    WHEN OTHERS THEN
      5    BEGIN
      6      IF (sqlcode <> -900) THEN
      7        RAISE;
      8      END IF;
      9    END;
     10  END;
     11  /

    PL/SQL procedure successfully completed.

    SQL>
    SQL> WHENEVER SQLERROR CONTINUE;
    SQL>

    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  YES
             3 DEVPDB                         READ WRITE YES
             5 PDB2                           READ WRITE YES
             7 DEVDB                          MOUNTED
    SQL>
    SQL> exit
    Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0
    [oracle@oraclelab1 ~]$
    [oracle@oraclelab1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 6 21:09:05 2022
    Version 19.14.0.0.0

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


    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.14.0.0.0

    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  YES
             3 DEVPDB                         READ WRITE YES
             5 PDB2                           READ WRITE YES
             7 DEVDB                          MOUNTED
    SQL>
    SQL> alter pluggable database DEVDB open;

    Pluggable database altered.

    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  YES
             3 DEVPDB                         READ WRITE YES
             5 PDB2                           READ WRITE YES
             7 DEVDB                          READ WRITE NO
    SQL>
    SQL> select name from v$datafile;

    NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEVDB/datafile/o1_mf_system_kgvmtpcn_.dbf
    /u01/app/oracle/oradata/DEVDB/datafile/o1_mf_sysaux_kgvmw3hs_.dbf
    /u01/app/oracle/oradata/DEVDB/datafile/o1_mf_undotbs1_kgvmwwmm_.dbf
    /u01/app/oracle/oradata/DEVDB/datafile/o1_mf_users_kgvmwxo3_.dbf

    SQL> 

    Note:
    We have already plugged or create DEVDB as PDB inside DEVCDB, If we try to open DEVDB as normal database which will not open. 

    [oracle@oraclelab1 ~]$ env |grep ORA
    ORACLE_SID=DEVDB
    ORACLE_BASE=/u01/app/oracle
    ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1
    [oracle@oraclelab1 ~]$

    [oracle@oraclelab1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 6 21:11:21 2022
    Version 19.14.0.0.0

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

    Connected to an idle instance.

    SQL> startup;
    ORACLE instance started.

    Total System Global Area 3690985848 bytes
    Fixed Size                  8903032 bytes
    Variable Size             721420288 bytes
    Database Buffers         2952790016 bytes
    Redo Buffers                7872512 bytes
    Database mounted.
    ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
    ORA-01110: data file 1:
    '/u01/app/oracle/oradata/DEVDB/datafile/o1_mf_system_kgvmtpcn_.dbf'
    SQL> 

    Try to shuldwon PDB (DEVDB) from DEVCDB and try to open normal DEVDB database which will fail again
    Once you create or plugin node database DEVDB as PDB inside DEVCDB, you dont have any option to revet that back. 

    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             7 DEVDB                          READ WRITE NO
    SQL>
    SQL> shut immediate;
    Pluggable Database closed.
    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             7 DEVDB                          MOUNTED
    SQL> conn / as sysdba
    Connected.
    SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  YES
             3 DEVPDB                         READ WRITE YES
             5 PDB2                           READ WRITE YES
             7 DEVDB                          MOUNTED
    SQL>

    [oracle@oraclelab1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 6 21:14:36 2022
    Version 19.14.0.0.0

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

    Connected to an idle instance.

    SQL> startup;
    ORACLE instance started.

    Total System Global Area 3690985848 bytes
    Fixed Size                  8903032 bytes
    Variable Size             721420288 bytes
    Database Buffers         2952790016 bytes
    Redo Buffers                7872512 bytes
    Database mounted.
    ORA-01122: database file 1 failed verification check
    ORA-01110: data file 1:
    '/u01/app/oracle/oradata/DEVDB/datafile/o1_mf_system_kgvmtpcn_.dbf'
    ORA-01204: file number is 25 rather than 1 - wrong file

    SQL>

    Regards,
    Mallik

    No comments:

    Post a Comment

    🌟 Proud to be an Oracle ACE Pro! 🚀

    🌟 Proud to be an Oracle ACE Pro! 🚀 I’m excited to share my official Oracle ACE Profile with the Oracle community. 👨‍💻 Mallikarjun ...