What is OPatch?

OPatch is an Oracle supplied utility to assist you with the process of applying interim patches to Oracle's software. OPatch is a Java-based utility which requires the Oracle Universal Installer to be installed. It is platform independent and runs on all supported operating systems. OPatch supports the following:

Prior to release 10.2 (OPatch for 10.2 is only compatible with 10.2 and nothing earlier), OPatch was available from MetaLink as a patch in and of itself (p2617419_10102_GENERIC.zip for release With 10.2, OPatch is installed as part of the RDBMS software.

Opatch has several options to execute it:
"lsinventory" -> Adding the lsinventory option to opatch produces a report saying the patches that were applied
"-report" -> Will report to screen and will NOT apply the real patch. Using "-report" is a good way of performing nondestructive testing of the patch installation process.
rollback" -> Will undo the patch that was applied. Example: opatch rollback –id 4667809

Applying a patch is simple as:
opatch apply <patchid>

Post-installation (post-deinstallation) steps

Don't forget to check the readme file for post-installation/deinstallation steps. In general, the post-installation steps require running of the catcpu.sql script, followed by using the utlprp.sql script used to recompile invalid objects. Is that SQL script named utlrp or utlprp? In this case, the README file says utlprp, whose function is essentially the same as that of utlrp. What is the difference between the scripts? As it turns out, utlrp simply calls utlprp. The deinstallation tasks are nearly identical, with the main difference being that you use the catcpu_rollback SQL script.

For Patch 4667809, the catcpu/catcpu_rollback scripts are related to applying and unapplying changes related to the OWA toolkit (OWA = Oracle Web Agent, which uses modplsql, which uses PL/SQL to generate dynamic Web pages, and that's why you see modplsql in the patch-related files folders).

Example Applying Patch 4751921
After the Patch is Installed:
1.Log in as sys as sysdba.
2. cd $ORACLE_HOME/rdbms/admin
3. spool catpatch_database_name
4. shutdown immediate
5. startup migrate
6. @catpatch.sql   ( this takes at least 1 hour ). After catpatch completed,
7. select object_name,owner from dba_objects where ststus='INVALID';
8. @utlrp.sql
9.select object_name,owner from dba_objects where ststus='INVALID';   ( YOU WILL GET near 0 invalid objects )
10. shutdown immediate;
11. startup

One other useful Opatch feature

Along with the log and inventory files, Opatch output includes a history file, which contains date and action performed information. The history file is named opatch_history.txt and is located in the $OH\cfgtools\opatch directory. As an example of its contents, the "rollback –help" action performed earlier was recorded as:

Date & Time : Sun Dec 18 12:00:50 MST 2005
Oracle Home : C:\oracle\product\10.2.0\db_1
OPatch Ver. :
Current Dir : C:\
Command     : rollback -help
Log File    : $OH\cfgtoollogs\opatch\opatch-<date>.log

So, as yet another way to answer the "what patches are installed" question, you can use the OPatch history file.