Oracle 12c introduced a new utility which replaces the need to run post installation SQL scripts after a database patch is applied. This new utility is called "Datapatch" and it is shipped with 12c binaries as a component of OPatch distribution.
"Datapatch" is very useful in multitenant environments where multiple PDBs (Pluggable Databases) must be patched together.
Checking the current database patch level
In order to check your current database patch level, execute datapach utility adding -verbose parameter as follows:
[oracle@ora12c ~]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 12.2.0.0.0 on Wed Mar 18 17:19:22 2015
Copyright (c) 2014, Oracle. All rights reserved.
Connecting to database...OK
Determining current state...done
Current state of SQL patches:
Adding patches to installation queue and performing prereq checks...
Installation queue:
Nothing to roll back
Nothing to apply
SQL Patching tool complete on Wed Mar 18 17:19:32 2015
Patching in a multitenant environment
Now, let's proceed with a real case installing last PSU JAN2015 in a 12c multitenant environment.
Download the PSU JAN2015 from MOS. Then verify prerequisites for PSU executing "opatch prereq" command as follows:
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.1.0.1.0
Copyright (c) 2012, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /oraclebin/app/oracle/product/database/12c1
Central Inventory : /oraclebin/app/oracle/product/database/oraInventory
from : /oraclebin/app/oracle/product/database/12c1/oraInst.loc
OPatch version : 12.1.0.1.0
OUI version : 12.1.0.1.0
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
Once prerequisites were verified, shutdown anything running against the Oracle home:
[oracle@ora12c 19769486]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 19 15:42:22 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
[oracle@ora12c 19769486]$ lsnrctl stop
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-MAR-2015 15:45:36
Copyright (c) 1991, 2013, Oracle. All rights reserved.
The command completed successfully
Continue applying PSU JAN2015 patch executing "opatch apply" command as usual:
[oracle@ora12c 19769486]$ $ORACLE_HOME/OPatch/opatch apply Oracle Interim Patch Installer version 12.1.0.1.0
Copyright (c) 2012, Oracle Corporation. All rights reserved.
Oracle Home : /oraclebin/app/oracle/product/database/12c1
Central Inventory : /oraclebin/app/oracle/product/database/oraInventory
from : /oraclebin/app/oracle/product/database/12c1/oraInst.loc
OPatch version : 12.1.0.1.0
OUI version : 12.1.0.1.0
Applying interim patch '19769486' to
OH '/oraclebin/app/oracle/product/database/12c1'
Verifying environment and performing prerequisite checks...
Patch 19769486:
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME
on the local system.
(Oracle Home = '/oraclebin/app/oracle/product/database/12c1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Patching component oracle.network.rsf, 12.1.0.1.0...
Patching component oracle.ldap.rsf, 12.1.0.1.0...
Patching component oracle.precomp.common, 12.1.0.1.0...
Patching component oracle.ovm, 12.1.0.1.0...
Patching component oracle.ldap.rsf.ic, 12.1.0.1.0...
Patching component oracle.rdbms.deconfig, 12.1.0.1.0...
Patching component oracle.xdk, 12.1.0.1.0...
Patching component oracle.rdbms.util, 12.1.0.1.0...
Patching component oracle.rdbms, 12.1.0.1.0...
Patching component oracle.rdbms.dbscripts, 12.1.0.1.0...
Patching component oracle.nlsrtl.rsf, 12.1.0.1.0...
Patching component oracle.xdk.parser.java, 12.1.0.1.0...
Patching component oracle.oraolap, 12.1.0.1.0...
Patching component oracle.rdbms.rsf, 12.1.0.1.0...
Patching component oracle.xdk.rsf, 12.1.0.1.0...
Patching component oracle.rdbms.rman, 12.1.0.1.0...
Patching component oracle.precomp.lang, 12.1.0.1.0...
Patching component oracle.ordim.client, 12.1.0.1.0...
Patching component oracle.ordim.jai, 12.1.0.1.0...
Patching component oracle.rsf, 12.1.0.1.0...
Verifying the update...
Patch 19769486 successfully applied
OPatch succeeded.
Verify all patches that were recently installed executing "opatch lsinventory" command:
[oracle@ora12c 19769486]$ $ORACLE_HOME/OPatch/opatch lsinventory
Oracle Interim Patch Installer version 12.1.0.1.0
Copyright (c) 2012, Oracle Corporation. All rights reserved.
Oracle Home : /oraclebin/app/oracle/product/database/12c1
Central Inventory : /oraclebin/app/oracle/product/database/oraInventory
from : /oraclebin/app/oracle/product/database/12c1/oraInst.loc
OPatch version : 12.1.0.1.0
OUI version : 12.1.0.1.0
---------------------------------------------------------------------------
Installed Top-level Products (1):
Oracle Database 12c 12.1.0.1.0
There are 1 products installed in this Oracle Home.
Interim patches (1) :
Patch 19769486 : applied on Thu Mar 19 16:06:38 ART 2015
Unique Patch ID: 18246488
Patch description: "Database Patch Set Update : 12.1.0.1.6 (19769486)"
Created on 30 Dec 2014, 09:04:11 hrs PST8PDT
Bugs fixed:
18093615, 17716305, 17257820, 17034172, 16694728, 16042673, 18096714
17439871, 16320173, 14664684, 17762256, 18002100, 18436307, 16450169
17006570, 17753428, 17552800, 15994107, 17441661, 17305959, 18362376
17997255, 17710315, 14506328, 17806676, 17443596, 17040764, 16849982
16837842, 14010183, 18393024, 16845022, 16228604, 17446564, 17042658
14536110, 17579911, 18262334, 17311728, 17391312, 17244462, 16935643
18641419, 17039360, 14355775, 18155703, 16672859, 18229326, 17080436
17912217, 16788832, 16039096, 16570023, 18099539, 14123213, 17174391
17405549, 17830435, 17249820, 16946990, 16589507, 16924879, 16874123
17750832, 16784143, 15987992, 17346196, 16901482, 16859937, 17898041
17068536, 16910001, 17946998, 16527374, 17394724, 17572720, 16703112
17490498, 16433869, 16186165, 16170787, 16524968, 17032726, 16543323
17349104, 18355572, 17888553, 16575931, 18061914, 16070351, 17088068
16888264, 16448848, 16863422, 17443671, 18308576, 16911800, 16517900
16825779, 17019974, 16707927, 17551812, 14576755, 17263661, 17325413
17446849, 16465149, 17184677, 16689109, 16705020, 18889652, 17828499
16964279, 15953721, 17205719, 18603606, 18121501, 16757934, 16864562
16782193, 17436936, 15996344, 17037526, 17260090, 19556045, 17216406
17659488, 16485876, 16709437, 17898730, 18641461, 17174582, 16796277
17421502, 17534365, 16921340, 16784167, 18292893, 16660558, 16793174
16371304, 20074391, 17570606, 16943711, 16674666, 19197175, 16697600
17848854, 18522516, 17797837, 17716565, 16456371, 16347068, 16181570
19121550, 17516005, 16275522, 16475788, 16683859, 17491753, 16427054
16227068, 17753514, 16479182, 18554871, 17051636, 16263492, 16551086
18856947, 19866250, 16406802, 16433745, 16681689, 17614134, 17364702
17171530, 17298973, 16212405, 19049453, 18189497, 16443657, 16855202
18078926, 18244962, 17462687, 16087650, 16313881, 16992075, 17082983
17359546, 14595800, 16715647, 19554106, 17362796, 17777061, 16392068
17761775, 16977973, 17158214, 14197853, 16712618, 12911115, 17922172
16524071, 16856570, 17050888, 16410570, 17210416, 13866822, 18513099
16372203, 17867137, 16101465, 15914210, 16459685, 16802693, 16195633
16978185, 19309466, 17983206, 16787973, 16850996, 16178562, 16838328
16503473, 18126350, 13782826, 18439152, 17537657, 17721717, 17489214
16362358, 16994576, 17600719, 17461374, 16969016, 17571945, 16444683
16928832, 16929165, 16710753, 16864359, 16679874, 18031528, 16585173
15986012, 17467075, 17735933, 14852021, 16191248, 19692901, 16173738
17797453, 17343514, 16495802, 17324822, 16619249, 19297295, 16590848
15921906, 16986421, 17316776, 16576250, 16730813, 16433540, 16663303
18420490, 16619979, 17897716, 17016479, 16457621, 16675739, 17341326
17981677, 17005047, 17442449, 16795944, 16668226, 16698577, 16621274
17330580, 18348157, 17393683, 17817656, 16634384, 16465158, 16816103
16910734, 16584684, 16936008, 16347904, 16512817, 17273253, 16902138
17179261, 17810688, 16864048, 17468141, 17226980, 17883081, 16682595
16473934, 16762985, 16864864, 16721594, 16946613, 16972213, 16855292
17026503, 16964686, 17860549, 16674842, 13771513, 16061921, 17235750
16842274, 16913149, 16769019, 17000176, 15931910, 17572525, 17478145
14237793, 19248799, 17976046, 17289787, 16919176, 16613964, 17217040
16462834, 18092561, 16617325, 17308691, 16733884, 16483559, 16057129
16286774, 16822629, 17596344, 19289642, 17954431, 18423374, 16993424
17605522, 17280117, 19769486, 18436647, 8352043, 18973907, 16772060
16790307, 16991789, 17608025, 19006849, 18082092, 20128874, 16603924
18148383, 17182200, 16784901, 16912439, 18641451, 13521413, 17767676
17478811, 16836849, 16007562, 16851772, 16663465, 17786278, 17027533
16675710, 17437634, 19458377, 17610418, 17465741, 15905421, 17892268
16523150, 16741246, 16930325, 17982838, 17390431, 17974104
---------------------------------------------------------------------------
OPatch succeeded.
Loading Modified SQL Files into the database using Datapatch
Datapatch is run to complete the post-install SQL deployment for the PSU.
The datapatch utility will run the necessary apply scripts to load the modified SQL files into the database. Take note that an entry will be added to both DBA_REGISTRY_HISTORY and DBA_REGISTRY_SQLPATCH views.
Open a sqlplus session as sysdba and perform a database startup operation as follows:
[oracle@ora12c 19769486]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 19 17:44:35 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 2405122048 bytes
Fixed Size 2853360 bytes
Variable Size 1543505424 bytes
Database Buffers 838860800 bytes
Redo Buffers 19902464 bytes
Database mounted.
Database opened.
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options.
Now proceed with datatapach execution adding "-verbose" as argument:
[oracle@ora12c 19769486]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 12.1.0.1.0 on Thu Mar 19 17:54:46 2015
Copyright (c) 2014, Oracle. All rights reserved.
Connecting to database...OK
Determining current state...
Currently installed SQL Patches:
PDB CDB$ROOT:
PDB PDB$SEED:
PDB PDB01:
PDB PDB02:
Currently installed C Patches: 19769486
Adding patches to installation queue and performing prereq checks...
Installation queue:
For the following PDBs: CDB$ROOT PDB$SEED PDB01 PDB02
Nothing to roll back
The following patches will be applied: 19769486
Installing patches...
Patch installation complete. Total patches installed: 1
Validating logfiles...
Patch 19769486 apply (pdb CDB$ROOT): SUCCESS
logfile: /oraclebin/app/oracle/product/database/12c1/sqlpatch/19769486/..
catbundle generate logfile: /oraclebin/app/oracle/product/database/base/..
catbundle apply logfile: /oraclebin/app/oracle/product/database/base/..
Patch 19769486 apply (pdb PDB$SEED): SUCCESS
logfile: /oraclebin/app/oracle/product/database/12c1/sqlpatch/19769486/..
catbundle generate logfile: /oraclebin/app/oracle/product/database/..
catbundle apply logfile: /oraclebin/app/oracle/product/database/base/..
Patch 19769486 apply (pdb PDB01): SUCCESS
logfile: /oraclebin/app/oracle/product/database/12c1/sqlpatch/19769486/..
catbundle generate logfile: /oraclebin/app/oracle/product/database/base/..
catbundle apply logfile: /oraclebin/app/oracle/product/database/base/..
Patch 19769486 apply (pdb PDB02): SUCCESS
logfile: /oraclebin/app/oracle/product/database/12c1/sqlpatch/19769486/..
catbundle generate logfile: /oraclebin/app/oracle/product/database/base/..
catbundle apply logfile: /oraclebin/app/oracle/product/database/base/..
SQL Patching tool complete on Thu Mar 19 18:07:48 2015
From the above output, note as patch has been automatically applied to all existing container and pluggable databases:
Patch 19769486 apply (pdb CDB$ROOT): SUCCESS
Patch 19769486 apply (pdb PDB$SEED): SUCCESS
Patch 19769486 apply (pdb PDB01): SUCCESS
Patch 19769486 apply (pdb PDB02): SUCCESS
Finally, you can verify in DBA_REGISTRY_SQLPATCH that patch has been applied successfully:
SQL> SELECT patch_id, status
2 FROM dba_registry_sqlpatch;
PATCH_ID STATUS
---------- ---------------
19769486 SUCCESS