Applying Patches on Oracle 12c Guide

This is an overview procedure on how to apply Oracle Patches (PSU) on Oracle 12cR1 databases (12.1.0.2). Its very important that you read the official documentation (readme.html) that is being provided with the patch being released in case oracle is listing new requirements.

********* STEPS for Applying PSU on 12c in Unix environment:

1.first collect preliminary database information and spool it in a file.

make a directory and call it before_patch: mkdir before_patch

cd before_patch

sqlplus ‘/as sysdba’

set pages 300
set lines 250
col owner for a17;
col object_name for a35;
col object_type for a20;
col action for a15;
col comments for a40;
col comp_name for a40;
col version for a15;

spool before_patch.log
SELECT NAME FROM V$DATABASE;
SELECT * from V$VERSION;
SELECT ACTION,VERSION,COMMENTS FROM SYS.REGISTRY$HISTORY;
SELECT * from dba_registry_sqlpatch;
SELECT COMP_NAME,VERSION,STATUS FROM DBA_REGISTRY;
select count(*) from dba_objects where status = ‘INVALID’;
select owner, count(*) from dba_objects where status <>’VALID’ group by owner order by 1;
Select owner, object_type, object_name
from dba_objects where status <>’VALID’ order by 1,2,3;
spool off

2. edit your Oracle inventory and make sure its pointing to the right location

3.shutdown listener and shutdown the database.

you can check the database listener name in your server by executing the unix command: ps -ef |  gep inh

or going directly to $ORACLE_HOME/network/admin and executing the command: lsnrctl stop listener_db1

4. in 12c the patches are being setup depending if you have JAVA component in your database or not.

For 12.1.0.2 if there is no JAVA component
go to the location of the patch:

cd ../20834354/20299023
then execute the OPatch utiltiy
OPatch/opatch apply -invPtrLoc /etc/oraInst.loc

For 12.1.0.2 if JAVA component exists
cd ../20834354/20415564
Opatch/12.1.0.1.7/OPatch/opatch apply -invPtrLoc /etc/oraInst.loc

*** the output will be similar to this:

Do you want to proceed? [y|n]
Y
Email address/User Name:
Press enter

You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]:
Yes

Is the local system ready for patching? [y|n]
Y

5. Run Bundle

##### To run the bundle for 12.1.0.2 FOR NON-JAVA
sqlplus ‘/as sysdba’
STARTUP
exit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
—–Please make sure you receive the following message “Patch 20299023 apply: SUCCESS
sqlplus ‘/as sysdba’
col PRODUCT for a60;
col VERSION for a10;
col STATUS for a15;
col description for a60;
col action_time for a30;
set lines 133
select patch_id, version, status, description, action_time from dba_registry_sqlpatch order by 1;

##### To run the bundle for 12.1.0.2 FOR JAVA
sqlplus ‘/as sysdba’
STARTUP UPGRADE
QUIT
cd $ORACLE_HOME/OPatch
./datapatch –verbose
sql
shutdown immediate
STARTUP

6. Post Patching
cd
mkdir after_patch
cd after_patch
sql
sqlplus ‘/as sysdba’
col action for a15;
col comments for a40;
col comp_name for a40;
col version for a15;
set pages 300
set lines 300

spool after_patch.log
select name from v$database;
select * from v$version;
select ACTION,VERSION,COMMENTS from sys.registry$history;
select COMP_NAME,VERSION,STATUS from dba_registry;
select * from dba_registry_sqlpatch;
select count(*) from dba_objects where status = ‘INVALID’;
select owner, count(*) from dba_objects where status <>’VALID’ group by owner order by 1;
Select owner, object_type, object_name
from dba_objects where status <>’VALID’ order by 1,2,3;
spool off

Moving datafiles online in 12c

I want to share with you a very good new feature in 12c , you can now move “datafiles” ONLINE while applications are performing DML operations.

In 11g we used to put tablespace offline, then use the operating system “mv” command to move the datafile from one directory to another then use the command:

ALTER TABLESPACE RENAME ‘/orad08/oradbd14/DUMMY_SM.ORA’ TO ‘/orad07/oradbd14/DUMMY_SM.ORA’;

The drawback was that there is an outage while performing this operation.

Now, in 12c you can perform this operation ONLINE whit no issues.

To illustrate:

A tablepsace TS_DUMMY is currently having a datafile under orad07 directory

tablespace dummy

Executing the command:

SQL> ALTER DATABASE MOVE DATAFILE ‘/orad07/oradbd14/DUMMY_SM.ORA’ TO ‘/orad10/oradbd14/DUMMY_SM.ORA’;

alter database command

NOW the data file has been relocated after the successful execution of the command:

dummy after re-location

Another option is using the same command with the keyword “KEEP” which copies the datafile to the destination directory but keeps the datafile in original directory. However, the default tablespace will reflect the new moved data file !

SQL> ALTER DATABASE MOVE DATAFILE ‘/orad10/oradbd14/DUMMY_SM.ORA’ TO ‘/orad09/oradbd14/DUMMY_SM.ORA’ KEEP;

keep option

2 datafiles exist in both directories

datafile both exists

Default datafile will be the moved one

default data file

You can’t do that with TEMP datafile or Archive,…etc

trying to move tmep datafile

Oracle 12c database password file

one of the new features in 12c is having the passwords in the password file being by default case sensitive. also, you can configure password file for the new system account users (SYSDG—-> for data guard, SYSBACKUP —-> for backup operations and administration)

Example of password file command:

orapwd file=EMO_DB_PASS entries=10 sysbackup=y sysdg=y

*** the  EMO_DB file (password file) will be created in the directory where you are currently in.

password file command

as shown in the above picture passwords are required to be entered for SYS,SYSBACKUP,SYSDG accounts.

the following command will be executed to access the database as SYSDG user for verification:

sqlplus SYSDG/cocoChannel7 as SYSDG

sqlplus example

Oracle Export Errors ORA-31693 ORA-29913 ORA-21700

While checking the export of status of one of my supported databases (11gR2), i found out the log file has the below errors:

ORA-31693: Table data object “SYSTEM”.”SCHEDULER_PROGRAM_ARGS” failed to load/unload and is being skipped due to error:

ORA-29913: error in executing ODCIEXTTABLEPOPULATE callout

ORA-21700: object does not exist or is marked for delete

To Resolve this error:

the error shows that you have dropped an object that has dependencies, so you need to re-create it and then drop it.

or directly drop the scheduler objects as shown below.

connect / as sysdba
exec dbms_scheduler.drop_program(‘JDM_BUILD_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_EXPLAIN_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_EXPORT_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_IMPORT_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_PREDICT_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_PROFILE_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_SQL_APPLY_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_TEST_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_XFORM_PROGRAM’);
exec dbms_scheduler.drop_program(‘JDM_XFORM_SEQ_PROGRAM’);

impdp ORA-39097 ORA-39065 ORA-56935

While performing an import, I faced the below error:

ORA-39097: Data Pump job encountered unexpected error
ORA-39065: unexpected master process exception in DISPATCH
ORA-56935: existing datapump jobs are using a different version of time zone data file

Solution:

Check the value of  DST_UPGRADE_STATE by the following query:

SELECT PROPERTY_NAME, SUBSTR (property_value, 1, 30) value
FROM DATABASE_PROPERTIES
WHERE PROPERTY_NAME LIKE ‘DST_%’
ORDER BY PROPERTY_NAME;

Then try executing the following:

ALTER SESSION SET EVENTS ‘30090 TRACE NAME CONTEXT FOREVER, LEVEL 32’;
exec dbms_dst.unload_secondary;

Re-execute the query:

SELECT PROPERTY_NAME, SUBSTR (property_value, 1, 30) value
FROM DATABASE_PROPERTIES
WHERE PROPERTY_NAME LIKE ‘DST_%’
ORDER BY PROPERTY_NAME;

****check the value of  DST_UPGRADE_STATE should be NONE

Installing Oracle Database 12c in IBM AIX environment

The following is a “general purpose” procedure for 12cR1 binary instillation on AIX environment. you still need to refer to Oracle official documentation for further details and clarification.

******** Pre-requisites:

1. Operating System:

Oracle recommends that you install on AIX 6.1 Technology Level 9 or later.

AIX 7.1 Technology Level 1 Service Pack 3 (“7100-01-03-1207”) or later, 64-bit kernel

Note: You can install on AIX 7.1 Technology Level 1, but Oracle recommends that you install on AIX 7.1 Technology Level 3 or later.

2. User Profile , make sure that your profile is referencing to the right new Oracle Home.

3. check your Oracle Inventory file and the correct path.

Instillation Process:

Start the installation by running ./runInstaller from the installation directory

1

2

Choose “YES”

3

choose “skip software updates”

4

5

6

8 - original

15 14 - original 13 12 - original 10 9 8 - original 6 5 4 2 1 3

Oracle Database 11g future patches

for any Professional DBA, applying patches is an essential and crucial process. So, to get to the point.

Oracle Database (11.2.0.3) Last patch set will be released on July 2015 !

Oracle Database (11.2.04) Last patch set will be released on January 2018 !

This shows that Oracle are pushing people to go to 12c (my humble opinion) .

Oracle Database 12c: Extended Datatypes

The datatypes of varchar2, NVARCHAR2 has increased from 4000 bytes to 32767 bytes in 12c.

After the upgrade if you try to create a table with the new size you can’t do that directly:

create table mousaem.tab1 (id number,text varchar2(32767 byte));

You will receive the below error:

1

To enable this feature:

1.You first need to make sure that the parameter “COMPATIBLE=12.1.0” is added to your init.ora file. usually the initialization parameter file is located under Oracle Home then dbs file system in (unix/linux) environments.

COMPATIBLE=12.1.0

2. Then, add the following parameter in your init.ora file

         max_string_size=EXTENDED

3.Then you need to shut down the database

4.Then startup in “upgrade” mode

2

5.Then execute the script:

@?/rdbms/admin/utl32k.sql

6.Then shutdown the database normally

SQL> shutdown immediate

7.Then “startup” normally and check the parameter

3

Now Try re-creating the table again ………. created successfully!!!!!

4

you can double check it from TOAD or Sql developer:

5

Interesting New Feature 😉