Downgrading a Single Pluggable Oracle Database (PDB)

If you are downgrading Oracle Database, then you can downgrade one PDB without downgrading the whole CDB.

You can downgrade individual PDBs. For example, you can unplug a PDB from an upgraded CDB, downgrade the PDB, and then plug it in to an earlier release CDB, or you can convert the PDB database to a standalone database.

Downgrade the PDB

In this procedure example, you downgrade the PDB to release 19c:

  1. Start up the PDB in DOWNGRADE mode. The CDB can be in normal mode when you do this.

    SQL> alter pluggable database CDB1_PDB1 open downgrade;
    
  2. Downgrade the PDB, either by using the dbdowngrade utility, or by running catdwgrd manually, using catcon.pl.

    In each of these options, the PDB that you are downgrading is PDB1.

    • Downgrading with dbdowngrade utility.

      Downgrade the PDB using the dbdowngrade script as follows:

      cd $ORACLE_HOME/bin
      ./dbdowngrade -c 'PDB1'
    • Manually downgrading with catdwgrd, using catcon.pl.

      Run catdwgrd as follows, where output-directory is the output directory, and catdwgrd is the log file base:

      $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -d
       $ORACLE_HOME/rdbms/admin -n 1 -l output-directory -e -b catdwgrd -c 'PDB1'
       catdwgrd.sql
      

      In the example, catdwgrd is run with catcon.pl. The -d parameter tells catcon.pl where to find catdwgrd. The -l parameter specifies the output directory for log files, instead of writing to the rdbms/admin directory). You must use the -r parameter to run the two scripts together at the same time.

      The log files for the downgrade are placed in the Oracle base home (the Oracle base identified by the commands orabasehome, or orabase, or the Oracle home identified by the command oracle_home, in that order.

  3. Close the PDB.

Unplug the PDB from the CDB

In this step you unplug the downgraded PDB from the Oracle Database 23ai CDB:

  1. Connect to the upgraded CDB.

  2. Close the PDB that you want to unplug.

    SQL> alter pluggable database PDB1 close;
    
  3. Unplug the downgraded 19c PDB, replacing the variable path with the path on your system:

    SQL> alter pluggable database PDB1 unplug into 'path/pdb1.xml';
    

    You receive the following response when the unplug is completed:

    Pluggable database altered

Plug in the Downgraded 19c PDB

In this step you plug the downgraded 19c PDB into the 19c CDB. To do this, you must create the PDB in this CDB. The following example shows how to create a pluggable database called PDB1:

  1. Connect to the 19c CDB.

  2. Plug in the 19c PDB.

    SQL> create pluggable database PDB1 using 'path/pdb1.xml';
    

    This command returns Pluggable database created.

  3. Open the PDB in upgrade mode:

    SQL> alter pluggable database PDB1 open upgrade;
    
  4. Connect to the PDB:

    SQL> alter session set container=PDB1;
    
  5. Run catrelod in the PDB:

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

    The catrelod.sql script reloads the appropriate version for each of the database components in the downgraded database.

  6. Run utlrp in the PDB:

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

    The utlrp.sql script recompiles all existing PL/SQL modules that were previously in an INVALID state, such as packages, procedures, types, and so on.