Patching a Database

This topic describes the procedures to apply patches to databases in bare metal and virtual machine DB systems by using the Console and the API. For information on patching DB systems and to see a list of currently available database patches, see Patching a DB System.

Note

This topic is not applicable to Exadata Cloud Service instances. For information and instructions on Exadata patching in Oracle Cloud Infrastructure, see the following topics:

Required IAM Policy

You must have the required type of access in a policy  to use Oracle Cloud Infrastructure, whether you're using the Console or the REST API with an SDK, CLI, or other tool. When running a command, if you see an error message that says you don’t have permission or are unauthorized, contact your administrator. Confirm the type of access you've been granted, and which compartment  you should work in.

For administrators: The policy in Let database admins manage Oracle Cloud database systems enables the specified group to do everything with databases and related Database resources.

If you're new to policies, see Getting Started with Policies and Common Policies. Details about writing policies for databases are located in Details for the Database Service.

About Patching Databases

For database patching, always patch a DB system before you patch the databases within that system. The Console displays the latest DB system patch and the previous patch. You can use either of these patches, but we recommend using the latest patch when possible. See Patching a DB System for more information.

You can also patch your database using a custom database software image. See Oracle Database Software Images for more information on creating and working with software images.

For a list of currently available database patches, see Currently Available Patches.

Applying Interim (One-Off) Patches Using a Database Software Image

You can use custom database software images to easily apply interim (one-off) patches to databases in virtual machine and bare metal DB systems in the Console. See the following topics for more information:

Applying one-off patches on Oracle Database 21c

Use the Apply a one-off patch feature available in the Updates section of the Database Details page to apply one-patches directly to your 21c database.

To apply one-off patches to Oracle 21c databases

You can use the OCI Console to apply one-off patches to Oracle 21c databases.

  1. Open the navigation menu. Click Oracle Database, then click Bare Metal, VM, and Exadata.
  2. Choose your Compartment.

  3. Find the DB system where the database is located, and click the system name to display details about it.

  4. Find the database on which you want to perform the patch operation, and click its name to display details about it.
  5. Under Resources, click Updates.
  6. Click the Apply one-off patch link.
  7. In the Apply one-off patch dialog, enter the patch numbers. Use a comma-separated list to enter more than one patch.
  8. Click Apply.

    While a patch is being applied, the database's status displays as Updating. A work request is created for the patching operation, allowing you to monitor the progress of the operation. If the operation completes successfully, the database's status changes to Available.

Using the Console

To patch a database
  1. Open the navigation menu. Click Oracle Database, then click Bare Metal, VM, and Exadata.
  2. Choose your Compartment.

  3. Find the DB system where the database is located, and click the system name to display details about it.

  4. Find the database on which you want to perform the patch operation, and click its name to display details about it.
  5. Under Resources, click Updates.

    The Oracle Provided Database Software Images tab displays generally-available Oracle Database software images that you can use to patch your database. Oracle images that can be used for patching have the update type of "Patch".

    The Custom Database Software Images tab allows you to select a database software image that you have created in advance. Use the Select a Compartment selector to specify the compartment that contains the database software image. Custom images that can be used for patching have the update type of "Patch".

  6. Review the list of database software images that you can use to patch your database. We recommend using the latest database software image patch when possible.
  7. Click the Actions icon (three dots) for the patch you are interested in, and then select one of the following actions:

    • Precheck: Check for any prerequisites to ensure that the patch can be successfully applied.
    • Apply: Performs the precheck, and then applies the patch.
  8. Confirm when prompted.
  9. In the list of patches, click the patch name to display its patch request and monitor the progress of the patch operation.

    While a patch is being applied, the patch's status displays as Applying and the database's status displays as Updating. If the operation completes successfully, the patch's status changes to Applied and the database's status changes to Available.

To view the patch history of a database

Each patch history entry represents an attempted patch operation and indicates whether the operation was successful or failed. You can retry a failed patch operation. Repeating an operation results in a new patch history entry.

Note

Patch history views in the Console do not show patches that were applied by using command line tools like dbcli or the Patch utility.
  1. Open the navigation menu. Click > Databases > Bare Metal, VM, and Exadata.
  2. Choose your Compartment.

    A list of DB systems is displayed.

  3. To display details about the DB system where the database is located, and click the system name.

    A list of databases is displayed.

  4. To display details about the database you are interested in, locate the system name and click it.
  5. Under Resources, click Update History.

    The history of patch and upgrade operations for that database is displayed.

Applying Interim Patches Manually

Note

This topic applies only to database homes in 1-node and 2-node RAC DB systems.

To apply an interim patch (previously known as a "one-off" patch) to fix a specific defect, follow the procedure in this section. Use the Opatch utility to apply an interim patch to a database home.

To apply an interim patch to a database home
Note

In the procedure example, the database home directory is /u02/app/oracle/product/12.1.0.2/dbhome_1 and the patch number is 26543344.
  1. Obtain the applicable interim patch from My Oracle Support.
  2. Review the information in the patch README.txt file. This file might contain additional and/or custom instructions to follow to apply the patch successfully.
  3. Use SCP or SFTP to place the patch on your target database.
  4. Shut down each database that is running in the database home.

    srvctl stop database -db <db name> -stopoption immediate -verbose
  5. Set the Oracle home environment variable to point to the target Oracle home.

    sudo su - oracle
    export ORACLE_HOME=/u02/app/oracle/product/12.1.0.2/dbhome_1 
    
  6. Change to the directory where you placed the patch, and unzip the patch.

    
    cd <work_dir_where_opatch_is stored>
    unzip p26543344_122010_Linux-x86-64.zip 
    
  7. Change to the directory with the unzipped patch, and check for conflicts.

    
    cd 26543344 
    $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
    
  8. Apply the patch.

    
    $ORACLE_HOME/OPatch/opatch apply
    
  9. Verify that the patch was applied successfully.

    $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
  10. If the database home contains databases, restart them.

    $ORACLE_HOME/bin/srvctl start database -db <db_name>

    Otherwise, run the following command as root user.

    # /u01/app/<db_version>/grid/bin/setasmgidwrap o=/u01/app/oracle/product/<db_version>/dbhome_1/bin/oracle
  11. If the readme indicates that the patch has a sqlpatch component, run the datapatch command against each database.

    Before you run datapatch, ensure that all pluggable databases (PDBs) are open. To open a PDB, you can use SQL*Plus to execute ALTER PLUGGABLE DATABASE <pdb_name> OPEN READ WRITE; against the PDB.

    
    $ORACLE_HOME/OPatch/datapatch