P. 1
Oracle 11g Nf 1.0

Oracle 11g Nf 1.0

|Views: 1,031|Likes:
Published by Ramu Spl

More info:

Published by: Ramu Spl on May 10, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/12/2013

pdf

text

original

Sections

  • Installation, Database Upgrades and Change Management
  • Installation New Features Support
  • Role and Privilege Changes
  • Deprecated Components
  • New Initialization Parameters Affecting Database Creation
  • DBCA Enhancements
  • Upgrading to Oracle Database 11g
  • Database Replay
  • The SQL Performance Analyzer
  • Patching in Oracle Database Control
  • Database Diagnosis and Repair
  • Introducing Automatic Diagnostic Repository (ADR)
  • Configuring the ADR
  • Using adrci Tool
  • Using The Support Workbench in the OEM
  • Using SQL Repair Advisor
  • Database Health Monitor
  • Data Recovery Advisor
  • SQL Test Case Builder
  • Data Block Corruption Parameters
  • Automatic Memory Management
  • Automatic Maintenance Tasks
  • New Automatic Maintenance Task
  • Oracle Flashback-Related New Features
  • LogMiner Interface in Oracle Enterprise Manager
  • Oracle Flashback Transaction Backout
  • Flashback Data Archive
  • Virtual Columns
  • New Data Partitioning Schemes
  • DDL Lock Timeout
  • Explicit Locking of Tables
  • Invisible Indexes
  • Read-Only Tables
  • Deferred Segment Creation
  • Shrinking Temporary Tablespaces and Tempfiles
  • Creating an Initialization Parameter File from Memory
  • Restore Point Enhancements
  • Database Resident Connection Pooling
  • Comparing and Synchronizing Database Objects
  • Online Application Maintenance
  • Oracle Advanced Compression Option
  • Oracle Scheduler New Features
  • Lightweight Jobs
  • Remote External Jobs
  • Monitoring Job State with Email Notifications
  • File Watcher
  • Finer-grained Dependency Management
  • Enhancements in Oracle Database Resource Manager
  • Dropping Unused Object Storage
  • PL/SQL Native Compilation
  • Server Result Cache
  • PL/SQL Function Result Cache
  • Enhanced Oracle Process Monitoring
  • Subprogram Inlining
  • SQL Tuning Automation
  • SQL Access Advisor Enhancements
  • Changing Statistics Preferences
  • Enhanced Statistics Maintenance
  • SQL Plan Management
  • ADDM New Features
  • AWR New Features
  • Setting Metric Thresholds for Baselines
  • Setting Metric Thresholds for Selected Baselines
  • Performance-Related Changes in Database Control
  • Miscellaneous New Performance Tuning Features
  • Real-Time SQL Monitoring
  • Adaptive Cursor Sharing
  • Stronger Password Hash Algorithm
  • Security Out of the Box
  • Case-Sensitive Password Files
  • Anti Network Attacks Parameters
  • Fine-Grained Access Control for UTL_* Packages
  • Further Security New Features
  • Backup and Recovery New Features
  • Enhanced Block Media Recovery
  • RMAN Substitution Variables
  • New RMAN Configuration Parameters
  • Creating Archival Backups
  • VALIDATE Command
  • Configuring an Archived Redo Log Deletion Policy
  • Active Database Duplication
  • Importing and Moving Recovery Catalogs
  • Compression Enhancement
  • Reusing a Dump File
  • Automatic Storage Management (ASM)
  • SYSASM Privilege and OSASM Group
  • ASM Fast Mirror Resync
  • asmcmd Utility Commands
  • Oracle Direct NFS
  • PL/SQL New Features
  • SecureFiles
  • Partitioning Improvements

Page 1 Oracle 11g New Features for Administrators - Summary Sheets

Oracle 11g New Features for Administrators
Summary Sheets
Version 2.1
Editor: Ahmed Baraka



Page 2 Oracle 11g New Features for Administrators - Summary Sheets


Usage Ter ms
• Anyone is can copy t his document t o any means of st orage and present it in any f ormat t o any individual
or organizat ion f or non- commercial purpose f ree.
• No individual or organizat ion may use t his document f or commercial purpose wit hout a writ t en permission
f rom t he edit or.
• There is no warrant y of any t ype f or t he code or inf ormat ion present ed in t his document . The edit or is not
responsible f or any loses or damage result ed f rom using t he inf ormat ion or execut ing t he code in t his
document .
• I f any one wishes t o correct a st at ement or a t yping error or add a new piece of inf ormat ion, please send
an email message t o i nf o@ahmedbar ak a. com

Ver si on Hi st or y
Ver si on Dat e Updat es
1.0
23- Mar- 2008 I nit ial document .
1.1
29- Apr- 2008 - Mapping exam obj ect ives t o t he document t opics
- Fixing caught bugs in t he code examples.
- Fixing caught errat a and mist akes in some st at ement s.
- Adding new t opics.
1.15
12- Sep- 2008 - Furt her explanat ion on using t he new PIVOT operat or.
- Adding minor det ails in some sect ions.
1.2
10- Oct - 2008 - Adding t he sect ion "Adapt ive Cursor Sharing"
- Adding minor det ails in some sect ions.
- Fixing caught errat a and mist akes in some st at ement s.
1.3
01- Mar- 2010 - Adding minor det ails in some sect ions.
2.0
23- Dec- 2010 - Adding Oracle 11g Release 2 New Feat ures
- Removing t he st at ement "t hat virt ual column cannot be a part of part it ioning key
column". Thanks t o Arshad Taqvi.
2.1
22- Jan- 2010 - Removing t he inf ormat ion about FIXED_DATE paramet er as it is not a new f eat ure.
Thanks t o Bhalla Ravinder.

Document Pur pose
This document aims at brief ly explaining Oracle Dat abase 11g New Feat ures wit h concent rat ion on t he pract i cal
code. I t discusses new f eat ures relat ed t o dat abase administ rat ion and applicat ion development . The document i s
edit ed so t hat it concent rat es on t he f ollowing:
• Brief descript ion of t he concept s. This includes:
o New t erms and def init ions.
o Signif icant advant ages and/ or disadvant ages
o Concept limit at ions and precaut i ons
• Code examples
On t he ot her hand, t he document avoids t he f ollowing:
• Det ailed explanat ion of t he concept s
• Det ails of using Oracle Grid Cont rol in i mplement ing t he concept s.


Page 3 Oracle 11g New Features for Administrators - Summary Sheets

What i s not cov er ed?
The document discussed new f eat ures in Oracle 11g in only t he t opics as st at ed in t he cont ent s sect ion. New
f eat ures int roduced in ot her areas are not covered. To ment i on some of t hem, t his document does not cover t he
new f eat ures in t he f ollowing areas:
• Oracle St reams
• Dat a Guard
• Oracle RAC
• Oracle XML DB
Pr er equi si t e
To be able t o get advant age of reading t his document , you must have solid knowledge on Oracle dat abase 10g
administ rat ion.
Ter ms and Acr ony ms Used
Following are list of t he t erms and acronyms used in t his document :
Ter m / Acr on y m Mean i n g
Oracle 11g Whenever Oracle 11g is ment ioned in t his document , it is meant t o be Oracle Dat abase
11g.
ADR Aut omat ic Diagnost ic Reposit ory
Oracle Grid Cont rol Oracle Grid Cont rol, Dat abase Cont rol or Oracle Ent erpri se Manager ( OEM) are used
int erchangeably in t his document .
Conv ent i ons i n t he Document
When you are asked t o click on several links in t he Ent erprise Manager, t he t erm "f ollow t he links" is used. For
example, consider t he f ollowing st at ement :
To manage creat ed SQL pat ches, f ollow t he links Dat abase Home page> Ser ver t ab> Qu er y Opt i mi zer
sect i on > SQL Pl an Con t r ol > SQL Pat ch t ab
This st at ement means, in t he Dat abase Home page you click Ser ver t ab where you will see Qu er y Opt i mi zer
sect ion. Then you click on SQL Pl an Con t r ol and t hen on t he SQL Pat ch t ab.
Resour ces
S/ N Resou r ce Ty pe Resou r ce Nam e
1 Book Oracle Dat abase 11g New Feat ures f or DBAs and Developers, by Sam R. Alapat i
and Charles Kim, Apress, I SBN: 978- 1- 59059- 910- 5
2 Book Oracle Dat abase 11g New Feat ures by Rober G. Freeman, Oracle Press
3 Oracle Of f icial
Document at ion
• Oracle Dat abase New Feat ures Guide 11g Release 2 ( 11. 2) E17128- 03
• Oracle Dat abase New Feat ures Guide 11g Release 1 ( 11. 1) B28279- 02
• Oracle Dat abase Administ rat or' s Guide 11g Release 1 ( 11. 1) B28310- 03
• Oracle Dat abase Perf ormance Tuning Guide 11g Release 1 ( 11. 1) B28274- 01
• Oracle Dat abase Backup and Recovery User' s Guide 11g Release 1 ( 11. 1)
B28270- 02
• Oracle Dat abase PL/ SQL Packages and Types Ref erence 11g Release 1 ( 11. 1. )
B28419- 02
• Oracle Dat abase High Availabilit y Overview 11g Release 1 ( 11. 1) B28281- 01
• Oracle Dat abase St orage Administ rat or' s Guide 11g Release 1 ( 11. 1) B31107- 03
• Oracle Dat abase PL/ SQL Language Ref erence 11g Release 1 ( 11. 1) B28370- 02
• Oracle Dat abase VLDB and Part it ioning Guide 11g Release 1 ( 11. 1) B32024- 01
• Oracle Dat abase SecureFiles and Large Obj ect s Developer' s Guide 11g Release 1
Page 4 Oracle 11g New Features for Administrators - Summary Sheets

( 11. 1) B28393- 02
4 Oracle Met alink The f ollowing document s were ref erenced:
• Not e: 453487. 1 Tit le: 11g New Feat ures : Top 5 Feat ures I n 11g
• Not e: 454631. 1 Tit le: 11g DBCA New f eat ures / Enhancement s
• Not e: 445116. 1 Tit le: Usi ng t he workload capt ure and replay in 11G
• Not e: 470199. 1 Tit le: 11g f eat ure: Flashback Dat a Archive Guide
• Not e: 444149. 1 Tit le: New Background Processes I n 11g
• Not e: 432776. 1 11g New Feat ure : Transparent Dat a Encrypt ion at Tablespace
Level
5 Web Sit e www. oracle- base. com
6 Web Sit e www. psoug. org
7 Web Sit e www. oraf aq. com
8 Web Sit e ht t p: / / t echnol ogy. amis. nl
9 Web Sit e ht t p: / / decipherinf osys. wordpress. com/ 2007/ 12/ 03/ oracle- 11g- cross- t ab- report -
using- pivot - and- unpivot - operat or
10 Web Sit e ht t p: / / www. f adalt i . com/ oracle/ dat abase/ oracle_dat abase_11g_new_f eat ures. ht m
11 Art icles by Arup
Nanda
ht t p: / / www. oracle. com/ t echnol ogy/ pub/ art icles/ oracle- dat abase- 11g- t op-
f eat ures/ index. ht ml
12 Blog Sit e ht t p: / / bar- solut ions. com/ wordpress/
13 Blog Sit e ht t p: / / virag. shar ma. googlepages. com/ 11g
14 Blog Sit e ht t p: / / viveklsharma. blogspot . com
15 Blog Sit e ht t p: / / ant ognini. ch/ blog
Page 5 Oracle 11g New Features for Administrators - Summary Sheets

Cont ent s

I nst al l at i on, Dat abase Upgr ades and Change Management 9
I nst allat ion New Feat ures Support ______________________________________________________ 9
Role and Privilege Changes ____________________________________________________________ 9
Deprecat ed Component s _____________________________________________________________ 10
New I nit ial izat i on Paramet er s Af f ect ing Dat abase Creat ion __________________________________ 10
DBCA Enhancement s ________________________________________________________________ 11
Upgrading t o Oracle Dat abase 11g _____________________________________________________ 11
Dat abase Replay ___________________________________________________________________ 13
The SQL Perf ormance Analyzer ________________________________________________________ 17
Pat ching in Oracle Dat abase Cont r ol ____________________________________________________ 21
Dat abase Di agnosi s and Repai r _________ 22
I nt r oducing Aut omat ic Di agnost i c Reposit ory ( ADR) ________________________________________ 22
Conf iguring t he ADR ________________________________________________________________ 22
Using adrci Tool ____________________________________________________________________ 22
Using The Support Workbench in t he OEM _______________________________________________ 24
Dat abase Healt h Monit or _____________________________________________________________ 25
Dat a Recovery Advisor _______________________________________________________________ 26
SQL Test Case Builder _______________________________________________________________ 27
Dat a Block Cor rupt ion Paramet ers _____________________________________________________ 28
Dat abase Admi ni st r at i on _____________ 29
Aut omat ic Memory Management _______________________________________________________ 29
Aut omat ic Maint enance Tasks _________________________________________________________ 30
Oracle Flashback- Rel at ed New Feat ures _________________________________________________ 32
LogMiner I nt erf ace in Oracle Ent erprise Manager __________________________________________ 32
Oracle Flashback Transact ion Backout __________________________________________________ 32
Flashback Dat a Archive ______________________________________________________________ 33
Virt ual Columns ____________________________________________________________________ 35
New Dat a Part it ioning Schemes________________________________________________________ 36
DDL Lock Timeout __________________________________________________________________ 36
Explicit Locking of Tables _____________________________________________________________ 36
I nvisible I ndexes ___________________________________________________________________ 36
Read- Only Tables ___________________________________________________________________ 37
Def erred Segment Creat ion ___________________________________________________________ 37
Shrinking Temporary Tablespaces and Tempf iles __________________________________________ 37
Creat ing an I nit ializat ion Paramet er File f rom Memory ______________________________________ 38
Rest ore Point Enhancement s __________________________________________________________ 38
Dat abase Resident Connect ion Pooling __________________________________________________ 38
Comparing and Synchronizing Dat abase Obj ect s __________________________________________ 40
Page 6 Oracle 11g New Features for Administrators - Summary Sheets

SQL* Plus New Feat ures ______________________________________________________________ 41
Online Applicat ion Maint enance ________________________________________________________ 42
Oracle Advanced Compression Opt ion ___________________________________________________ 42
Oracle Scheduler New Feat ures ________________________________________________________ 43
Light weight Jobs ___________________________________________________________________ 44
Remot e Ext ernal Jobs _______________________________________________________________ 44
Monit oring Job St at e wit h Emai l Not if icat ions _____________________________________________ 45
File Wat cher _______________________________________________________________________ 47
Finer- grained Dependency Management _________________________________________________ 50
Enhancement s in Oracle Dat abase Resour ce Manager ______________________________________ 50
Enhanced TRUNCATE St at ement _______________________________________________________ 51
Dropping Unused Obj ect St orage ______________________________________________________ 52
Per f or mance Tuni ng _________________ 53
PL/ SQL Nat ive Compilat ion ___________________________________________________________ 53
Server Result Cache_________________________________________________________________ 54
Client Side Result Cache _____________________________________________________________ 56
Enhanced Oracle Process Moni t oring ____________________________________________________ 57
Subprogram I nlining ________________________________________________________________ 58
SQL Tuning Aut omat ion ______________________________________________________________ 58
SQL Access Advisor Enhancement s _____________________________________________________ 59
Changing St at ist ics Pref erences _______________________________________________________ 63
Enhanced St at ist ics Maint enance_______________________________________________________ 63
SQL Plan Management _______________________________________________________________ 66
ADDM New Feat ures ________________________________________________________________ 69
AWR New Feat ures _________________________________________________________________ 72
Set t ing Met ric Thresholds f or Baselines __________________________________________________ 74
Perf ormance- Relat ed Changes in Dat abase Cont rol ________________________________________ 74
Miscellaneous New Perf ormance Tuning Feat ures __________________________________________ 74
Real- Time SQL Monit or ing ____________________________________________________________ 75
Adapt ive Cursor Sharing _____________________________________________________________ 76
Dat abase Secur i t y ___________________ 77
St ronger Password Hash Algorit hm _____________________________________________________ 77
Securit y Out of t he Box ______________________________________________________________ 77
Ant i Net work At t acks Paramet ers ______________________________________________________ 78
Tablespace Encrypt ion _______________________________________________________________ 79
Fine- Grained Access Cont rol f or UTL_* Packages __________________________________________ 80
Furt her Securit y New Feat ures ________________________________________________________ 81
Back up and Recov er y New Feat ur es _____ 83
Enhanced Block Media Recovery _______________________________________________________ 83
RMAN Subst it ut ion Variables __________________________________________________________ 83
Page 7 Oracle 11g New Features for Administrators - Summary Sheets

New RMAN Conf igurat ion Paramet er s ___________________________________________________ 84
The Mult isect ion Backups_____________________________________________________________ 84
Creat ing Archival Backups ____________________________________________________________ 85
VALI DATE Command ________________________________________________________________ 85
Conf iguring an Archived Redo Log Delet ion Poli cy _________________________________________ 86
Act ive Dat abase Duplicat ion __________________________________________________________ 86
I mport ing and Moving Recovery Cat alogs ________________________________________________ 88
Virt ual Privat e Cat alogs ______________________________________________________________ 89
Miscellaneous New Feat ures in RMAN ___________________________________________________ 90
Dat a Pump Ut i l i t i es __________________ 91
Compression Enhancement ___________________________________________________________ 91
Encrypt ion Enhancement s ____________________________________________________________ 91
Reusing a Dump File ________________________________________________________________ 92
Remapping Dat a ___________________________________________________________________ 92
Renaming Tables During Export or I mport _______________________________________________ 92
Dat a Pump and Part it ioned Tables______________________________________________________ 92
I gnori ng Nondef erred Const raint s ______________________________________________________ 93
Ext ernal Tables Based on Dat a Pump Driver ______________________________________________ 93
Enhancement in t he Transport able Paramet er ____________________________________________ 93
Aut omat i c St or age Management ( ASM) __ 94
SYSASM Privilege and OSASM Group ___________________________________________________ 94
Upgrading ASM using DBUA __________________________________________________________ 94
Upgrading ASM Manually _____________________________________________________________ 94
ASM Rest rict ed Mode ________________________________________________________________ 95
Diskgroup At t ribut es ________________________________________________________________ 95
Checking Diskgroup _________________________________________________________________ 97
asmcmd Ut ilit y Commands ___________________________________________________________ 98
Fast Rebalance _____________________________________________________________________ 99
The FORCE opt ion wit h Dr op Diskgroup Command _________________________________________ 99
Miscellaneous ASM New Feat ures ______________________________________________________ 99
PL/ SQL New Feat ur es _______________ 101
PL/ SQL New Feat ures ______________________________________________________________ 101
Dat a War ehousi ng _________________ 107
SecureFiles _______________________________________________________________________ 107
Accessing a LOB Using SQL and PL/ SQL ________________________________________________ 108
Online Redef init ion _________________________________________________________________ 109
Part it ion Change Tr acking ( PCT) ______________________________________________________ 110
Generat ing SQL Crosst ab Report using PI VOT Operat or ____________________________________ 110
Part it ioning I mpr ovement s __________________________________________________________ 112
Page 8 Oracle 11g New Features for Administrators - Summary Sheets

Appendi x I Mappi ng Ex am 1Z0- 050 Obj ect i v es t o Document Topi cs 117
Appendi x I I Di spl ay i ng CLOB Cont ent s i n SQL Pl us 120
Page 9 Oracle 11g New Features for Administrators - Summary Sheets

I nst al l at i on, Dat abase Upgr ades and Change Management
I nst al l at i on New Feat ur es Suppor t

Following are t he changes you will f ace when inst alling Oracl e Dat abase 11g:
• Ch oosi n g Or acl e Base l o cat i on
Oracle Base ( set by t he environment variable ORACLE_BASE) is t he t op- level direct ory f or inst alling Oracle
sof t ware. Oracle Universal I nst aller now allows you t o specif y and edit Oracle base locat ion. Oracle
recommends you t o specif y t he same Oracle base f or mult iple Oracle homes.
I f you inst all Oracle dat abase 11g sof t ware wit h t he opt ion of creat ing a dat abase and you do not specif y a
value t o ORACLE_BASE, t he inst allat ion proceeds wit h t he def ault value but a message will be logged in t he
alert log f ile.
• Dat af i l e an d Fl ash Recover y Ar ea Lo cat i on s
By def ault , Dat af iles and f lash recovery area are locat ed one level below t he Oracle base locat ion. I n Oracle
10g, it is used t o be saved under Oracle home direct ory.
• Au t omat i c Di agn ost i c Reposi t o r y ( ADR)
ADR is a single direct ory locat ion f or all error and t race dat a in t he dat abase. I t replaces t he t radit ional
diagnost ic direct ories such as bdump, cdump, and udump. ADR locat ion is cont rolled by t he new init ializat ion
paramet er DIAGNOSTIC_DEST. Oracle recommends you choose t he same ADR base f or all Oracle product s.
• New Compon en t s
Following are new component s whi ch are available when inst alling Oracle 11g:
o Or acl e App l i cat i on Ex pr ess ( APEX) : APEX is a rapid applicat ion development t ool f or developing
dat abase cent ric web- based applicat ions. I n Oracle 11g, it is highly enhanced and available in t he Oracle
dat abase CD.
o Or acl e SQL Devel oper : Oracle SQL Developer is a graphical t ool f or examining dat abase obj ect s and
issuing SQL commands. I t is aut omat ically inst alled, if you creat e a t emplat e- based dat abase.
o Or acl e Real Appl i cat i on Test i n g: Oracle Real Applicat ion Test ing opt ion is aut omat ically inst alled wit h
t he Ent erprise Edit ion inst allat ion. This opt ion includes t wo solut ions t o t est t he ef f ect of t he syst em
changes on t he real- world applicat ions: Dat abase Reply and SQL Perf ormance Analyzer. Bot h of t hose
solut ions will be discussed in lat er sect ions.
o Or acl e Con f i gu r at i on Man ager ( OCM) : OCM is an opt ional component and it collect s inf ormat ion about
sof t ware conf igurat ion in t he Oracle home direct ories and uploads it t o t he Oracle conf igurat ion reposit ory.
o Or acl e War eh ou se Bu i l der : it is a business int elligence ( BI ) design t ool and is aut omat ically inst alled as
part of t he Oracle dat abase sof t ware.
o Or acl e Dat abase Vau l t : Oracle Dat abase Vault component enables you t o secure business dat a even
f rom DBAs. I n Oracle 11g, it is a component available during inst allat ion and t o inst all it , you must select
t he Cust om inst allat ion opt ion.
o Or acl e Sh adow Copy Ser vi ce: When you inst all Oracle 11g on Windows 2003 servers, a service named
as Volume Shadow Copy Service ( VSS) is inst alled. This service is an inf rast ruct ure t hat enables t he users
t o creat e snapshot s called shadow copies. For det ails on using VSS, ref er t o t he document at ion "Oracle
Dat abase Backup and Recovery User' s Guide" and Chapt er 8 in "Oracle Dat abase Plat f orm Guide f or
Microsof t Windows"
• Ot h er I n st al l Opt i on s
o Oracle Dat a Mining opt ion is select ed by def ault wit h t he Ent erprise Edit ion inst all at ion and is aut omat ically
inst alled when you creat e a dat abase.
o Oracle XML DB is now a mandat ory component and t hus it s opt ion is removed f rom t he inst allat ion.
Rol e and Pr i v i l ege Changes
I n Oracle 11g, t here is a new syst em privilege called SYSASM. This privilege should be grant ed t o users who
need t o perf orm ASM administ rat ive t asks. Also, in Oracle 11g f or Unix/ Linux operat ing syst ems, you can creat e
osasm OS group. Oracle recommends you grant ASM access only t o members of t he osasm group. For f urt her
det ails about using t his privilege, ref er t o t he chapt er "Aut omat ic St orage Management ".
CONNECT role has now only CREATE SESSION privilege. Be aware t hat if you upgrade exist ing dat abase t o version
11g, CONNECT role will be modif ied by t he upgrade script t o have only CREATE SESSION privilege.
Page 10 Oracle 11g New Features for Administrators - Summary Sheets

Depr ecat ed Component s
Following are t he component s deprecat ed in Oracle 11g:
o iSQL* Plus
o Oracle Workf low
o Oracle Ent erprise Manager Java Console
o Oracle Dat a Mining Scoring Engine
o Raw st orage support ( inst aller only)
New I ni t i al i zat i on Par amet er s Af f ect i ng Dat abase Cr eat i on
As wit h any new Oracle dat abase version, in Oracle 11g some new init ializat ion paramet ers are int roduced and
some paramet ers are deprecat ed. I n t his sect ion we will int roduce t hose new paramet ers you may set while
creat ing an Oracle 11g dat abase. Not ice t hat t his sect ion is not meant t o list all t he new init ializat ion paramet ers.
• Memor y Par amet er s
I n Oracle 11g, t he aut omat ic memory management f eat ure is developed. Bot h t he syst em global area ( SGA) and
t he program global area ( PGA) will expand and shrink based on t he inst ance demands. To enable t his f eat ure,
you set t he f ollowing new paramet ers:

MEMORY_TARGET
t his paramet er set s t he syst em- wide usable memory t hat will be used by t he inst ance
f or SGA and PGA.

MEMORY_MAX_TARGET
t his paramet er set s t he maximum value you can set f or MEMORY_TARGET paramet er.
Furt her det ails about using t hose paramet ers will be discussed in Aut omat ic Memory Management sect ion.
• Au t omat i c Di agn ost i c Reposi t o r y ( ADR)
ADR is a direct ory t hat point s t o all error dat a raised in t he dat abase. You set it by t he new paramet er
DIAGNOSTIC_DEST. I t replaces USER_DUMP_DEST, BACKGROUND_DUMP_DEST and CORE_DUMP_DEST paramet ers.
DIAGNOSTIC_DEST def ault s t o t he f ollowing value: $ORACLE_BASE/ diag/ rdbms/ $I NSTANCE_NAME/ $ORACLE_SI D
I f you haven’t set t he ORACLE_BASE variable, t he value of t he DI AGNOSTI C_DEST paramet er def ault s t o
$ORACLE_HOME/ log.
Furt her det ails about using t his paramet er will be discussed in ADR sect ion.
• Resu l t Cach e Par amet er s
I n Oracle 11g, a new memory component , named as result cache, is int roduced. This memory area st ores result s
of f requent ly run queries. I t also saves result s of PL/ SQL f unct ion result s. Paramet ers used t o cont rol result
cache are: RESULT_CACHE_MODE, RESULT_CACHE_MAX_RESULT, RESULT_CACHE_MAX_SIZE,
RESULT_CACHE_REMOTE_EXPIRATION, CLIENT_RESULT_CACHE_SIZE and CLIENT_RESULT_CACHE_LAG. Using t hose
paramet ers will be discussed in Server Result Cache and Client Side Result Cache sect ions.
• DDL Lo ck Ti meou t
The new paramet er DDL_LOCK_TIMEOUT cont rols lengt h of t ime a DDL st at ement wait s f or a DML lock. Using t his
paramet er will be discussed in DDL Lock Timeout sect ion.
• Th e DB_ULTRA_SAFE Par amet er
This paramet er i s used t o set t he ef f ect ive values of t he paramet ers: DB_BLOCK_CHECKING,
DB_LOST_WRITE_PROTECT, DB_BLOCK_CHECKSUM. This paramet er t akes one of t he f ollowing values:

off
t his value means any values you set f or any of t he t hree paramet ers will not be
overridden.

data only
The ef f ect ive value of t he paramet ers will be as f ollows:


Par amet er Act i v e Val u e

DB_BLOCK_CHECKING medium

DB_LOST_WRITE_PROTECT typical


DB_BLOCK_CHECKSUM.
full

data and index
The ef f ect ive value of t he paramet ers will be as f ollows:


Par amet er Act i v e Val u e

DB_BLOCK_CHECKING full

DB_LOST_WRITE_PROTECT typical


DB_BLOCK_CHECKSUM.
full
Page 11 Oracle 11g New Features for Administrators - Summary Sheets

• Secu r i t y Par amet er s
Oracle 11g int roduces t wo import ant securit y paramet ers. Following t able illust rat ed t hose paramet ers and t heir
usages:
Par amet er Descr i pt i on Def au l t Val u e
SEC_CASE_SENSITIVE_LOGON
t o enable or disable password case- sensit ivit y.
true
SEC_MAX_FAILED_LOGIN_ATTEMPTS
Oracle drops t he connect ion af t er t he specif ied
number of login at t empt s f ail f or any user.
10

DBCA Enhancement s
I n Oracle 11g, DBCA go t hrough st eps similar t o t he one in Oracle 10g. Following is a list of new DBCA pages in
Oracle 11g:
• Secu r i t y Set t i n gs
I n t his page you can set t he creat ed dat abase t o use t he new enhanced def ault securit y set t ings in Oracle 11g.
Those set t ings include audit set t ings, password prof iles and revoking grant s f rom t he public role. Those set t ings
are part of a dat abase opt ion named as Secure Conf igurat ion.
I f you choose t o disable t hose securit y set t ings, t he dat abase will be creat ed wit h t he def ault securit y opt ions as
f or Oracle Dat abase 10g Release 2. You can st ill conf igure t he Secure Conf igurat ion opt ion lat er by invoking t he
DBCA.
• Cr eat i n g a Li st en er
I f you choose t o conf igure t he Ent erprise Manager, DBCA will search f or a list ener conf igured in t he Oracle home.
I f no list ener was f ound, DBCA asks you t o creat e one wit h t he Net Conf igurat ion Assist ant t ool.
• Net w o r k Con f i gu r at i on
I n Oracle 11g, DBCA allows you t o select t he list ener( s) f or which t o regist er t he new dat abase.
• Con f i gu r i n g New Dat abase Opt i on s
I n Oracle Dat abase 11g, you can conf igure t he f ollowing opt ions when using DBCA:
a) Oracle Applicat ion Express
b) Oracle Dat abase Vault
c) Oracle Warehouse Builder
Also, you no longer see t he Dat a Mining in t he DBCA as an opt ion t o conf igure. The dat a mining schema are by
def ault creat ed when t he catproc.sql script is run.
• New Memo r y Man agem en t
You can enable using t he new aut omat ic memory management f eat ure by specif ying amount of memory t o be
used by bot h SGA and PGA.
• Sw i t ch i n g a Dat ab ase f r om Dat abase Con t r ol t o Gr i d Con t r ol Con f i gu r at i on
Wit h Oracle Dat abase 11g, DBCA provides t he Ent erprise Manager Conf igurat ion plug- in, which aut omat es t he
process t o swit ch conf igurat ion of a dat abase f rom Dat abase Cont rol t o Grid Cont rol.
Upgr adi ng t o Or acl e Dat abase 11g
Upgr ade pat h
You can direct ly upgrade t o Oracle 11g, if you current dat abase is 9. 2. 04 or newer. I n ot her words, it support s
direct upgrade t o versions 9. 2. 0. 4, 10. 1 and 10. 2. Ot herwise, you should f ollow one of t he upgrade pat hs:
7.3.3 -> 7.3.4 -> 9.2.0.8 -> 11.1
8.0.5 -> 8.0.6 -> 9.2.0.8 -> 11.1
8.1.7 -> 8.1.7.4 -> 9.2.0.8 -> 11.1
9.0.1.3-> 9.0.1.4 -> 9.2.0.8 -> 11.1
9.2.0.3 (or lower) -> 9.2.0.8 -> 11.1
Oracle 11g client can access Oracle dat abases of versions 8i, 9i and 10g.
Upgr ade pr ocess an d COMPATI BLE par amet er
The def ault compat ibilit y value f or Oracle 11g is 11. 1. You can, however, upgrade t o Oracle 11g wit h a minimum
value of t he COMPATIBLE paramet er of 10. 0. 0. However, if you upgrade t o 11g and keep t he COMPATIBLE
paramet er t o 10. 0. 0, only a small port ion of t he new f eat ures will be available.
Page 12 Oracle 11g New Features for Administrators - Summary Sheets

Man u al Upgr ade Pr ocedu r e
To manually upgrade a dat abase f rom 10g t o Oracle 11g, perf orm t he f ollowing st eps:
1. I nvoke t he Pre- Upgrade I nf or mat ion Tool in t he dat abase t o upgrade.
This t ool is simply t he script $ORACLE_HOME/rdbms/admin/utlu111i.sql. So, you have t o copy t his script
alt oget her wit h t he script s: utlu111s.sql and utlu111x.sql t o a st aging direct ory in t he dat abase t o
upgrade.
As wit h previous versions, t his t ool will examine t he t arget dat abase and display t he warnings and
recommendat ions t hat you should consider bef ore you st art t he upgrade process such as removing obsolet e
init ializat ion paramet ers, set t ing proper values t o some paramet ers and adding space t o key t ablespaces.
Spool t he out put of running t he script f or lat er review.
SQL>spool upgrade11g.log
SQL>@utlu111i.sql
...
SQL>spool off

2. Backup t he dat abase.
3. Set t he COMPATIBLE paramet er t o 11. 1. 0. You can do so by issuing t he f ollowing command:
ALTER SYSTEM SET COMPATIBLE='11.1.0' SCOPE=SPFILE;
4. Modif y t he values of t he init ializat ion paramet ers and remove t he obsolet e paramet ers as recommended by
t he Pre- upgrade t ool in t he current init iali zat ion paramet er f i le.
5. Copy t he init ializat ion paramet er f ile t o t he new Oracle 11g home.
6. Shut down cleanly t he dat abase.
7. I f t he dat abase is inst alled in a Windows syst em, perf orm t he f ollowing st eps:
a) St op t he Oracle dat abase service. Usually it s name has t he f ormat OracleService< SI D> .
b) Delet e t he service. You can use t he oradim ut ilit y f or t his purpose.
oradim -delete –SID <sidname>
c) Use oradim ut il it y in t he Oracle 11g home t o creat e a new Oracle Dat abase 11g release inst ance. Of
course, it should use t he same SI D.
oradim -NEW –SID <sidname>
8. I f t he dat abase t o upgrade is using a password f ile, move it t o t he new Oracle 11g home.
9. Change t he environment variables ORACLE_HOME, PATH, and LD_LIBRARY_PATH so t hat t hey point t o t he new
Oracle Dat abase 11g direct ories.
10. I n t he Oracle 11g home, change t o direct ory $ORACLE_HOME/rdbms/admin and t hen st art t he SQL* Plus
11. St art t he dat abase in upgrade mode and t hen run t he upgrade script ( it t akes long t ime) . When working in
upgrade mode, Oracle allows only SYSDBA connect ions and set s some ini t ializat ion paramet er s t o specif ic
values t hat are required t o run t he upgrade script .
SQL>login sys/password as sysdba
SQL>startup upgrade pfile=$ORACLE_HOME/dbs/initorcl.ora
SQL>spool upgrade11g.log
SQL>@ catupgrd.sql
...
SQL>spool off
12. Af t er t he upgrade script f inishes, make sure no error occur red during t he upgrade. Usually errors are raised
because of lack of shared memory or t ablespace size. I f t her e is any error, f ix it s cause and rest art t he
upgrade script .
13. When t he upgrade script successf ully f inishes, rest art t he dat abase in OPEN mode.
14. Rum utlu111s.sql script ( ref erred t o as Post - Upgrade St at us t ool) t o view t he result s of t he upgrade. This
t ool will view t he inst alled component s and t heir st at us. I f you see a component wit h invalid st at us, usually
running t he script in t he next st ep will set it t o valid.
Page 13 Oracle 11g New Features for Administrators - Summary Sheets

15. Execut e t he script utlrp.sql t o in parallel recompile any invalid PL/ SQL program unit and Java code.
SQL>@utlrp.sql
SQL>SELECT COUNT(*) FROM DBA_INVALID_OBJECTS;
16. Because t he upgraded dat abase disables all t ablespace alert s by set t ing t he t hreshold t o null, set t he
t hresholds f or t ablespace alert t o t he values you desire.
I f t he upgrade process f ails, rest ore t he dat abase f rom t he backup.
Upgr adi n g w i t h t h e DBUA
Dat abase Upgrade Assist ance ( DBUA) is a GUI ut il it y t hat f acilit at es upgrade process. DBUA works in 11g in a
similar way t o it in 10g. I t j ust now has a screen asking you t o def ine t he diagnost ic direct ory.
Beside it s simplici t y, DBUA has an advant age of being able t o upgrade bot h t he dat abase inst ance and t he
ASM inst ance simult aneously. I n manual met hod, you have t o upgrade t hem separat ely.
Not e The dat abase upgrade process moves SQL prof iles t o SYSAUX t ablespace. Thus, t aking t hat
t ablespace of f line may lead t o degrading t he dat abase perf ormance.

Dat abase Repl ay
Dat abase Replay ( somet imes named as Workload Replay) f eat ure in Oracle 11g allows you t o reproduce t he
product ion dat abase condit ions in a t est ing environment . I n ot her words, wit h t his f eat ure you can capt ure t he
act ual workload on a product ion syst em and replay it in a t est syst em. This way, you can analyze t he condit ion
of t he product ion dat abase wit hout working on t he act ual product ion dat abase.
This f eat ure enables you t o t est t he impact of applying changes on a product ion dat abase. These changes could
be dat abase upgrades, swit ching t o RAC, applicat ion upgrades, operat ing syst em upgrades or st orage syst em
changes.
Using Dat abase Replay consist s of f our phases:
1. Wor k l oad Capt u r e: t his is when you record t he product ion dat abase workload.
2. Wor k l oad Pr epr ocessi n g: t his is t o convert t he capt ured workload int o replay f iles.
3. Typically, af t er t he st ep above, you apply t he changes on t he t est syst em. Then you st art t he Wor k l oad
Repl ay process where you replay t he product ion workload in t he t est dat abase.
4. An al ysi s an d Repor t i n g: when t he st ep above successf ully f inishes, you generat e report on t he errors and
perf ormance inf luence.
I n t he f ollowing sect ions, pract ical st ep t o implement t hose phases will be discussed.
To int erf ace wit h Workload Replay f eat ure in t he dat abase, you use a ut ilit y named as Workload Replay Client . To
invoke t he ut ilit y, t ype wrc in t he command line.
Dat a Capt u r ed by Dat abase Repl y
Following is a list of dat a changes capt ured by Dat abase Reply:
• DML st at ement s
• DDL st at ement s
• Session cont rol calls ( such as ALTER SESSION)
• Syst em cont rol calls ( such as ALTER SYSTEM)
Dat a Not Capt u r ed by Dat abase Repl y
The f ollowing dat a changes are not capt ured by Dat abase Reply:
• Flashback queries
• Scheduled j obs
• Shared Server request s
• Non PL/ SQL AQ
• Direct pat h load f rom ext ernal f iles using SQL* Loader, dat abase links, ext ernal t ables, Oracle st reams,
non- SQL- based obj ect access and dist ribut ed t ransact ions.
• Dist ribut ed t ransact ions
Page 14 Oracle 11g New Features for Administrators - Summary Sheets

Pr epar i n g f or Capt u r i n g Wor k l oad
Bef ore you capt ure t he workload, perf orm t he f ollowing st eps:
1. Backup dat abase dat a t hat you want t o t est . Use eit her RMAN, user- managed online backup, Dat a Pump
ut ilit ies or a snapshot st andby. This backup will be used lat er t o creat e a t est ing environment in a st at e
similar t o t he product ion dat abase f or t he replay process.
2. Any t ransact ion t hat is underway when you st art capt uring t he workload may not be capt ured. I f you
want t o capt ure all t ransact ions, you should rest art t he dat abase in rest rict ed mode, st art t he capt ure
process, t hen open t he dat abase f or users.
3. Creat e direct ory obj ect f or st oring capt ured workload.
CREATE DIRECTORY workload_dir AS 'C:\Oracle\admin\ora11g\workload';
4. Decide whet her some of t he user sessions should not be capt ured. You may not need t o capt ure DBA
sessions, Oracle Ent erprise Manager sessions or any sessions creat ed by t hird part y client s. To achieve
t his t ask, use DBMS_WORKLOAD_CAPTURE package as shown in t he f ollowing st eps:
a. Use ADD_FILTER procedure t o add any eliminat ing sessions based on USER, MODULE, ACTION,
PROGRAM, SERVICE or INSTANCE_NUMBER:
begin
DBMS_WORKLOAD_CAPTURE.ADD_FILTER(
FNAME => 'FILTER_DBA1',
FATTRIBUTE => 'USER',
FVALUE => 'SYSTEM,DBSNMP' );
end;
b. The DBA_WORKLOAD_FILTERS view provides you inf ormat ion about exist ing f ilt ers. For a f ilt er wit h
t he STATUS of USED, it means t he f ilt er is delet ed. :
SELECT NAME, ATTRIBUTE, VALUE FROM DBA_WORKLOAD_FILTERS;
c. Use DELETE_FILTER procedure t o delet e any exist ing f ilt er:
EXEC DBMS_WORKLOAD_CAPTURE.DELETE_FILTER( FNAME => 'FILTER_DBA1');
Capt u r i n g Wor k l oad
Use START_CAPTURE procedure in DBMS_WORKLOAD_CAPTURE package t o st art capt uring t he workload. I f you set
t he DURATION paramet er t o NULL, it means t hat workload capt ure will cont inue unt il t he user execut es
DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE. I t is recommended t o record t he t ime in t he syst em j ust bef ore
issuing t he command.
begin
DBMS_WORKLOAD_CAPTURE.START_CAPTURE(
NAME => '1JAN_WORKLOAD',
DIR => 'WORKLOAD_DIR',
DURATION => 2400); -- duration in seconds
end;
To st op t he capt ure process bef ore ending of durat ion period, issue t he f ollowing command:
exec DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE;
Af t er capt ure process f inishes, you can issue query about workload capt ures using t he f ollowing command:
SELECT ID, NAME, STATUS, ERROR_MESSAGE FROM DBA_WORKLOAD_CAPTURES;
You can generat e a report about t he workload capt ure you have made:
declare
v_capture_id number;
v_capture_rpt clob;
begin
v_capture_id := DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO(DIR => 'WORKLOAD_DIR');
v_capture_rpt := DBMS_WORKLOAD_CAPTURE.REPORT( CAPTURE_ID => v_capture_id , FORMAT =>
DBMS_WORKLOAD_CAPTURE.TYPE_TEXT); -- format could also be TYPE_HTML
-- display contents of v_capture_rpt
end;
Page 15 Oracle 11g New Features for Administrators - Summary Sheets

Alt ernat ively, you can use t he f ollowing st at ement s:
SELECT id, name, status FROM DBA_WORKLOAD_CAPTURES;
SELECT DBMS_WORKLOAD_CAPTURE.REPORT(1, 'HTML') FROM DUAL;
I f you want t o delet e f rom it s dat a dict ionary views, used t he procedure DELETE_CAPTURE_INFO. However, t his
procedure does not delet e t he workload capt ure f iles in it s direct ory. I f you want t o t ake a new workload capt ure
wit h t he same name, you should manually get rid of it s f iles ot herwise an error will be ret urned when you
execut e START_CAPTURE procedure.
Pr epr ocessi n g Wor k l oad Capt u r e Dat a
To be able t o replay a Workload Capt ure, you must preprocess it s dat a. Alt hough it is possible t o preprocess in
t he product ion dat abase, pract ically it is done in a t est dat abase. Preprocessing includes t he f ollowing st eps:
1. Rest ore t he t est dat abase f rom t he backup you made in t he product ion dat abase. The t arget is t o make t he
same applicat ion become in t he same st at e as it has been in t he product ion dat abase.
2. Creat e a direct ory obj ect in t he t est dat abase t o hold t he workload capt ure dat a f iles.
CREATE DIRECTORY replay_dir AS 'c:\oracle\admin\ora11g\replay';
3. Move t he workload dat a f iles f rom t he product ion dat abase t o t he creat ed direct ory in t he t est syst em.
4. Use t he PROCESS_CAPTURE procedure t o process t he workload dat a:
exec DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE('REPLAY_DIR');
Repl ayi n g t h e Wor k l oad
Typically, at t his st age, you perf orm t he changes you want t o undert ake on t he syst em. Then you st art t he
replay process. Replaying Workload is done by perf orming of t he f ollowing st eps:
1. I t is recommended t o set t he t ime of t he t est syst em t o t he t ime when t he workload was capt ured on t he
product ion syst em. This is t o avoid any invalid t ime- based dat a or j ob- scheduling issues.
2. Take st eps t o resolve, if any, ext ernal ref erences including: dat abase links, ext ernal t ables, direct ory obj ect s,
and URLs.
3. I nit ialize t he Replay Dat a: t his process means met adat a will be read f rom Workload Capt ure f iles and loaded
int o t ables. Workload replay process will read f rom t hose t ables when it operat es. I nit ializing t he replay dat a
is done by invoking t he procedure INITIALIZE_REPLAY
begin
DBMS_WORKLOAD_REPLAY.INITIALIZE_REPLAY(
REPLAY_NAME =>'1JAN_WORKLOAD',
REPLAY_DIR =>'REPLAY_DIR'); -- directory name should always be in upper case.
end;
4. Remapping Connect ions: if any session in t he product ion dat abase during t he workload capt uring used a
connect ion t o access an ext ernal dat abase, t his connect ion should be remapped in t he t est dat abase so t hat
it connect s t o t he desired dat abase.
To display t he connect ion mapping inf ormat ion f or a workload replay, query t he view
DBA_WORKLOAD_CONNECTION_MAP.
SELECT REPLAY_ID, CONN_ID, CAPTURE_CONN, REPLAY_CONN
FROM DBA_WORKLOAD_CONNECTION_MAP
To remap connect ion st ring in t he t est dat abase t o t he required connect ion st rings, you use
REMAP_CONNECTION procedure.
begin
DBMS_WORKLOAD_REPLAY.REMAP_CONNECTION (
CONNECTION_ID =>1, REPLAY_CONNECTION => 'myprod:1521/mydb' );
end;
5. Preparing t he Workload Replay: t his is done wit h t he procedure PREPARE_REPLAY. Following are t he t hree
opt ions ( set by paramet ers) t hat can be conf igured wit h t his procedure:
a. SYNCHRONIZATION: ( def ault TRUE) Ensure t he replay observes t he commit sequence of t he capt ure;
i. e. any work is run only af t er dependent commit s in t he replay are complet ed. I f you know t hat
t ransact ions in your workload capt ure are independent , you can set t his paramet er t o FALSE.
Page 16 Oracle 11g New Features for Administrators - Summary Sheets

b. CONNECT_TIME_SCALE: ( def ault 100) t his paramet er uses t he elapsed t ime bet ween t he t ime when t he
workload capt ure began and when sessions connect . You can use t his opt ion t o manipulat e t he session
connect t ime during replay wit h a given percent age value. The def ault value is 100, which will at t empt
t o connect all sessions as capt ured. Set t ing t his paramet er t o 0 will at t empt t o connect all sessions
immediat ely.
c. THINK_TIME_SCALE: ( def ault 100) t hink t ime is t he elapsed t ime while t he user wait s bet ween issuing
calls. To cont rol replay speed, use t he THINK_TIME_SCALE paramet er t o scale user t hink t ime during
replay.
I f user calls are being execut ed slower during replay t han during capt ure, you can make t he dat abase
replay at t empt t o cat ch up by set t ing t he THINK_TIME_AUTO_CORRECT paramet er t o TRUE ( t he def ault ) .
This will make t he replay client short en t he t hink t ime bet ween calls, so t hat t he overall elapsed t ime
of t he replay will more closely mat ch t he capt ured elapsed t ime.
The PREPARE_REPLAY procedure put s t he dat abase server in PREPARE mode. Below is a code example:
exec DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY ( SYNCHRONIZATION => FALSE );
6. St art ing Replay Client ( s) : replay client ( represent ed by t he execut able wrc) cont rols t he replay of t he
workload dat a. You may need t o run more wrc f rom more t han one host . This depends on t he maximum
number of sessions t hat a single wrc t hread can handle and t he t ot al number of sessions capt ured by t he
workload capt ure.
For example, if t he workload capt ure has dat a of 400 sessions and a single host can handle only 150
sessions, in t his case you need t hree host s wit h wrc inst alled and run on each.
To know how many host s and wrc client s you need t o operat e f or your workload capt ure, run t he wrc in t he
calibrat e mode as shown below:
wrc system/<password> mode=calibrate replaydir=C:\Oracle\admin\ora11g\replay
Then, run wrc in replay mode ( t he def ault ) on t he client host ( s) :
wrc system/<password> mode=replay replaydir=C:\Oracle\admin\ora11g\replay
7. St art t he replay process using START_REPLAY procedure ( not ice t hat wrc client ( s) were previously st art ed) :
exec DBMS_WORKLOAD_REPLAY.START_REPLAY();
I f , f or any reason, you want t o cancel t he replay process bef ore it f inishes, use CANCEL_REPLAY procedure.
For t he workload replay, not ice t he f ollowing:
o While t he workload is replaying, you can query V$WORKLOAD_REPLAY_THREAD view t o list inf ormat ion
about all sessions f rom t he replay client s.
o You can obt ain inf or mat ion about t he workl oad replays, af t er t hey f inish, by querying t he view
DBA_WORKLOAD_REPLAYS.
o Af t er workload replay f inishes, all AWR snapshot s relat ed t o t he replay t ime period is aut omat ically
export ed. This can also be done manually using EXPORT_AWR procedure.
o Export ed snapshot s can be import ed int o t he AWR schema owned by SYS user using IMPORT_AWR
procedure.
An al yzi n g Wor k l oad Repl ay Repor t
Af t er t he workload f inishes, you st art generat ing a report about it . The report is t he desired out put of t he whole
process and will assist you on measuring t he dif f erence bet ween t he product ion and t est syst ems or cat ching any
errors during t he workload replay. To generat e t he report , issuing t he f ollowing code:
declare
v_cap_id NUMBER;
v_rep_id NUMBER;
v_rpt CLOB;
begin
v_cap_id := DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO(DIR=>'REPLAY_DIR');
/* Get the latest replay */
SELECT MAX(ID) INTO v_rep_id FROM DBA_WORKLOAD_REPLAYS
WHERE CAPTURE_ID=v_cap_id;
v_rpt := DBMS_WORKLOAD_REPLAY.REPORT(
REPLAY_ID => v_rep_id,
FORMAT => DBMS_WORKLOAD_REPLAY.TYPE_TEXT); -- or XML, HTML
end;
Page 17 Oracle 11g New Features for Administrators - Summary Sheets

Repl ayi n g a Dat abase Wor k l oad Usi n g En t er pr i se Man ager
To replay a dat abase workload using Ent erprise Manager, f ollow t he links: Sof t w ar e an d Su ppor t page> Real
Appl i cat i on Test i n g> Dat abase Repl ay> i n t h e Go t o Task col u mn , cl i ck t h e Repl ay Wor k l oad t ask
i con .
Using OEM, you can also monit or an act ive workload replay and view a complet ed workload replay.
The SQL Per f or mance Anal yzer
The SQL Perf ormance Analyzer ( SPA) aims at measuring t he impact of applying any change on t he dat abase on
t he perf ormance of t he SQL st at ement s execut ion. I f it f inds out perf ormance degradat ion in one or more SQL
st at ement s, it provides you recommendat ions on how t o improve t heir perf ormance.
This is very usef ul f or a DBA t o analyze how a change on t he dat abase ( including dat abase upgrade) may af f ect
t he execut ion ef f iciency of SQL st at ement s. Using t his t ool is explained here because you may consider using it
t o st udy t he ef f ect of upgrading an Oracle dat abase 10g release 2 t o 11g.
SPA can be invoked f rom OEM or using DBMS_SQLPA package.
To use SPA, you perf orm t he f ollowing phases:
1. Capt ure t he SQL workload.
2. Measure t he perf ormance of t he workload bef ore t he change.
3. Make a change.
4. Measure t he perf ormance of t he workload af t er t he change.
5. Compare perf ormance.
St eps t hat should be f ollowed t o perf orm t hose phases are explained in t he f ollowing sect ions.
I t is recommended t o make an ident ical copy of t he product ion dat abase, apply t he change on t he t est dat abase
t hen use SPA on t he t est dat abase t o measure t he inf luence of t he applied changes.
Not e I f you plan t o use SPA on a t est dat abase, it is highly recommended t o make t he t est dat abase
resemble t he product ion dat abase as closely as possible. You can use t he RMAN duplicate command
f or t his purpose.
Capt u r i n g t h e Pr odu ct i on Syst em SQL Wor k l oad
You capt ure t he SQL Workload t hat you int end t o analyze and st ore it s st at ement s int o a SQL t uning set ( STS) .
Following are t he st eps t o do so:
1. Creat e STS using t he f ollowing code:
begin
DBMS_SQLTUNE.CREATE_SQLSET(
SQLSET_NAME => 'upgrade_sts',
DESCRIPTION =>'To test upgrade to 11g',
SQLSET_OWNER =>'SYS'); -- current user is the default
end;
2. You can load SQL st at ement s int o a STS f rom dif f erent sources, including t he cursor cache, Aut omat ic
Workload Reposit ory ( AWR) , and exist ing SQL Tuning Set s. STS cont ains inf ormat ion about t he capt ured
st at ement s such as execut ion cont ext , SQL t ext and execut ion f requency.
The f ollowing example illust rat es how t o load UPGRADE_STS f rom an AWR baseline called peak baseline. The
dat a has been f ilt ered t o select only t he t op 30 SQL st at ement s ordered by elapsed t ime.
declare
baseline_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
--a ref cursor is opened to select from the specified baseline
OPEN baseline_cur FOR
SELECT VALUE(p)
FROM TABLE (DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(
'peak baseline',NULL, NULL, 'elapsed_time', NULL, NULL, NULL,30 )) p;
--Next the statements and their statistics are loaded into the STS
DBMS_SQLTUNE.LOAD_SQLSET( SQLSET_NAME=>'UPGRADE_STS', POPULATE_CURSOR=>baseline_cur);
end;
Page 18 Oracle 11g New Features for Administrators - Summary Sheets

The f ollowing example loads UPGRADE_STS wit h SQL st at ement s t hat are not owned by SYS and t heir elapsed
t ime is great er t han 20, 000 seconds.
declare
sql_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
--a ref cursor is opened to select the required SQL statments
OPEN sql_cur FOR
SELECT VALUE(p)
FROM TABLE (DBMS_SQLTUNE.LOAD_SQLSET(
'parsing_schema_name <> ''SYS'' and elapsed_time > 2000000',NULL, NULL, NULL, NULL,1,
NULL, 'ALL')) p;
--the statements are loaded into the STS
DBMS_SQLTUNE.LOAD_SQLSET( SQLSET_NAME=>'UPGRADE_STS', POPULATE_CURSOR=>sql_cur);
end;
3. I f you are using a t est dat abase, you should t ransport t he STS creat ed in t he previous st ep t o t he t est
syst em. This can be done by perf orming t he f ollowing st eps:
3. 1. Creat e a st aging t able t o hold t he STS f rom t he product ion dat abase. Following is an example code
t o do t hat :
exec DBMS_SQLTUNE.CREATE_STGTAB_SQLSET( TABLE_NAME =>'sts_table');
3. 2. Export STS dat a int o t he st aging t able as shown in t he f ollowing code:
begin
DBMS_SQLTUNE.PACK_STGTAB_SQLSET( SQLSET_NAME => 'UPGRADE_STS',
STAGING_TABLE_NAME =>'sts_table');
end;
3. 3. Export t he st aging t able f rom t he product ion dat abase and import it t o t he t est dat abase using Dat a
Pump export and import ut ilit ies.
3. 4. I mport t he STS dat a f rom t he st aging t able t o t he t est dat abase as shown in t he example below:
begin
DBMS_SQLTUNE.UNPACK_STGTAB_SQLSET( SQLSET_NAME => '%',
REPLACE => TRUE,
STAGING_TABLE_NAME =>'sts_table');
end;
4. Creat e a t uning t ask f or t he creat ed STS as show in t he example code below:
declare
v_task varchar2(100);
begin
v_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( SQLSET_NAME => 'UPGRADE_STS',
TASK_NAME =>'spa_upgrade_task');
end;

Not e We are using SPA in t his scenario t o analyze SQL involved in a STS. Act ually, you can also use it t o
analyze a given single SQL st at ement , a st at ement in t he cursor cache or SQL st at ement s in a
workload reposit ory in a given a range of snapshot ident if iers
5. I f you are using SPA t o examine t he inf luence of upgrading a 10g dat abase t o 11g, set t he paramet er
OPTIMIZER_FEATURES_ENABLE in t he t est dat abase t o 10. 2. 0. This enables you t o make SPA generat e
st at ist ics f or 10g dat abase.
ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='10.2.0'

Page 19 Oracle 11g New Features for Administrators - Summary Sheets

Measu r i n g t h e Per f or man ce Bef or e t h e Ch an ge
St art analyzing t he SQL workload bef ore applying t he change. This is done by using t he procedure
EXECUTE_ANALYSIS_TASK. This procedure has t he paramet er EXECUTION_TYPE which should t ake one of t hree
possible values: TEST EXECUTE, EXPLAIN PLAN or COMPARE PERFORMANCE. The f irst value will lead t o execut e all
t he SQL St at ement s in t he STS. The second value will generat e explain plans f or t he SQL St at ement s wit hout
execut ing t he st at ement s. The t hird value is only used t o compare t wo versions of SQL Perf ormance dat a.
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK (
TASK_NAME => 'spa_upgrade_task',
EXECUTION_TYPE=> 'TEST EXECUTE', -- or EXPLAIN PLAN
EXECUTION_NAME =>'before_change');
end;
Af t er t he code above is successf ully execut ed, apply t he change on t he dat abase.
Measu r i n g t h e Per f or man ce Af t er t h e Ch an ge
I f t he change was upgrading t he dat abase t o 11g, do not f orget t o set t he paramet er
OPTIMIZER_FEATURES_ENABLE t o t he 11g value af t er t he upgrade f inishes:
ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='11.1.0.6'
Af t er applying t he change, you collect SQL perf ormance dat a by running EXECUTE_ANALYSIS_TASK again.
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK (
TASK_NAME => 'spa_upgrade_task',
EXECUTION_TYPE=> 'TEST EXECUTE', -- or EXPLAIN PLAN
EXECUTION_NAME =>'after_change');
end;
Compar i n g t h e SQL Per f or man ce
To compare t he SQL perf ormance dat a bef ore and af t er t he change, you st ill use t he procedure
EXECUTE_ANALYSIS_TASK but t his t ime you set t he paramet er EXECUTION_TYPE t o COMPARE PERFORMANCE.
The f ollowing code compares t he SQL perf ormance dat a analyzed by t he SPA bef ore and af t er t he change f or t he
t ask spa_upgrade_task. By set t ing t he paramet er COMPARISION_METRIC t o DISK_READS, it will measure t he
perf ormance impact of t he change on t he disk reads. Ot her possible values include: ELAPSED_TIME,
OPTIMIZER_COST, DIRECT_WRITE, PARSE_TIME, and BUFFER_GETS.
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK (
TASK_NAME => 'spa_upgrade_task',
EXECUTION_TYPE => 'COMPARE PERFORMANCE',
EXECUTION_PARAMS => 'DBMS_ADVISOR.ARGLIST('COMPARISION_METRIC','DISK_READS'));
end;
By def ault , t he procedure EXECUTE_ANALYSIS_TASK compares t he last t wo t ask execut ions. You can set t he
names of t he execut ions bef ore and af t er t he syst em change was made as f ollows:
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK (
TASK_NAME => 'spa_upgrade_task',
EXECUTION_TYPE => 'COMPARE PERFORMANCE',
EXECUTION_PARAMS => DBMS_ADVISOR.ARGLIST('EXECUTION_NAME1', 'before_change',
'EXECUTION_NAME2', 'after_change',
'COMPARISON_METRIC','DISK_READS'));
end;
Page 20 Oracle 11g New Features for Administrators - Summary Sheets

Then you can generat e a report t o show t he result of perf ormance comparison. This can be done using
REPORT_ANALYSIS_TASK f unct ion as shown in t he code below:
declare
report clob;
begin
report := DBMS_SQLPA.REPORT_ANALYSIS_TASK (
TASK_NAME => 'spa_upgrade_task',
TYPE => 'TEXT', -- or HTML, XML
LEVEL =>'TYPICAL', -- BASIC,ALL,IMPROVED,REGRESSED,CHANGED,
-- UNCHANGED,CHANGED_PLANS,UNCHANGED_PLANS,ERRORS
SECTION =>'SUMMARY'); -- or SECTION_ALL
end;
SQL Per f or man ce An al yzer Repo r t
The report is divided int o t he sect ions: General I nf ormat ion, Result Summary and Result Det ai ls. Foll owing t able
illust rat es descript ion of t he report ' s sect ion and subsect ions.
Sect i on / Su bsect i on Descr i pt i on
General Information
I t cont ains basi c inf ormat ion and met adat a about t he SQL Perf ormance Analyzer
t ask, t he SQL Tuning Set used, and t he pre- change and post - change execut ions.
Result Summary
I t summar izes t he resul t s of t he SQL Perf ormance Analyzer t ask.
Overall Performance
Statistics
I t displays st at ist i cs about t he overall perf ormance of t he ent ire SQL workload.
Use t his subsect ion t o det ermine whet her t he workload perf ormance wil l improve
or degrade af t er making t he syst em change.
Performance
Statistics of SQL
Statements
I t highlight s t he SQL st at ement s t hat are t he most i mpact ed by t he syst em
change.
Errors
I t report s all error s t hat occurred during an execut ion.
Result Details
I t represent s a drill- down int o t he perf ormance of SQL st at ement s t hat appears
in t he Result Summary sect i on of t he report .
SQL Statement
Details
I t summar izes t he SQL st at ement , li st ing it s inf or mat ion and execut ion det ails.
Single Execution
Statistics
I t compares execut ion st at ist i cs of t he SQL st at ement f rom t he pre- change and
post - change execut ions and t hen summari zes t he f indings.
Execution Plans
I t displays t he pre- change and post - change execut ion plans f or t he SQL
st at ement .
SQL Per f or man ce An al yzer Vi ew s
You can use t he f ollowing queries t o monit or SQL Perf ormance Analyzer and view it s analysis result s:
-- to display descriptive information about the created SQL Performance Analyzer tasks
SELECT TASK_ID, TASK_NAME, STATUS, PCT_COMPLETION_TIME, PROGRESS_METRIC,
RECOMMENDATION_COUNT
FROM DBA_ADVISOR_TASKS
WHERE ADVISOR_NAME='SQL Performance Analyzer';
-- to display information about task executions
SELECT TASK_NAME, EXECUTION_NAME, EXECUTION_TYPE, STATUS
FROM DBA_ADVISOR_EXECUTIONS
WHERE ADVISOR_NAME='SQL Performance Analyzer';
-- to display the SQL Performance Analyzer findings
-- TYPE possible values: PROBLEM, SYMPTOM, ERROR, and INFORMATION
SELECT TASK_NAME, EXECUTION_NAME, FINDING_NAME, TYPE,
IMPACT_TYPE, IMPACT "Impact Value", MESSAGE, MORE_INFO
FROM DBA_ADVISOR_FINDINGS
WHERE upper(TASK_NAME)= upper ('spa_test');


Page 21 Oracle 11g New Features for Administrators - Summary Sheets

Pat chi ng i n Or acl e Dat abase Cont r ol
New Feat u r es i n Dat ab ase Con t r o l f o r Pat ch i n g
Pat ching t hrough Dat abase Cont rol is enhanced in Oracle 11g. On t he Dat abase Cont rol home page, click
Sof t w ar e an d Su ppor t t o reach t he Dat abase Sof t w ar e Pat ch i n g page. The page has t he f ollowing links:
Li n k Descr i pt i on
Pat ch Advisor The advisor will connect t o Met alink and display t he available pat ches applicable t o your
sof t ware inst al lat ion. I t has t wo sect i ons:
o Crit ical Secur it y Pat ches
o Pat ch Recommendat ions by Feat ure
View Pat ch
Cache
This page displays all t he pat ches downloaded f rom Met alink. Even if you did not download
any pat ch, OEM by def ault aut omat ically downl oads necessary pat ches f rom Met alink when
t he pat ch j ob runs. Cached pat ches can be t hen applied t o mult iple dest inat ions.
Pat ch
Prerequisit es
Wit h t his page, you can st age t he sof t ware updat es f rom Met alink or Sof t ware Library t o a
st aging locat ion and run prerequisit e checks on t hose updat es.
St age Pat ch This page enables you t o search t he pat ches on Met alink based on your crit eria and t hen
select t hem.
Apply Pat ch This page let s you select an updat e f rom Met alink or Sof t ware Library t o apply.
On l i n e Pat ch i n g
Wit h Oracle 11g online pat ching ( or called hot pat ching) , you can apply or roll back a dat abase pat ch while t he
inst ance is running. Also it can det ect conf lict s bet ween t wo online pat ches. On t he ot her hand, online pat ching
consumes more memory t han t he convent ional met hod.
I n UNI X syst ems, you use t he script $ORACLE_HOME/OPatch/opatch t o invoke t he online pat ching.
Page 22 Oracle 11g New Features for Administrators - Summary Sheets

Dat abase Di agnosi s and Repai r
I nt r oduci ng Aut omat i c Di agnost i c Reposi t or y ( ADR)

The Aut omat ic Diagnost ic Reposit ory ( ADR) is a f ile syst em reposit ory t o st ore diagnost ic dat a source such as
alt er log, t race f iles, user and background dump f iles, and also new t ypes of t roubleshoot ing f iles such as Healt h
Monit or report s, I ncident packages, SQL t est cases and Dat a repair records.
I n Oracle 11g, t here is a new f ramework ( named as f ault diagnosabilit y inf rast ruct ure) consist ing of many t ools
f or diagnosing and repairing t he errors in t he dat abase. All t hose t ools ref er t o t he ADR in t heir operat ion.
ADR is developed t o provide t he f ollowing advant ages:
• Diagnosi s dat a, because it is st ored in f ile syst em, i s available even when t he dat abase is down.
• I t is easier t o provide Oracle support wit h diagnosi s dat a when a problem occurs in t he dat abase.
• ADR has diagnosis dat a not only f or t he dat abase inst ance. I t has t roubleshoot ing dat a f or ot her Oracle
component s such as ASM and CRS.
Not e For each dat abase inst ance t wo aler t log f iles are generat ed: one as t ext f ile and one wit h xml
f ormat . Cont ent s of t he xml- f ormat t ed f ile can be examined using adrci t ool, which will be discussed
in a lat er sect ion.
Also t he xml- f ormat t ed alert log is saved in t he ADR and specif ically in t he direct ory
$ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID/alert
Pr ob l ems an d I n ci den t s
Problem is a crit ical error occurred in t he dat abase. Each problem has a problem key. The problem key consist s
of t he Oracle error number and error argument . Here is an example: ORA 600 [ 4899] .
The f irst t ime a problem occurs, an incident is also creat ed. When t he same problem t akes place again, anot her
incident will be generat ed f or t he same problem. Thus, you may have mult iple incident s f or a one problem.
When an incident occurs, Oracle perf orms t he f ollowing:
• An alert will be issued.
• An ent ry will be added in t he alert log f ile.
• Relat ed dat a will be st ored in t he ADR direct ory.
By def ault , an incident met adat a is purged f rom t he ADR af t er one year and it s f iles are ret ained f or one mont h.
Conf i gur i ng t he ADR
To conf igure t he ADR, you only have t o def ine it s root direct ory by set t ing t he value of t he init ializat ion
paramet er DIAGNOSTIC_DEST. This root direct ory is named as ADR base.
SELECT VALUE FROM V$PARAMETER WHERE NAME ='diagnostic_dest';
ALTER SYSTEM SET DIAGNOSTIC_DEST ='C:\ORACLE\diag';
Query t he view V$DIAG_INFO t o display all t he ADR- relat ed locat ions ( also number of act ive problems and
incident s) :
SELECT NAME, VALUE FROM V$DIAG_INFO;

Usi ng adr ci Tool
Oracle 11g int roduces adrci t ool. This t ool is used t o examine cont ent s of ADR reposit ory and also t o package
inf ormat ion relat ed t o a specif ic problem int o a compressed ( zip) f ile t o send it t o Oracle support .
To invoke t he t ool, log in as t he Oracle sof t ware owner and t ype adrci in t he command line. To list t he t ool
command line commands, t ype t he f ollowing:
adrci –help
To display t he t ool commands, t ype t he f ollowing command in t he adrci command line:
adrci>help
Page 23 Oracle 11g New Features for Administrators - Summary Sheets

To obt ain guiding inf ormat ion about specif ic command, t ype t he f ollowing:
adrci>help show incident
adrci commands will run on t he ADR root ( known when dealing wit h t his t ool as ADR base) . To display t he ADR
base direct ory t he t ool is handling, t ype t he f ollowing in t he adrci command:
adrci>show base
adrci t ool can deal wit h all t he Oracle homes under t he ADR base. I f you want t o specif y which home should be
handled by t he t ool, you must specif y t he current homepat h. I f you do not specif y t he current homepat h, all t he
homes will be handled by t he t ool.
To display homes under t he ADR root , issue t he f ollowing command:
adrci>show homes
To display t he current ADR homepat h, issue t he f ollowing command:
adrci>show homepath
To set t he current ADR home, issue t he f ollowing command:
adrci>set homepath diag\rdbms\ora11g\ora11g

Not e You can specif y mult iple homes as current homepat hs. I n t hi s case, adrci t ool will deal wit h all t he
specif ied current homepat hs. However, not all adrci commands can work wit h mult iple current
homepat hs.
Any t ext out put f rom adrci can be capt ured and saved in an ext ernal t ext f ile using spool command:
adrci>spool /u01/myfiles/myadrci.txt
adrci> ...
adrci>spool off
Usi n g ad r ci t o Vi ew t h e Al er t Log
By def ault , adrci displays t he alert log in your def ault edit or. You can use t he SET EDITOR command t o change
your def ault edit or.
adrci>set editor notepad.exe
To display cont ent s of t he alert log f ile ( xml t ags will be excluded) , issue t he f ollowing command:
adrci>show alert
To see only t he last 30 messages in t he alert , modif y t he command as f ollows:
adrci>show alert –tail 30
To display messages cont aining ORA- 600 errors, i ssue t he f ollowing command:
adrci>show alert –p "MESSAGE TEXT LIKE '%ORA-600%'*
Usi n g ad r ci t o Li st Tr ace Fi l es
Trace f iles can be list ed in adrci using t he f ollowing command:
adrci>show tracefile
Usi n g ad r ci t o Vi ew I n ci den t s
Use t he f ollowing command t o obt ain a report about all t he i ncident s in t he current homepat h( s) :
adrci>show incident
I f you want t o obt ain f urt her det ails about an incident , i ssue t he command wit h –p ( predicat e st ri ng) opt ion:
adrci>show incident –mode detail –p "incident_id=112564"
You can use many f ields in t he predicat e opt ions. To list all available f ields, issue t he command describe
incident.
Page 24 Oracle 11g New Features for Administrators - Summary Sheets

Usi n g ad r ci t o Pack age I n ci den t s
Wit h adrci t ool, you can package all t he diagnost ic f iles relat ed t o specif ic problems int o a ZI P f ile t o submit it
t o Oracle support . To do so, you use special commands called I PS as shown in t he f ollowing st eps:
1. Creat e a logical package: use ips create package command t o creat e an empt y logical package as shown
in t he example below. The package will be given a serially generat ed number.
adrci>ips create package
2. Add diagnost ic dat a t o t he logical package: t his is done by ips add incident command as shown below:
adrci>ips add incident 112564 package 1
Act ually, t here are f ormat s of t he ips create package command which enables you t o perf orm t he st eps 1
and 2 in one command. Following are t hose command f ormat s:
o ips create package problem
o ips create package problem key
o ips create package incident
o ips create package time
3. Generat e t he physical package. The f iles relat ed t o t he incident will be collect ed in a ZI P f ile. The f ollowing
example shows t he command t o perf orm t his t ask:
adrci>ips generate package 1 in /u01/myfiles/incidents
I f you decide t o add or change any diagnost ic dat a lat er, you can do so by generat ing an increment al ZI P f ile.
Modif y t he command as f ollows t o achieve t hat :
adrci>ips generate package 1 in /u01/myfiles/incidents incremental
You will not ice t hat t he generat ed f ile has t he phase I NC in it s name indicat ing t hat it is an increment al ZI P
f ile.
ips commands behavior is cont rol led by various conf igurat ion opt ions. To display t hose conf igurat ion
opt ions, use t he command ips show configuration.

Usi ng The Suppor t Wor k bench i n t he OEM
The Support Workbench is a new OEM f acilit y t hat has similar t ask t o t he command line ut ilit y adrci. I t aims at
examining and report ing crit ical errors occurring in t he dat abase. I n order t o use t he opt ion of uploading incident
packages t o Oracle, you must inst all Oracle Conf igurat ion Manager.
The f acilit y is accessed by t he link Dat abase Home Page> Sof t w ar e an d Su p por t > Su ppo r t Wor k ben ch .
Resol vi n g a Cr i t i cal Er r or
A crit ical error can be resolved wit h t he Support Workbench by perf orming t he f ollowing st eps:
1. I n OEM home page, examine t he crit ical error alert s in t he Al er t s sect ion t able.
2. Click t he er r o r l i n k provided in t he Message column.
3. Click on Go t o Met al i n k t o creat e a service request . Of cour se, you will be asked t o provide your Oracle
Met alink account credent ials.
4. I n t he I n vest i gat e an d Resol ve sect i on of t he Problem Det ails page, click on Qu i ck Pack age.
You have t he opt ion t o creat e a Quick Package or Cust om Package. Wit h cust om package, you can edit
diagnost ic dat a bef ore uploading t o dat a. Quick package does not give you t his level of cont rol.
5. Fol l o w t h e i n st r u ct i on s t ill you f inish wit h submit t ing t he package.
6. You can t hen revise t he Problem Det ails page t o perf orm t he f ollowing:
o Adding an Oracle bug number t o t he problem inf ormat ion.
o Adding comment s t o t he problem act ivit y log.
o Running t he relat ed Oracle advisors.
7. Once t he problem is resolved, you close t he incident . Follow t he link Su ppor t Wo r k b en ch h ome> Vi ew
Pr ob l em Det ai l s. Cli ck t he incident you want t o close and click Cl ose.
By def ault , open incident s are closed af t er 30 days. You can disable t his aut omat i c behavior in t he I n ci den t
Det ai l s page.
Page 25 Oracle 11g New Features for Administrators - Summary Sheets

Usi n g SQL Repai r Adv i sor
I f a SQL st at ement s f ails because of a problem in it s execut ion plan ( caused f or example by a bug) , you may
want t he opt imizer t o make it running using anot her successf ul execut ion plan. SQL Repair Advisor analyzes
f ailed SQL st at ement s wit h crit ical errors and provides recommendat ions t o apply a pat ch. The pat ch causes t he
query opt imizer t o choose an alt ernat e execut ion plan f or f ut ure execut ions.
To run t he advisor, f ollow t he link Su ppor t Wor k ben ch h ome> Pr obl em Det ai l s of t h e f ai l ed st at emen t >
I n vest i gat e an d Resol ve sect i on > Sel f Ser vi ce t ab> Resol ve h eadi n g> SQL Repai r Advi sor .
To manage creat ed SQL pat ches, f ollow t he links Dat abase Home pag e> Ser ver t ab> Qu er y Opt i m i zer
sect i on > SQL Pl an Con t r o l > SQL Pat ch t ab
Dat abase Heal t h Moni t or
Oracle 11g int roduced a new monit oring f ramework named as t he Healt h Monit or. Wit h Healt h Monit or, Oracle
aut omat ically runs a diagnost ic operat ion ( called check) t o examine any dat abase corrupt ion or error. Checks run
in t wo ways:
o React i ve: I f t he f ault diagnosabilit y inf rast ruct ure cat ches a crit ical error, it aut omat ically runs healt h
checks t o search f or any f urt her f ailures relat ed t o t he caught f ailure.
o Man u al ( o r pr oact i ve) : A DBA may invoke t he checks manually using DBMS_HM or t he OEM.
Not e Oracle recommends t o f requent ly invoke t he Healt h checks on t he dat abase when it is under low
usage t o cat ch any corrupt ion or error t hat may cause damage in t he f ut ure.
Healt h Monit or f ramework provides several t ypes of dat abase healt h checks. Following are t he checks
undert aken by t he Healt h Monit or:
• DB St ruct ure Check
• Dat a Block I nt egrit y Check
• Redo I nt egrit y Check
• Undo Segment I nt egrit y Check
• Transact ion I nt egrit y Check
• Dict i onary I nt egrit y Check
To display list of t he check t hat can be perf ormed, issue t he f ollowing query:
SELECT NAME, DESCRIPTION, OFFLINE_CAPABLE FROM V$HM_CHECK;
The OFFLINE_CAPABLE column def ines whet her you can perf orm t he check when t he dat abase is of f line or not .
Ru n n i n g Heal t h Ch eck s Usi n g t h e DBMS_HM
A DBA can use DBMS_HM t o manually invoke t he dat abase check. To ret rieve t he list of checks t hat can be run
manually by users, issue t he f ollowing query:
SELECT NAME FROM V$HM_CHECK WHERE INTERNAL_CHECK = 'N';
Use t he procedure RUN_CHECK t o perf orm a dat abase healt h check. I t s f irst paramet er CHECKNAME is mandat ory
and it t akes one of t he ret urned names by t he query above.
exec DBMS_HM.RUN_CHECK(CHECK_NAME=>'DB Structure Integrity Check', RUN_NAME=>'HM01');
Most healt h checks accept input paramet ers. You can view paramet er names and descript ions wit h t he
V$HM_CHECK_PARAM view. Some paramet ers are mandat ory while ot hers are opt ional. The f ollowing query
displays paramet er inf ormat ion f or all healt h checks:
select C.NAME CHECK_NAME, P.NAME PARAMETER_NAME, P.TYPE,
P.DEFAULT_VALUE, P.DESCRIPTION
from V$HM_CHECK_PARAM P, V$HM_CHECK C
where P.CHECK_ID = C.ID and C.INTERNAL_CHECK = 'N'
order by C.NAME;
I nput paramet ers are passed t o t he INPUT_PARAMS argument of t he RUN_CHECK procedure as name/ value pairs
separat ed by semicolons ( ; ) . The f ollowing example illust rat es how t o pass t he t ransact ion I D as a paramet er t o
t he Transact ion I nt egrit y Check:
begin
DBMS_HM.RUN_CHECK (
CHECK_NAME => ' Transaction Integrity Check', -- passed value is case sensitive
RUN_NAME => 'MY_RUN', INPUT_PARAMS => 'TXN_ID=7.33.2');
end;
Page 26 Oracle 11g New Features for Administrators - Summary Sheets

Dat abase Healt h checks execut ions are st ored in ADR and can be viewed by eit her querying t he V$HM_RUN:
SELECT * FROM V$HM_RUN;
Anot her opt ion is t o run t he adrci command show hm_run:
adrci>show hm_run
You can view a report of a part icular Healt h check by using t he f ollowing adrci command:
adrci>show report hm_run HM01
Alt ernat ively, you can DBMS_HM package as shown in t he f ollowing code example:
declare
v_rpt clob;
begin
v_rpt := DBMS_HM.GET_RUN_REPORT('HM01');
end;
Findings, if any, det ect ed by t he checks can be obt ained f rom V$HM_FINDING and recommendat ions f rom
V$HM_RECOMMENDATION.
Ru n n i n g Heal t h Ch eck s Usi n g t h e En t er pr i se Man ager
Af t er connect ing as SYSDBA, under t he Advi sor Cen t r al page, you will see Ch eck er s link which can be used t o
manually invoke any Healt h check.
Dat a Recover y Adv i sor
Dat a Recovery Advisor is an Oracle Dat abase 11g t ool t hat aut omat ically diagnoses dat a f ailures, det ermines and
present s appropriat e repair opt ions, and execut es repairs at t he user' s request . Dat a Recovery Advisor can
diagnose f ailures such as t he f ollowing:
• I naccessible component s like dat af iles and cont rol f iles.
• Physical corrupt ions such as block checksum f ailures and invalid block header
• Field values
• I nconsist ent dat af iles ( online and of f line)
• I / O f ailures
The advisor however doe not recover f rom f ailures on st andby dat abases or RAC environment . This advisor can
be used t hrough RMAN or t he Ent erprise Manager.
Usi n g Dat a Recover y Advi sor w i t h RMAN
Following are t he RMAN commands t o use Dat a Recovery Advisor:
1. List f ailures by running t he LIST FAILURE command. Following are variat ions of using t he command:
RMAN>LIST FAILURE;
RMAN>LIST OPEN;
RMAN>LIST CLOSED;
2. Opt ionally, execut e LIST FAILURE ... DETAIL t o list det ails of an individual f ailure.
RMAN>LIST FAILURE 105 DETAIL;
3. I f you suspect t hat f ailures exist t hat have not been aut omat ically diagnosed by t he dat abase, t hen run
VALIDATE DATABASE t o check f or corrupt blocks and missing f iles. I f a f ailure is det ect ed, t hen RMAN logs it
int o t he ADR, where it can be accessed by t he Dat a Recovery Advisor.
4. Det ermine repair opt ions by running t he ADVISE FAILURE command.
RMAN>ADVISE FAILURE;
Page 27 Oracle 11g New Features for Administrators - Summary Sheets

5. Choose a repair opt ion. You can repair t he f ailures manually or run t he REPAIR FAILURE command t o f ix
t hem aut omat ically. By def ault , t he REPAIR FAILURE command prompt s t he user t o conf irm t he repair, but
t his can be prevent ed using t he NOPROMPT keyword. Be aware t hat t he previous command must be issued
bef ore using REPAIR FAILURE command.
The f ollowing f orm of t he command inf orms you how RMAN plans t o repair t he f ailure:
RMAN>REPAIR FAILURE PREVIEW
6. You may wish t o change t he priorit y of a f ailure ( t o HIGH or LOW) , if it does not represent a problem t o you,
or even manually close it . This can be done by t he CHANGE FAILURE command:
RMAN> CHANGE FAILURE 202 PRIORITY LOW;

Not e Dat a Recovery Advisor may det ect or handle some logical corrupt ions. But in general, corrupt ions of
t his t ype require help f rom Oracle Support Services.
Usi n g Dat a Recover y Advi sor w i t h t h e En t er pr i se Man ager
Access t he Dat a Recovery Advisor in t he Ent erprise Manager by f ollowing t he links: Avai l abi l i t y> Man age>
Per f or m Recover y> Per f or m Au t omat ed Repai r .
SQL Test Case Bui l der
The SQL Test Case Builder aims at capt uring t he inf ormat ion pert aining t o a SQL- relat ed problem, along wit h t he
exact environment under which t he problem occurred, so t hat t he problem can be reproduced and t est ed on a
separat e Oracle dat abase inst ance. Once t he t est case is ready, you can upload t he problem t o Oracle Support t o
enable support personnel t o reproduce and t roubleshoot t he problem.
The inf ormat ion gat hered by SQL Test Case Builder includes t he query being execut ed, t able and index
def init ions ( but not t he act ual dat a) , PL/ SQL f unct ions, procedures, and packages, opt imizer st at ist ics, and
init ializat ion paramet er set t ings.
The out put of t he SQL Test Case Builder is a SQL script t hat cont ains t he commands required t o recreat e all t he
necessary obj ect s and t he environment . The SQL Test Case Builder can be accessed using t he int erf ace package
DBMS_SQLDIAG or t he Ent erprise Manager.
Accessi n g SQL Test Case Bu i l der Usi n g DBMS_SQLDI AG
The DBMS_SQLDIAG has a procedure named EXPORT_SQL_TESTCASE which is used t o generat e a SQL t est case f or
a given SQL st at ement , SQL I d ( t aken f rom V$SQL) or an incident id. Following st eps should be f ollowed:
1. Creat e direct ory t o hold t he SQL t est case f iles.
CREATE DIRECTORY sql_tes_dir AS 'C:\Oracle\TestCase';
2. Execut e t he proper f orm of EXPORT_SQL_TESTCASE procedure. Following is an example using a passed SQL
st at ement .
DECLARE
V_SQL CLOB := 'SELECT * FROM HR.NAMES WHERE ID BETWEEN 100 AND 1000';
V_TESTCASE CLOB;
BEGIN
DBMS_SQLDIAG.EXPORT_SQL_TESTCASE (
DIRECTORY =>'SQL_TES_DIR',
SQL_TEXT =>V_SQL,
USER_NAME =>'HR',
BIND_LIST =>NULL,
EXPORTENVIRONMENT =>TRUE,
EXPORTMETADATA =>TRUE,
EXPORTDATA =>TRUE,
SAMPLINGPERCENT =>100,
CTRLOPTIONS =>NULL,
TIMELIMIT =>0,
TESTCASE_NAME =>'RETURN_NAMES', -- generated scripts prefix
TESTCASE =>V_TESTCASE);
END;
Page 28 Oracle 11g New Features for Administrators - Summary Sheets

Accessi n g SQL Test Case Bu i l der Usi n g t h e En t er pr i se Man ager
From Ent erprise Manager, t he SQL Test Case Builder is accessible only when a SQL incident occurs. SQL- relat ed
problem is ref erred t o as a SQL incident .
To access t he SQL Test Case Builder, f ollow t he links t h e Su ppor t Wor k ben ch page> Cl i ck on an i n ci den t
I D> I n vest i gat e an d Resol ve sect i on > Or acl e Su ppor t > Gen er at e Addi t i on al Du mps an d Test Cases>
cl i ck on t h e i con i n t h e Go To Task .
Dat a Bl ock Cor r upt i on Par amet er s
The new init ializat ion paramet er DB_ULTRA_SAFE set s t he def ault values f or ot her paramet ers t hat cont rol
prot ect ion levels. Also t his paramet er cont rols ot her dat a prot ect ion behavior in t he Oracle Dat abase, such as
requiring ASM t o perf orm sequent ial mirror writ es. Using t his paramet er is discussed in t he sect ion New
I nit ializat ion Paramet ers Af f ect ing Dat abase Creat ion.
Page 29 Oracle 11g New Features for Administrators - Summary Sheets

Dat abase Admi ni st r at i on
Aut omat i c Memor y Management

I n Oracle 11g, a new paramet er named as MEMORY_TARGET is added t o aut omat e memory allocat ion f or bot h t he
SGA and PGA. When t his paramet er is set , t he SGA and t he PGA memory sizes are aut omat ically det ermined by
t he inst ance based on t he dat abase workload.
This paramet er is dynamic and can be alt er using t he ALTER SYSTEM command as shown below:
ALTER SYSTEM SET MEMORY_TARGET = 1024M ;
However, if t he dat abase is not conf igured t o use t his paramet er and you want t o use it , you must rest art t he
dat abase af t er set t ing t he paramet er.
When you conf igure t he dat abase t o use MEMORY_TARGET, you should t ake int o considerat ion t he f ollowing:
• The paramet er STATISTICS_LEVEL must be set t o TYPICAL
• The paramet er MEMORY_MAX_SIZE cont rols t he maximum value you can set f or MEMORY_TARGET. I f you do not
set a value f or t his paramet er, it def ault s t o MEMORY_TARGET.
• I f you set t he paramet ers SGA_TARGET and PGA_TARGET, Oracle will consider t he values as t he minimum
values f or SGA and PGA.
• I f you do not set t he paramet ers SGA_TARGET and PGA_TARGET ( or set t hem t o zero) , no minimum value is
considered by Oracle f or t he SGA and PGA. When t he inst ance st art s, it assigns 60 percent t o SGA and 40
percent t o t he PGA.
• When MEMORY_TARGET is conf igured, t he f ollowing component s are aut o t uned: DB BUFFER CACHE, SHARED
POOL, JAVA POOL, LARGE POOL and STREAMS POOL.
To set a proper value t o t he paramet er MEMORY_TARGET, query t he view V$MEMORY_TARGET_ADVICE.
SELECT * FROM V$MEMORY_TARGET_ADVICE;
I n t he Ent erprise Manager, f ollow t he links Dat abase h ome page> Ser ver t ab> Dat abase con f i gu r at i on
sect i on > Memor y Advi sor s
To display current st at us of t he memory component s, use t he f ollowing query:
SELECT COMPONENT, ROUND(CURRENT_SIZE/1024/1024) CURRENT_SIZE ,
ROUND(MIN_SIZE/1024/1024) MIN, ROUND(MAX_SIZE/1024/1024) MAX
FROM V$MEMORY_DYNAMIC_COMPONENTS;
To know how Oracle has modif ied t he memory area sizes by t ime, issue t he f ollowing query:
select START_TIME, END_TIME, STATUS, COMPONENT, OPER_TYPE, OPER_MODE,
PARAMETER, INITIAL_SIZE/1024/1024 INITIAL_SIZE_MB,
TARGET_SIZE/1024/1024 TARGET_SIZE_MB, FINAL_SIZE/1024/1024 FINAL_SIZE_MB
from V$MEMORY_RESIZE_OPS
order by START_TIME, END_TIME

Not e On Linux syst ems, if you receive t he f ollowing error af t er set t ing t he MEMORY_TARGET paramet er, most
likely t he reason is t hat t he / dev/ shm is allocat ed a size ( can be known by issuing t he command df -
k) less t han SGA_MAX_SIZE:
ORA-00845: MEMORY_TARGET not supported on this system.
Resolving t he issue can be done by t he f ollowing OS commands:
#umount /dev/shm
#mount -t tmpfs shmfs -o *size=><xx>m* /dev/shm

Page 30 Oracle 11g New Features for Administrators - Summary Sheets

Aut omat i c Mai nt enance Task s
New Au t omat i c Mai n t en an ce Task
When you inst all Oracle dat abase 11g, t he f ollowing predef ined aut omat ic maint enance t asks will be creat ed in
t he scheduler:
• The Aut omat ic Opt imizer St at ist ics Collect ion t ask ( predef ined in Oracle 10g as well)
• The Aut omat ic Segment Advisor t ask ( predef ined in Oracle 10g as well)
• The Aut omat ic SQL Tuning Advisor ( int roduced in Oracle 11g) . The SQL Tuning Aut omat ion sect ion has a
brief descript ion about using t his t ool.
The lat er t ask issues t he Aut omat ic SQL Tuning Advisor which examines SQL st at ement s perf ormance and makes
SQL prof ile recommendat ions t o improve t hem. Det ail about using t his advisor will be discussed in Perf ormance
Management New Feat ures chapt er.
The Aut omat ed Maint enance Tasks are managed by t he Aut oTask Background Process ( ABP) . The process is
spawned by t he MMON background process at t he st art of t he maint enance window. Following are t he process
f unct ionalit ies:
• I t convert s aut omat ic t asks int o Scheduler j obs. I t does not execut e t he maint enance t asks.
• I t det ermines t he j obs t hat need t o be creat ed f or each maint enance t ask window.
• I t st ores t ask execut ion hist ory in t he SYSAUX t ablespace.
To display list of t he aut omat ic t asks in t he dat abase, issue t he f ollowing query:
SELECT TASK_NAME, OPERATION_NAME, STATUS
FROM DBA_AUTOTASK_TASK;
New Mai n t en an ce Wi n dow s
I n Oracle dat abase 11g, t here are seven predef ined maint enance windows. Their names derived f rom
MONDAY_WINDOW t o SUNDAY_WINDOW. Weekdays windows open at 10: 00 p. m. and close at 2: 00 a. m ( 4 hours) . The
weekend windows ( Sat urday and Sunday) open at 6: 00 a. m. and close in 20 hours.
All t hose windows are assigned t o a resource plan, DEFAULT_MAINTENANCE_PLAN, which is enabled aut omat ically
when t he maint enance windows are opened. The DEFAULT_MAINTENANCE_PLAN resource plan has a number of
consumer groups assigned t o it named as ORA$AUTOTASK_*_GROUP. This plan priorit izes SYS_GROUP operat ions
and allocat es t he remaining 5% t o diagnost ic operat ions and 25% t o aut omat ed maint enance operat ions.
To display list schedule of t he predef ined maint enance windows in t he next 32 days, issue t he f ollowing query:
SELECT WINDOW_NAME, to_char(START_TIME,'DD-Mon-RR hh24:mi') START_TIME, DURATION
FROM DBA_AUTOTASK_SCHEDULE
ORDER BY WINDOW_NAME, START_TIME DESC;
To display t he predef ined consumer groups assigned t o t he aut omat ic maint enance windows:
SELECT * FROM DBA_RSRC_CONSUMER_GROUPS G
WHERE G.CONSUMER_GROUP LIKE 'ORA$AUTO%'
En abl i n g an d Di sabl i n g Mai n t en an ce Task s
The DBMS_AUTO_TASK_ADMIN package can be t o manage t he aut omat ic t asks.
To disable all aut omat ic t asks in all maint enance windows, issue t he f ollowing command:
exec DBMS_AUTO_TASK_ADMIN.DISABLE;
To disable a part icular aut omat ed maint enance t asks f or all maint enance windows, issue t he f ollowing command:
Begin
DBMS_AUTO_TASK_ADMIN.DISABLE(
CLIENT_NAME => 'sql tuning advisor', -- as found in DBA_AUTOTASK_CLIENT
OPERATION => NULL,
WINDOW_NAME => NULL); -- all windows will be affected
end;
By passing a value t o t he WINDOW_NAME paramet er, you specif y t o which maint enance window t he t ask is t o be
disabled.
Similarly, ENABLE procedure is used t o enable t he aut omat ic t asks in t he maint enance windows. For example, t o
enable all aut omat ic t asks in all t he maint enance windows, issue t he f ollowing command:
exec DBMS_AUTO_TASK_ADMIN.ENABLE;
Page 31 Oracle 11g New Features for Administrators - Summary Sheets

Modi f yi n g a Mai n t en an ce Wi n dow
The DBMS_SCHEDULER package includes a SET_ATTRIBUTE procedure f or modif ying t he at t ribut es of a window.
Not e t hat you must disable t he window bef ore making changes t o it . I f you change a window when it is current ly
open, t he change does not t ake ef f ect unt il t he next t ime t he window opens.
For example, t he f ollowing script changes t he durat ion of t he maint enance window SATURDAY_WINDOW t o 4 hours:
begin
DBMS_SCHEDULER.DISABLE( NAME => 'SATURDAY_WINDOW');
DBMS_SCHEDULER.SET_ATTRIBUTE(
NAME => 'SATURDAY_WINDOW',
ATTRIBUTE => 'DURATION',
VALUE => numtodsinterval(4, 'hour'));
DBMS_SCHEDULER.ENABLE( NAME => 'SATURDAY_WINDOW');
end;
Cr eat i n g a New Mai n t en an ce Wi n dow
To creat e a maint enance window, you must creat e a Scheduler window and t hen add it t o t he window group
MAINTENANCE_WINDOW_GROUP as in t he f ollowing example:
begin
DBMS_SCHEDULER.CREATE_WINDOW(
WINDOW_NAME => 'EARLY_MORNING_WINDOW',
DURATION => numtodsinterval(1, 'hour'),
RESOURCE_PLAN => 'DEFAULT_MAINTENANCE_PLAN',
REPEAT_INTERVAL=> 'FREQ=DAILY;BYHOUR=5;BYMINUTE=0;BYSECOND=0');
DBMS_SCHEDULER.ADD_WINDOW_GROUP_MEMBER(
GROUP_NAME => 'MAINTENANCE_WINDOW_GROUP',
WINDOW_LIST => 'EARLY_MORNING_WINDOW');
end;
Removi n g a Mai n t en an ce Wi n dow
To remove an exist ing maint enance window, remove it f rom t he MAINTENANCE_WINDOW_GROUP window group. The
window cont inues t o exist but no longer runs aut omat ed maint enance t asks. Any ot her Scheduler j obs assigned
t o t his window cont inue t o run as usual.
begin
DBMS_SCHEDULER.REMOVE_WINDOW_GROUP_MEMBER(
GROUP_NAME => 'MAINTENANCE_WINDOW_GROUP',
WINDOW_LIST => 'EARLY_MORNING_WINDOW');
end;
Man agi n g Au t omat i c Mai n t en an ce Task s i n t h e En t er pr i se Man ager
Follow t he link Dat abase Home page> Sch edu l er Cen t r al at t he bot t om of t he page.
From t he scheduler home page you can see bot h aut omat ed maint enance t asks running via Aut oTask, regular
scheduler j obs, or Ent erprise Manager j obs.
Au t omat i c Mai n t en an ce Task Di ct i on ar y Vi ew s
Oracle Dat abase 11g has removed t he old j obs f rom t he DBA_SCHEDULER_* views, and moved t hem t o
DBA_AUTOTASK_* views. Below is a list of queries f rom some of t hem.
The DBA_AUTOTASK_CLIENT view displays st at ist ical dat a f or each aut omat ed maint enance t ask ( client ) over 7-
day and 30- day periods.
SELECT * FROM DBA_AUTOTASK_CLIENT ORDER BY CLIENT_NAME;
The DBA_AUTOTASK_CLIENT_HISTORY view displays per- window hist ory of j ob execut ion count s f or each
aut omat ed maint enance t ask.
SELECT CLIENT_NAME, WINDOW_NAME, JOBS_CREATED, JOBS_STARTED, JOBS_COMPLETED
FROM DBA_AUTOTASK_CLIENT_HISTORY
WHERE CLIENT_NAME = 'auto optimizer stats collection';
The DBA_AUTOTASK_CLIENT_JOB view displays inf ormat ion about current ly running scheduler j obs creat ed f or
aut omat ed maint enance t asks.
select CLIENT_NAME, JOB_NAME, JOB_SCHEDULER_STATUS "Job status",
Page 32 Oracle 11g New Features for Administrators - Summary Sheets

TASK_NAME, TASK_TARGET_TYPE, TASK_TARGET_NAME "Name of the target",
TASK_PRIORITY, TASK_OPERATION
from DBA_AUTOTASK_CLIENT_JOB
order by CLIENT_NAME;
The DBA_AUTOTASK_JOB_HISTORY view displays t he hist ory of aut omat ed maint enance t ask j ob runs.
SELECT CLIENT_NAME, JOB_STATUS, JOB_START_TIME, JOB_DURATION
FROM DBA_AUTOTASK_JOB_HISTORY
WHERE CLIENT_NAME = 'auto optimizer stats collection';

Or acl e Fl ashback - Rel at ed New Feat ur es
Oracle Dat abase 11g int roduces t he f ollowing new Flashback- relat ed f eat ures:
• LogMiner I nt erf ace in Oracle Ent erprise Manager
• Oracle Flashback Transact ion Backout
• Oracle Flashback Dat a Archives
Those f eat ures will be discussed in t he f ollowing sect ions
LogMi ner I nt er f ace i n Or acl e Ent er pr i se Manager
Bef ore Oracle Dat abase 11g, in order t o use t he LogMiner t o examine and rollback t ransact ions, you needed t o
use t he DBMS_LOGMNR package t o perf orm command- line- driven log mining. I n Oracle 11g, t he Ent erprise
Manager has a graphical int erf ace t o ext ract t ransact ion f rom t he redo logs using LogMiner, which is much easier
t o use.
To invoke t he LogMiner f rom OEM, f ollow t he links Dat abase Homepage- > Avai l abi l i t y- > Vi ew an d Man age
Tr an sact i on s
You can t hen ret rieve t he required t ransact ions based on an ent ered range of t ime periods or SCNs.
Also, you can ent er addit ional f ilt ering condit ions in t he Adv an ced Qu er y f ield under Qu er y Fi l t er . For
example, t o f ind t ransact ions applied on t he record where locat ion = ' BOSTON' in t he DEPT t able in SCOTT
schema, ent er SCOTT.% in t he TABLE f ield and "DBMS_LOGMNR.COLMN_PRESENT(UNDO_VALUE,'SCOTT.DEPT.LOC')=
'BOSTON'" in t he Addit ional LogMiner Columns f ield.
Or acl e Fl ashback Tr ansact i on Back out
This f eat ure allows a DBA t o back- out a commit t ed t ransact ion and all dependent t ransact ions while t he dat abase
is st ill online.
Set t i n g Up f or Fl ash back Tr an sact i on Back ou t
1. Enable supplement al logging wit h primary key logging as seen in t his example:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
2. Grant EXECUTE on DBMS_FLASHBACK t o t he user who will be perf orming t he Flashback Transact ion Backout .
3. Finally, grant SELECT ANY TRANSACTION t o t he user who will be perf orming t he Flashback Transact ion
Backout .
Ex ecu t i n g a Fl ash back Tr an sact i on Back ou t i n OEM
Follow t he links Dat abase h ome page> Sch ema t ab i n OEM> Dat abase Obj ect s sect i on > Tabl es l i n k >
sel ect a t abl e> sel ect t h e Fl ash back Tr an sact i on act i on f or t he t able you have select ed.
Oracle will use t he LogMiner t o mine all t he t ransact ions on t he t able over t he given period of t ime or SCN.
Ex ecu t i n g a Fl ash back Tr an sact i on Back ou t Man u al l y
Following are t he st eps t o manually perf orm t he backout :
1. You need t o know t he t ransact ion I D. The V$TRANSACTION view provides t his f or you wit h t he XI D column if
you are in t he middle of a t ransact ion. Opt ionally you could use Log Miner t o f ind t he candidat e t ransact ion
I Ds.
select A.SQL_TEXT, B.XID
from V$OPEN_CURSOR A, V$TRANSACTION B, V$SESSION C
Page 33 Oracle 11g New Features for Administrators - Summary Sheets

where A.SID=C.SID AND C.TADDR=B.ADDR
and A.SQL_TEXT LIKE '%delete%';
2. Use t he DBMS_FLASHBACK.TRANSACTION_BACKOUT procedure t o back out t he t ransact ion.
declare
V_XID SYS.XID_ARRAY;
begin
V_XID := SYS.XID_ARRAY('03001800BC0D0000');
DBMS_FLASHBACK.TRANSACTION_BACKOUT( NUMTXNS => 1,
XIDS=>V_XID, OPTIONS=>DBMS_FLASHBACK.CASCADE);
end;
The OPTIONS paramet er can also accept t he value DBMS_FLASHBACK.NOCASCADE_FORCE. Wit h t his opt ion, t he user
f orcibly backs out t he given t ransact ions wit hout considering t he dependent t ransact ions. The RDBMS execut es
t he UNDO SQL f or t he given t ransact ions in reverse order of t heir commit t imes. I f no const raint s break, and t he
result is sat isf act ory, t he user can eit her COMMI T t he changes or else ROLL BACK
Obt ai n i n g I n f or mat i on abou t Fl ash back Tr an sact i on Back ou t s
I nf ormat ion about t ransact ion Backout s can be obt ained f rom t he f ollowing views:
• DBA_FLASHBACK_TXN_STATE any t ransact ion shown in t his view is backed out .
• DBA_FLASHBACK_TXN_REPORT provides inf ormat ion about t he compensat ing st at us of all t ransact ions in t he
dat abase.
Fl ashback Dat a Ar chi v e
A f lashback dat a archive ( FDA) is a new obj ect t hat holds hist orical dat a f or one or several t ables. FDA
mechanism operat es as f ollows:
• Once t he FDA is enabled f or a t able, an int ernal hist ory t able is creat ed f or t hat t able.
• A new background process named as FBDA wakes up at syst em- det ermined int ervals ( def ault f ive
minut es) and copies t he undo dat a f or t he marked t ransact ions t o t he hist ory t able( s) . Thus, undo dat a
marked f or archiving are not re- used by t he dat abase unt il it is st ored by t he FBDA int o t he hist ory t able.
Not e
You can f ind t he int ernally assigned names of t he hist ory t ables by querying t he
*_FLASHBACK_ARCHIVE_TABLES view. Hist ory t ables are compressed and int ernally part it ioned.
FDA is part of t he "Oracle Tot al Recall" opt ion in Oracle dat abase 11g. Hist orical dat a is st ored in compressed
f orm t o minimize st orage requirement s and it is complet ely t ransparent t o applicat ions.
Dat a Fl ash back Ar ch i ve Requ i r emen t s
To set up t he DFA in a dat abase, t he f ollowing condit ions must apply:
• Aut omat ic undo management must be enabled in t he dat abase.
• The t ablespace in which t he FDA is creat ed must be managed wit h Aut omat ic Segment Space
Management ( ASSM) .
Set t i n g u p t h e Dat a Fl ash back Ar ch i ve
Following are t he st eps you should carry out t o set up t he DFA:
1. To def ine a syst em- level DFA, DBA role or t he syst em privilege FLASHBACK ARCHIVE ADMINISTER must
be grant ed. To display users or roles which grant ed t his privilege, issue t he f ollowing query:
SELECT * FROM DBA_SYS_PRIVS WHERE PRIVILEGE LIKE '%FLASHBACK ARC%'
2. Creat e FDA obj ect . You can def ine it s t ablespace, ret ent ion period and quot a size.
CREATE FLASHBACK ARCHIVE hr_hist
TABLESPACE fda_archives -- mandatory (and it must be with ASSM)
QUOTA 5G -- optional in M,G,T,P
RETENTION 24 MONTH; -- mandatory (in YEAR, MONTH, DAY)
Page 34 Oracle 11g New Features for Administrators - Summary Sheets

For t he command above, not e t he f ollowing:
o I f QUOTA keyword is omit t ed, t he f lashback archive will t ake up all available space in t he t ablespace.
o Dat a exceeding t he ret ent ion period will be aut omat ically purged af t er one day of t he ret ent ion expiry
period.
o You can use t he DEFAULT keyword ( CREATE FLASHBACK ARCHIVE DEFAULT) t o designat e t his f lashback
dat a archive as t he def ault f lashback dat a archive f or t he dat abase. Using t his keyword requires SYSDBA
privilege.
Not e At t ime of writ ing t his document , t he st at ement in t he example above may ret urn ORA-55603:
Invalid Flashback Archive command error, if you t ry t o creat e a f lashback archive in a non- empt y
t ablespace. I f igured out a workaround which is t o put t he t ablespace name bet ween double
quot at ions.
3. Enable Flashback Dat a Archiving f or exist ing or new t ables. A user who want s t o do t hat should be
grant ed eit her t he SYSDBA privilege, t he syst em privilege FLASHBACK ARCHIVE ADMINISTER, or t he
obj ect privilege FLASHBACK ARCHIVE on t he creat ed f lashback archive. Following is an example of
grant ing t he obj ect privilege:
GRANT FLASHBACK ARCHIVE ON hr_hist TO scott;
Commands used t o enable FDA on t ables are illust rat ed in t he examples blow:
-- Create the table, using the default archive location.
CREATE TABLE my_table(..) FLASHBACK ARCHIVE;
-- Modify a table to use the default archive location
-- Note: if there is not default flashback archive, an error will be raised
ALTER TABLE my_table FLASHBACK ARCHIVE;
-- Create a table to use a non-default archivelocation
CREATE TABLE my_table (..) FLASHBACK ARCHIVE hr_arc;
-- Modify a table to use a non-default archive location.
ALTER TABLE my_table FLASHBACK ARCHIVE hr_arc;
-- Modify a table to stop (disable) archiving.
ALTER TABLE my_table NO FLASHBACK ARCHIVE;

Not e Disabling f lashback archiving f or a t able or dropping it s f lashback archive obj ect will result in all t he
hist ori cal dat a f or t hat t able being lost . I t also requires SYSDBA or FLASHBACK ARCHIVE ADMINISTER
privilege.
Al t er i n g Fl ash back Ar ch i ves
Use ALTER FLASBACK command t o alt er a f lashback archive obj ect . Below are examples of using t his command:
-- make myflash the default flashback archive (as SYSDBA)
ALTER FLASHBACK ARCHIVE myflash SET DEFAULT;
-- add space to the flashback archive
ALTER FLASHBACK ARCHIVE myflash ADD TABLESPACE mytbs;
-- remove the tablespace from use by the flashback archive
-- (assign it to another tablespace first)
ALTER FLASHBACK ARCHIVE myflash REMOVE TABLESPACE mytbs;
-- change the quota for the archive
ALTER FLASHBACK ARCHIVE myflash MODIFY TABLESPACE mytbs QUOTA 10G;
-- undefined quota (make the space unlimited)
ALTER FLASHBACK ARCHIVE myflash MODIFY TABLESPACE mytbs;
-- change the archive retention time
ALTER FLASHBACK ARCHIVE myflash MODIFY RETENTION 2 YEAR;
-- purge all archived data
ALTER FLASHBACK ARCHIVE myflash PURGE ALL;
-- purge data older than 2 days
ALTER FLASHBACK ARCHIVE MYFLASH
PURGE BEFORE TIMESTAMP( SYSTIMESTAMP – INTERVAL '2' DAY);
Page 35 Oracle 11g New Features for Administrators - Summary Sheets

Usi n g Or acl e Fl ash back Dat a Ar ch i ves
The normal f lashback query and Flashback Versions Query can now use t he Flash Archive dat a t o ret rieve old
dat a. Following are illust rat ing examples:
SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES
AS OF TIMESTAMP TO_TIMESTAMP ('2008-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS');
SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '6' MONTH);
SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES
VERSIONS BETWEEN TIMESTAMP
TO_TIMESTAMP ('2008-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS') -- or MINVALUE
AND
TO_TIMESTAMP ('2008-01-01 15:00:00','YYYY-MM-DD HH24:MI:SS') -- or MAXVALUE
WHERE EMPLOYEE_ID = 200;
Furt hermore, f lashback t able t akes advant age of t he Flashback Archive. Following is an example:
FLASHBACK TABLE employees TO TIMESTAMP (SYSTIMESTAMP – INTERVAL '6' MONTH);
Fl ash back Dat a Ar ch i ve Li mi t at i on s
For a t able wit h Flashback Archiving enabled, you cannot issue t he f ollowing DDL commands: ALTER TABLE
(except adding a column), DROP TABLE, RENAME TABLE and TRUNCATE TABLE.
Obt ai n i n g I n f or mat i on abou t Fl ash back Dat a Ar ch i ve
DBA_FLASHBACK_ARCHIVE provides inf ormat ion on all f lashback archives cont ained in t he dat abase.
SELECT * FROM DBA_FLASHBACK_ARCHIVE;
DBA_FLASHBACK_ARCHIVE_TS provides inf ormat ion on all t ablespaces cont aining f lashback archives.
SELECT * FROM DBA_FLASHBACK_ARCHIVE_TS;
DBA_FLASHBACK_ARCHIVE_TABLES indicat es which f lashback archive a given t able is assigned t o.
SELECT TABLE_NAME, OWNER_NAME, FLASHBACK_ARCHIVE_NAME FROM DBA_FLASHBACK_ARCHIVE_TABLES;

Vi r t ual Col umns
I n Oracle 11g, you can def ine a column in a t able t hat cont ains derived dat a. You can use virt ual columns in you
queries, creat e indexes on t hem, and even collect st at ist ics on t hem. There are a f ew rest rict ions including:
• You cannot writ e t o a virt ual column.
• There is no support f or index- organized, ext ernal, obj ect , clust er, or t emporary t ables.
• There is no support f or Oracle- supplied dat at ypes, user- def ined t ypes, LOBs, or LONG RAWs.
Cr eat i n g Tabl es w i t h Vi r t u al Col u mn s
Following is t he synt ax you use t o creat e a virt ual column as part of t he CREATE TABLE or ALTER TABLE
st at ement s:
column [datatype] [GENERATED ALWAYS] AS ( <column_expression> ) [VIRTUAL] [( inline_constraint
[,...] )]
Not e t he f ollowing:
• GENERATED ALWAYS and VIRTUAL are opt ional and are j ust used t o clarif y t hat t he dat a is not st ored on disk.
• COLUMN_EXPRESSION def ines t he cont ent of t he virt ual column. I t has t he f ollowing rest rict ions:
o The expression cannot ref erence anot her virt ual column.
o All columns ref erenced in t he expression must exist in t he same t able.
o The out put of t he column expression must be a scalar value.
Following is a code example f or creat ing a virt ual column:
CREATE TABLE EMPLOYEES
( empno number PRIMARY KEY,
sal NUMBER (8,2) NOT NULL,
annual_sal AS (sal*12),
CONSTRAINT MaxAnSal CHECK (annual_sal BETWEEN 0 AND 2000000) );
Page 36 Oracle 11g New Features for Administrators - Summary Sheets

SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT
FROM DBA_TAB_COLUMNS
WHERE TABLE_NAME='EMPLOYEES' AND COLUMN_NAME='ANNUAL_SAL';

New Dat a Par t i t i oni ng Schemes
New part it ioning f eat ures int roduced in Oracle Dat abase 11g including t he f ollowing:
o I nt erval part it ioning
o Ext ended composit e part it ioning
o Ref erence part it ioning
o Syst em part it ioning
o Syst em- managed domain indexes
Ref er t o t he Part it ioning I mprovement s sect ion in t he Dat a Warehousing chapt er f or more det ails.
DDL Lock Ti meout
I n Oracle 11g, t he new init ializat ion paramet er DDL_LOCK_TIMEOUT cont rols t he durat ion ( in seconds) f or which a
DDL st at ement will wait f or a DML lock. The def ault value of zero indicat es a st at us of NOWAIT. The maximum
value of 1, 000, 000 seconds will result in t he DDL st at ement wait ing f orever t o acquire a DML lock.
ALTER SYSTEM SET DDL_LOCK_TIMEOUT = 60 ;
ALTER SESSION SET DDL_LOCK_TIMEOUT = 60 ;

Ex pl i ci t Lock i ng of Tabl es
The LOCK TABLE command has a new keyword named as WAIT which let s you specif y t he maximum t ime a
st at ement should wait t o obt ain a DML lock on t able.
LOCK TABLE .. IN <lockmode> MODE [ NOWAIT | WAIT n ]
For t he provided synt ax, not e t he f ollowing:
• n is an int eger value in seconds
• I f you do not specif y eit her WIAT nor NOWAIT, Oracle will wait unt il t he lock is available and acquired.
LOCK TABLE mytab IN EXCLUSIVE MODE WAIT 60;
LOCK TABLE mytab IN SHARE MODE NOWAIT;

I nvi si bl e I ndex es
I nvisible index is an index t hat is not considered by t he opt imizer when creat ing t he execut ion plans. This can be
used t o t est t he ef f ect of adding an index t o a t able on a query ( using index hint ) wit hout act ually being used by
t he ot her queries.
Following are t he commands t o creat e an invisible index, change visibilit y of an exist ing index and obt aining
inf ormat ion about invisible indexes:
CREATE INDEX name_indx ON employees(emp_name) INVISIBLE;
SELECT /*+ index (EMP_NAME NAME_INDEX) */ ...
ALTER INDEX name_indx VISIBLE;
ALTER INDEX name_indx INVISIBLE;
SELECT INDEX_NAME, VISIBILITY FROM DBA_INDEXES WHERE INDEX_NAME='NAME_INDX';
When using invisible indexes, consider t he f ollowing:
• I f you rebuild an invisible index, t he result ing operat ion will make t he index visible.
• I f you want t he opt imizer t o consider t he invisible indexes in it s operat ion, you can set t he new init ializat ion
paramet er OPTIMIZER_USE_INVISIBLE_INDEXES t o TRUE ( t he def ault is FALSE) . You can set t he paramet er
in t he syst em and session levels.
Page 37 Oracle 11g New Features for Administrators - Summary Sheets

Read- Onl y Tabl es
I n Oracle 11g, you can set a t able t o be read only, i. e. users can only query f rom t he t able but no DML
st at ement is allowed on t he t able. Following are t he commands t o achieve t his:
ALTER TABLE employees READ ONLY;
ALTER TABLE employees READ WRITE;
SELECT TABLE_NAME, READ_ONLY FROM USER_TABLES WHERE TABLE_NAME='EMPLOYEES';

Def er r ed Segment Cr eat i on
Beginning wit h Oracle Dat abase 11g Release 2, when you creat e heap or part it ioned t ables in a locally managed
t ablespace, t he dat abase def ers t able segment creat ion unt il t he f irst row is insert ed.
This f eat ure saves disk space in applicat ions t hat creat e hundreds or t housands of t ables upon inst allat ion, many
of which might never be populat ed.
Def erred segment t able do not init ially appear in * _segment s
-- db level:
show parameter DEFERRED_SEGMENT_CREATION
alter system set deferred_segment_creation=true scope=both ;


-- table level
create table test ( .. ) SEGMENT CREATION DEFERRED partition by .. ;
create table test ( .. ) SEGMENT CREATION IMMEDIATE ;

-- (11.2.0.2) If you want to create the segments for objects where
-- SEGMENT CREATION DEFERRED is set without waiting for
-- inserting any rows:

-- all the objects in a schema:
conn / as sysdba
begin
DBMS_SPACE_ADMIN.MATERIALIZE_DEFERRED_SEGMENTS (
schema_name =>'SA');
end;

-- specific table:
begin
DBMS_SPACE_ADMIN.MATERIALIZE_DEFERRED_SEGMENTS (
schema_name =>'SA', table_name=>'EMP');
end;

-- specific partition
begin
DBMS_SPACE_ADMIN.MATERIALIZE_DEFERRED_SEGMENTS (
schema_name =>'SA', table_name=>'EMP',
partition_name=>'PAR01');
end;

Shr i nk i ng Tempor ar y Tabl espaces and Tempf i l es
I n Oracle 11g, you can shrink t emporary t ablespaces and t empf iles. Following are t he commands t o achieve
t hat :
ALTER TABLESPACE temp SHRINK SPACE KEEP 100M; -- the KEEP keyword is optional.
ALTER TABLESPACE temp SHRINK TEMPFILE '/u01/app/oracle/oradata/ora11g/temp01.dbf';
-- to obtain information about temporary space usage
SELECT * FROM DBA_TEMP_FREE_SPACE

Page 38 Oracle 11g New Features for Administrators - Summary Sheets

Cr eat i ng an I ni t i al i zat i on Par amet er Fi l e f r om Memor y
I n Oracle 11g, you can creat e a pf ile or spf ile f rom t he current values of t he init ializat ion paramet ers ( act ive in
t he inst ance) . Following is t he code example t o do so:
CREATE PFILE FROM MEMORY;
CREATE SPFILE FROM MEMORY;
The generat ed f ile will cont ain all t he init ializat ion paramet ers used by t he inst ance whet her exact ly set by t he
DBA or t aken as def ault values.
Rest or e Poi nt Enhancement s
Cr eat i n g Rest or e Poi n t " as of " an SCN or a Ti mest amp
Wit h Oracle 11g, you can creat e a rest ore point f or a specif ic SCN in t he past or a past point in t ime.
CREATE RESTORE POINT res_jun08 AS OF SCN 2340009;
CREATE RESTORE POINT res_jun08 AS OF TIMESTAMP to_date('01-04-2008 07:30','DD-MM-YYYY
HH24:MI');
The dat abase must be able t o f lashback t o t he t ime point you select t o creat e t he rest ore point .
Pr eser vi n g Rest or e Poi n t s
I n Oracle dat abase 10g, Oracle may reach t o sit uat ions where it delet es rest ore point s ( but not t he guarant eed
rest ore point s) . I n Oracle 11g, you can creat e a rest ore point wit h PRESERVE opt ion t o prevent Oracle f rom
delet ing it .
CREATE RESTORE POINT myrp PRESERVE;
Usi n g Rest or e Poi n t s w i t h Cr eat i n g Ar ch i val Back u ps
Rest ore point s can be used during t he implement at ion of archival backups. Det ails of t his t ype of backup are
explained in Archival Backup sect ion. s
Dat abase Resi dent Connect i on Pool i ng
Dat abase Resident Connect ion Pooling ( DRCP) is a pool of dedicat ed servers in t he dat abase f or t ypical Web
applicat ion usage scenarios. DRCP can be used by client s t hat use OCI driver including C, C+ + and PHP.
How i t w or k s
1. When a client process or t hread connect s t o t he dat abase, t he connect ion is est ablished bet ween t he client
and t he connect ion broker ( it is a new background process named as connect ion monit or CMON) in Oracle
dat abase.
2. When t he client sends a request , t he connect ion broker will assign t he client connect ion t o one of t he pooled
servers, if available. I f no pooled server is f ree, t he connect ion broker will creat e a new pooled server. I f
number of t he exist ing pooled servers reaches t o t he maximum, t he client connect ion will go int o a wait
queue t ill one of t he pooled servers becomes f ree.
3. The client connect ion releases t he pooled server back t o t he connect ion pool once it s request is serviced by
t he dat abase.
DRCP Advan t ages
DRCP provides t he f ollowing advant ages:
• DRCP is especially usef ul f or archit ect ures wit h mult i- process, single- t hreaded applicat ion servers, such as
PHP and Apache servers, t hat cannot do middle- t ier connect ion pooling.
• DRCP enables a signif icant reduct ion ( compared t o t he dedicat ed server mechanism) in key dat abase
resources ( specially t he memory) t hat are required t o support a large number of client connect ions.
• DRCP boost s t he scalabilit y of bot h t he dat abase server and t he middle- t ier.
• The pool of readily available servers also reduces t he cost of re- creat ing client connect ions.
Page 39 Oracle 11g New Features for Administrators - Summary Sheets

Con f i gu r i n g DRCP
DRCP is aut omat ically creat ed wit h any Oracle 11g dat abase but it is disabled by def ault . The f ollowing sub-
sect ion illust rat es how t o enable it . DRCP is cont rolled by t he f ollowing conf igurat ion paramet ers:
INACTIVITY_TIMEOUT maximum idle t ime f or a pooled server bef ore it is t erminat ed.
MAX_LIFETIME_SESSION t ime t o live TTL durat ion f or a pooled session.
MAX_USE_SESSION maximum number of t imes a connect ion can be t aken and released t o t he pool.
MAX_SIZE and MIN_SZIE t he maximum and minimum number of pooled servers in t he connect ions pool.
INCRSIZE pool would increment by t his number of pooled server when pooled server are
unavailable at applicat ion request t ime.
MAX_THINK_TIME maximum t ime of inact ivit y by t he client af t er get t ing a server f rom t he pool. I f
t he client does not issue a dat abase call af t er grabbing a server f rom t he pool,
t he client will be f orced t o relinquish cont rol of t he pooled server and will get an
error. The f reed up server may or may not be ret urned t o t he pool.
SESSION_CACHED_CURSORS t urn on SESSION_CACHED_CURSORS f or all connect ions in t he pool. This is an
exist ing init ializat ion paramet er
To modif y value of any of t he paramet ers above, use ALTER_PARAM procedure in DBMS_CONNECTION_POOL
package as show in t he example below:
begin
DBMS_CONNECTION_POOL.ALTER_PARAM( PARAM_NAME =>'INACTIVITY_TIMEOUT',
PARAM_VALUE=>'3600');
end;
To obt ain inf ormat ion about t he DRCP conf igurat ion, you can query t he view DB_CPOOL_INFO.
To rest ore all t he connect ion pool conf igurat ion paramet ers t o t heir def ault values, use t he code below:
exec DBMS_CONNECTION_POOL.RESTORE_DEFAULTS();
En abl i n g DRCP
To enable t he DRCP, af t er connect ing as SYSDBA use START_POOL procedure in t he DBMS_CONNECTION_POOL
package as show in t he example below:
exec DBMS_CONNECTION_POOL.START_POOL();

Not e I f you st art t he DRCP and t hen t he inst ance is rest art ed, t he pool is aut omat i cally st art ed.
Disabling DRCP can be done wit h t he code below:
exec DBMS_CONNECTION_POOL.STOP_POOL();
Cl i en t Con n ect i on Con f i gu r at i on
I f t he client is using easy Connect st ring, DRCP is specif ied in t he f ollowing way:
hostname.company.com:1521/mydb.company.com:POOLED
I f t he client is using t nsnames. ora f ile, t he conf igurat ion should be as f ollows:
MYDB = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=hostname.company.com)
(SERVER=POOLED)))
Also, Oracle ext ended t he OCI SessionPool API s so t hat t hey work wit h DRCP. For f urt her det ails on t hat , see t he
document at ion Oracle Call I nt erf ace Programmer' s Guide.
Mon i t or i n g DRCP
To monit or DRCP in a dat abase, use t he f ollowing dat a dict ionary views:
V$_CPOOL_INFO
Shows t he st at us of t he connect ion pool and it s conf igurat ion inf ormat ion.
V$CPOOL_STATS
Shows st at ist ics about t he pool.
V$CPOOL_CC_STATS
Shows det ails about t he connect ion class- level st at ist ics.
Page 40 Oracle 11g New Features for Administrators - Summary Sheets

Following are some queries on t he views above:
SELECT STATUS,MINSIZE,MAXSIZE,INCRSIZE,SESSION_CACHED_CURSORS,INACTIVITY_TIMEOUT
FROM DBA_CPOOL_INFO;
SELECT NUM_OPEN_SERVERS, NUM_BUSY_SERVERS, NUM_REQUESTS, NUM_HITS
NUM_MISSES, NUM_WAITS, NUM_PURGED, HISTORIC_MAX
FROM V$CPOOL_STATS;

Compar i ng and Sy nchr oni zi ng Dat abase Obj ect s
I n Oracle 11g, t he DBMS_COMPARISON package is developed t o use it when you want t o compare t wo dat abase
obj ect s in replicat ed dat abases and, if you wish, synchronize dat a bet ween t hem. This is pract ically usef ul when
you have t wo obj ect s in replicat ed dat abases ( shared dat abase obj ect s) out of synchronizat ion. The package
allows you t o compare t ables, simple views or mat erialized views ( or of course synonyms f or t hem) .
To use DBMS_COMPARISON package, t he t wo obj ect s must have a column wit h an index of primary key or non- null
unique const raint . This column is used t o uniquely ident if y t he rows in bot h t ables and known as index column.
Following are example of using t he DBMS_COMPARISON package in comparing t wo t ables in dif f erent dat abases:
1. Run t he CREATE_COMPARE procedure in t his package t o creat e a comparison.
begin
DBMS_COMPARISON.CREATE_COMPARISON(
COMPARISON_NAME =>'Compare_EMP',
SCHEMA_NAME =>'HR',
OBJECT_NAME =>'EMPLOYEES',
DBLINK_NAME =>'REMOTE_DB',
REMOTE_SCHEMA_NAME=>'HR',
REMOTE_OBJECT_NAME=>'EMP2' );
end;

Not e I f you want t o compare t wo obj ect s in t he same dat abase, as a workaround, you can creat e a
dat abase link connect ing t o t he same local dat abase.
2. Run t he COMPARE f unct ion. This f unct ion populat es dat a dict ionary views wit h comparison result s. You can
invoke t he f unct ion lat er at any t ime t o re- compare t he obj ect s.
declare
V_CONSISTEN BOOLEAN;
V_SCAN_INFO DBMS_COMPARISON.COMPARISON_TYPE;
begin
V_CONSISTEN := DBMS_COMPARISON.COMPARE(
COMPARISON_NAME => 'Compare_Emp',
SCAN_INFO => V_SCAN_INFO,
PERFORM_ROW_DIF =>TRUE );
DBMS_OUTPUT.PUT_LINE('Scan ID: ' || V_SCAN_INFO.SCAN_ID);
IF V_CONSISTEN THEN
DBMS_OUTPUT.PUT_LINE('Data are synchronized.');
ELSE
DBMS_OUTPUT.PUT_LINE('Data are out of synchronization.');
END IF;
end;
3. I f you want t o examine t he comparison result s, query t he f ollowing dat a dict ionary views:
DBA_COMPARISON_SCAN USER_COMPARISON_SCAN
DBA_COMPARISON_SCAN_SUMMARY USER_COMPARISON_SCAN_SUMMARY
DBA_COMPARISON_SCAN_VALUES USER_COMPARISON_SCAN_VALUES
DBA_COMPARISON_ROW_DIF USER_COMPARISON_ROW_DIF
Following is an example code of using t hose views t o view number of rows t hat were f ound dif f erent in t he t wo
t ables:
SELECT C.OWNER, C.COMPARISON_NAME, C.SCHEMA_NAME, C.OBJECT_NAME,
S.CURRENT_DIFF_COUNT
FROM DBA_COMPARISON C, DBA_COMPARISON_SCAN_SUMMARY S
WHERE C.COMPARISON_NAME = S.COMPARISON_NAME AND C.OWNER = S.OWNER AND SCAN_ID = 45;
Page 41 Oracle 11g New Features for Administrators - Summary Sheets

Following is a query t o f ind t he rowid or index values of t he rows t hat eit her exist only in one of t he t wo dat a
set s or have dif f erences in t heir dat a values.
SELECT c.COLUMN_NAME, r.INDEX_VALUE
, case when r.LOCAL_ROWID is null
then 'No'
else 'Yes'
end LOCAL_ROWID
, case when r.REMOTE_ROWID is null
then 'No'
else 'Yes'
end REMOTE_ROWID
FROM USER_COMPARISON_COLUMNS c, USER_COMPARISON_ROW_DIF r, USER_COMPARISON_SCAN s
WHERE c.COMPARISON_NAME = 'COMPARE_EMP_AND_CLONE'
AND r.SCAN_ID = s.SCAN_ID
AND s.last_update_time > systimestamp – (1/24/15)
AND r.STATUS = 'DIF'
AND c.INDEX_COLUMN = 'Y'
AND c.COMPARISON_NAME = r.COMPARISON_NAME
ORDER BY r.INDEX_VALUE
4. I f t here are dif f erences, and you want t o synchronize t he dat abase obj ect s at t he t wo dat abases, t hen run t he
CONVERGE procedure in t his package as shown in t he f ollowing code example:
SET SERVEROUTPUT ON;
declare
V_SCAN_INFO DBMS_COMPARISON.COMPARISON_TYPE;
begin
DBMS_COMPARISON.CONVERGE(
COMPARISON_NAME => 'Compare_Emp',
SCAN_ID =>45,
SCAN_INFO => V_SCAN_INFO,
CONVERGE_OPTIONS=>DBMS_COMPARISON.CMP_CONVERGE_LOCAL_WINS);
-- alternatively use CMP_CONVERGE_REMOTE_WINS
DBMS_OUTPUT.PUT_LINE('Local Rows Merged:' || V_SCAN_INFO.LOC_ROWS_MERGED);
DBMS_OUTPUT.PUT_LINE('Remote Rows Merged:'|| V_SCAN_INFO.RMT_ROWS_MERGED);
DBMS_OUTPUT.PUT_LINE('Local Rows Deleted:' || V_SCAN_INFO.LOC_ROWS_DELETED);
DBMS_OUTPUT.PUT_LINE('Remote Rows Deleted:' || V_SCAN_INFO.RMT_ROWS_DELETED);
end;
Merged rows in t his cont ext mean t hey were replaced. The opt ion CMP_CONVERGE_LOCAL_WINS indicat es t hat t he
column values at t he local dat abase replace t he column values at t he remot e dat abase when t hese column
values are dif f erent . This const ant can be specif ied as 'LOCAL'.

Not e To run t he COMPARE f unct ion or CONVERGE procedure, t he f oll owing users must have SELECT privilege
on each copy of t he shared dat abase obj ect :
o The compari son owner at t he local dat abase.
o When a dat abase link is used, t he user at t he remot e dat abase t o which t he comparison
owner connect s t hrough a dat abase link.
The CONVERGE procedure also requires addit ional privileges f or one of t hese users at t he dat abase
where it makes changes t o t he shared dat abase obj ect . The user must have INSERT, UPDATE, and
DELETE privileges on t he shared dat abase obj ect at t his dat abase.

SQL* Pl us New Feat ur es
SQL* Pl u s Er r or Loggi n g
I n Oracle 11g SQL* Plus, t he new command SET ERRORLOGGIN can be used t o st ore all errors result ing f rom
execut ed SQL, PL/ SQL and SQL* Plus commands in special error logging t able ( by def ault it is SPERRORLOG) .
Following are t he commands t o enable and disable error logging in SQL* Plus:
SQL>SHOW ERRORLOGGING
SQL>SET ERRORLOGGIN ON
SQL>SET ERRORLOGGIN OFF
Page 42 Oracle 11g New Features for Administrators - Summary Sheets

The SET ERRORLOGGIN ON command creat es t he error log t able. To view t he error st ored in t he t able, use a
query like t he f ollowing:
SELECT USERNAME, STATEMENT, MESSAGE
FROM SPERRORLOG;
New SQL* Pl u s Con n ect i on Syn t ax
The CONNECT command in Oracle 11g SQL* Plus is enhanced t o allow connect ing as ASM administ rat or.
CONN[ECT] [{logon | / } [AS {SYSOPER | SYSDBA | SYSASM}]]
Onl i ne Appl i cat i on Mai nt enance
En h an ced On l i n e I n dex Cr eat i on an d Rebu i l d
Bef ore Oracle 11g, rebuilding an index online on a t able wit h ext ensive DML leads t o unpredict able result s
because t able exclusive lock ( X) is required by rebuilding process. I n Oracle 11g, rebuilding an index acquire
shared exclusive lock ( SX) on t he t able allowing DML t o go on unint errupt ed. This new enhancement applies in
t he f ollowing st at ement s:
o Creat e index online
o Rebuild index online
o Creat e mat erialized view log
En h an ced ADD COLUMN Fu n ct i on al i t y
Bef ore Oracle 11g, adding new columns wit h DEFAULT values and NOT NULL const raint requires an exclusive lock
on t he t able and t he def ault value t o be st ored in all exist ing records. I n Oracle 11g, t he def ault value will be
st ored in t he dat a dict ionary inst ead of t he t able it self . This will save space ( f or large t ables) and signif icant ly
reduce t ime t o execut e t he modif icat ion st at ement .
Fi n er Gr ai n ed Depen den ci es
I nvalidat ion of dependent obj ect s result ed f rom modif ying st ruct ure of t he independent obj ect is def used in
Oracle 11g. For example, if a view or a PL/ SQL procedure ref erences a t able and you added a column t o t he
t able, t he view and t he procedure are not invalidat ed. However, if you modif y a column in t he t able and t hat
column is ref erenced by t he view or t he procedure, t hey will be invalidat ed.
Or acl e Adv anced Compr essi on Opt i on
Oracle Dat abase 11g has new opt ion named as Oracle Advanced Table Compression opt ion which aims at
reducing space occupied by dat a f or bot h OLTP and warehouse dat abases. This opt ion provides t he f ollowing
t ypes of compression:
o Compression of dat a t ables even f or OLTP environment . ( Previous versions had compression opt ion f or
t ables t hat are most ly read only) .
o Compression of unst ruct ured dat a in SecureFiles.
o Compression of RMAN backups.
o Compression in Dat a Pump Export f iles.
o Compression of redo dat a t ransmit t ed t o a st andby dat abase during redo gap resolut ion ( when dat a guard is
conf igured) .

Not e Using Advanced Compression Opt ion in Oracle 11g requires a separat e license f rom Oracle.
Page 43 Oracle 11g New Features for Administrators - Summary Sheets

Tabl e Compr essi on
Table compression has t he advant ages of saving st orage space, increased I / O perf ormance and reduct ion in
buf f er cache memory. On t he ot her hand, it incurs a CPU overhead.
The compression can be specif ied at t he t ablespace, t able or part it ion level wit h t he f ollowing opt ions:
o NOCOMPRESS - The t able or part it ion is not compressed. Thi s i s t he def ault .
o COMPRESS - This opt ion is considered suit able f or dat a warehouse syst ems. Compression is enabled on t he
t able or part it ion during direct - pat h insert s only.
o COMPRESS FOR DIRECT_LOAD OPERATIONS - This opt ion has t he same af f ect as t he simple COMPRESS keyword
( as wit h Oracle 10g) .
o COMPRESS FOR ALL OPERATIONS - This opt ion is considered suit able f or OLTP syst ems. As t he name implies,
t his opt ion enables compressi on f or all operat ions, including regular DML st at ement s. This opt i on requires
t he COMPATIBLE init ializat i on paramet er t o be set t o 11. 1. 0 or higher.
Following are examples t o use t he COMPRESS clauses:
CREATE TABLE ... COMPRESS FOR ALL OPERATIONS;

CREATE TABLE mytab ( .. created_date DATE NOT NULL )
PARTITION BY RANGE (created_date) (
PARTITION mytab_q1 VALUES LESS THAN (to_date('01/01/2008', 'DD/MM/YYYY')) COMPRESS,
PARTITION mytab_q2 VALUES LESS THAN (to_date('01/04/2008', 'DD/MM/YYYY')) COMPRESS FOR
DIRECT_LOAD OPERATIONS,
PARTITION mytab_q3 VALUES LESS THAN (to_date('01/07/2008', 'DD/MM/YYYY')) COMPRESS FOR
ALL

CREATE TABLESPACE mytbs ..
DEFAULT COMPRESS FOR ALL OPERATIONS;
The t able compression has t he f ollowing rest rict ions:
o You can add or drop columns t o a compressed t able, only if t he COMPRESS FOR ALL OPERATIONS opt ion was
used.
o Compressed t ables cannot have more t han 255 columns.
o Compression is not applied t o LOB segment s.
o The compression clause cannot be applied t o hash or hash- li st part it ions. I nst ead, t hey must inherit t heir
compression set t ings f rom t he t ablespace, t able or part it ion set t ings.
o Table compression cannot be specif ied f or ext ernal, clust ered or index organized t ables.
Compr essi on i n Secu r eFi l es
The Oracle SecureFiles f eat ure is an alt ernat ive solut ion t o LOB t o st ore unst ruct ured dat a such as XML f iles,
dat asheet s and word processor document s. Wit h t his f eat ure, compression is implement ed by eliminat ing
redundant copies of t he same document . I n t his case, all t he copies will point t o t he same document image.
For f urt her det ails about SecureFiles, see t he sect ion SecureFiles.
Compr essi on i n RMAN Back u ps
The Oracle Advanced Compression opt ion reduces t he compression rat io in RMAN backup ( by 20%) and
increases t he backup perf ormance ( by 40%) t han it does in Oracle 10g.
Compr essi on i n Dat a Pu mp Ex por t Fi l es
I n Oracle 11g, you can compress t he export dat a f iles in a Dat a Pump export j ob ( in Oracle 10g, only met adat a
can be compressed) . For f urt her det ails about using t he compression in Dat a Pump export f iles, see t he sect ion
Compression Enhancement in Dat a Pump.
Compr essi on of Tr an smi t t ed Redo Dat a
Wit h t he Oracle Advanced Compression opt ion, dat a t ransmit t ed during redo gab resolut ion when Oracle guard is
implement ed is compressed. This result s in increasing t he t hroughput of t he process and f inishing it in a short er
t ime ( about t wo t imes f ast er) .
Or acl e Schedul er New Feat ur es
Light weight Jobs and Remot e Ext ernal Jobs are t wo enhancement s included in t he scheduler. Those
enhancement s are discussed in t he f ollowing sect ions.
Page 44 Oracle 11g New Features for Administrators - Summary Sheets

Li ght w ei ght Jobs
I n Oracle 11g, Schedule j obs are divided int o t wo t ypes: regular and light weight j obs. Regular j obs are creat ed
and dropped af t er each execut ion. They do not cause re- creat ing overhead and are f ast er t o creat e. Use
light weight j obs when you need t o creat e and drop hundreds or t housands of j obs per second.
Light weight j obs must be based on j ob t emplat es. A j ob t emplat e is a dat abase obj ect t hat provides t he
necessary met adat a needed f or running a j ob ( ot her t han a schedule) and provides a privilege inf rast ruct ure t hat
can be inherit ed by any light weight j ob. Typically, a j ob t emplat e is a program obj ect wit h an obj ect t ype of
' PLSQL_BLOCK' or ' STORED_PROCEDURE' .
The f ollowing example creat es a light weight j ob usi ng a program as a t emplat e:
DBMS_SCHEDULER.CREATE_JOB (
JOB_NAME =>'Light_Job1',
PROGRAM_NAME =>'My_Prog', -- an existing scheduler program object
REPEAT_INTERVAL =>'freq=daily;by_hour=9',
ENABLED =>FALSE, -- default
AUTO_DROP =>TRUE, -- default
COMMENTS =>'Lightweight Job',
JOB_STYLE => 'LIGHTWEIGHT'); -- or REGULAR
The f ollowing example creat es a set of light weight j obs in one t ransact ion:
declare
NEWJOB SYS.JOB;
NEWJOBARR SYS.JOB_ARRAY;
begin
NEWJOBARR := SYS.JOB_ARRAY();
NEWJOBARR.EXTEND(5);
FOR I IN 1..5 LOOP
NEWJOB := SYS.JOB(JOB_NAME => 'LWJOB_' || TO_CHAR(I),
JOB_STYLE => 'LIGHTWEIGHT',
JOB_TEMPLATE => 'My_Prog', -- not PROGRAM_NAME
REPEAT_INTERVAL => 'FREQ=MINUTELY;INTERVAL=15',
START_DATE => SYSTIMESTAMP + INTERVAL '10' SECOND,
ENABLED => TRUE );
NEWJOBARR(I) := NEWJOB;
END LOOP;
-- create multiple jobs in a single call
DBMS_SCHEDULER.CREATE_JOBS(NEWJOBARR, 'TRANSACTIONAL');
end;

Remot e Ex t er nal Jobs
Con f i gu r i n g Remot e Ex t er n al Jobs Fu n ct i on al i t y
I n Oracle 11g, you can creat e in scheduler an ext ernal j ob t hat runs on a remot e host . This t ype of j ob is called
remot e ext ernal j ob.
To be able t o creat e a remot e ext ernal j ob, t he f ollowing condit ions apply:
o Oracle Scheduler agent ( not t he dat abase) should be inst alled on t he remot e host .
o Regist er t he scheduler agent wit h t he dat abase t hat needs t o run ext ernal j obs in t he remot e host .
To inst all t he scheduler agent , perf orm t he f ollowing st eps:
1. Run t he Oracle Universal I nst aller f rom t he Oracle Dat abase Gat eway sof t ware.
2. Select t he Oracle Scheduler Agent as t he sof t ware t o inst all.
3. Specif y t he host name and port number.
4. Af t er inst allat ion is f inished, run root.sh as a root user.
To regist er a dat abase in t he scheduler agent , perf orm t he f ollowing st eps:
1. I n t he dat abase you want t o regist er, issue t he f ollowing command as a SYS user:
SQL>@ ORACLE_HOME/rdbms/admin/prvtrsch.plb
Page 45 Oracle 11g New Features for Administrators - Summary Sheets

2. Set a regist rat ion password f or t he scheduler agent using t he f ollowing command:
exec DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('mypassword');
3. Regist er t he scheduler agent wit h t he dat abase using t he f ollowing command:
$schagent –registerdatabase database_host database_xmldb_http_port
To f ind out t he value of t he ht t p port , issue t he f ollowing command:
SQL>select dbms_xdb.gethttpport from dual;
4. St art t he scheduler agent wit h t he f ollowing command:
$schagent –start
5. The scheduler agent can be st opped wit h t he f ollowing command:
$schagent –stop
Cr eat i n g a Remot e Ex t er n al Job
To creat e a remot e ext ernal j ob, t he f ollowing st eps should be carried out :
1. Creat e a credent ial f or running t he remot e ext ernal j ob using t he f ollowing command:
exec DBMS_SCHEDULER.CREATE_CREDENTIAL('HostNameCredential', 'OSusername','mypassword');
I nf ormat ion about t he credent ials in t he dat abase can be obt ained by querying t he view
DBA_SCHEDULER_CREDENTIALS.
2. Grant t he obj ect privilege EXECUTE on t he creat ed credent ial t o t he required dat abase user:
GRANT EXECUTE ON HostNameCredential TO scott;
3. Use t he f ollowing code t o creat e t he ext ernal j ob:
begin
-- create the job
DBMS_SCHEDULER.CREATE_JOB(
JOB_NAME => 'EXT_JOB1',
JOB_TYPE => 'EXECUTABLE',
JOB_ACTION => '/u01/app/oracle/sendfiles',
REPEAT_INTERVAL =>'freq=daily;by_hour=9',
ENABLED =>FALSE);
-- define its credential
DBMS_SCHEDULER.SET_ATTRIBUTE (
NAME =>'EXT_JOB1',
ATTRIBUTE =>'CREDENTIAL_NAME',
VALUE =>'HostNameCredential' );
-- define its destination
DBMS_SCHEDULER.SET_ATTRIBUTE (
NAME =>'EXT_JOB1',
ATTRIBUTE =>'DESTINATION',
VALUE =>'rhostname:12345' ); -- hostname and port number listened to by the agent
-- enable the job
DBMS_SCHEDULER.ENABLE ('EXT_JOB1');
end;
To know t he port number t he scheduler agent is list ening t o, view t he f ile schagent.conf in t he scheduler agent
home direct ory.
Moni t or i ng Job St at e w i t h Emai l Not i f i cat i ons
You can conf igure a j ob t o send e- mail not if icat ions when it changes st at e.
/* Configuration */
CONN / AS SYSDBA
BEGIN
-- define the SMTP server
DBMS_SCHEDULER.set_scheduler_attribute('email_server', 'smtp.mydomain.com:25');
Page 46 Oracle 11g New Features for Administrators - Summary Sheets


-- optionally define default sender address, which
-- is used if the sender parameter is not specified
DBMS_SCHEDULER.set_scheduler_attribute('email_sender', 'info@mydomain.com');
END;
/


-- to enable/disable encryption is for the SMTP server connection
-- only (11.2.0.2)
-- possible values: NONE, SSL_TLS, STARTTLS
exec DBMS_SCHEDULER.set_scheduler_attribute('email_server_encryption','SSL_TLS')


-- Authentication
-- If the SMTP server requires authentication, then the Scheduler uses the
-- user name and password stored in the specified credential object
-- default NULL
exec dbms_scheduler.create_credential('hrcredential','hr','hrpassword');
exec DBMS_SCHEDULER.set_scheduler_attribute('email_server_credential','hrcredential')



/* Using Email Notification */
-- You call ADD_JOB_EMAIL_NOTIFICATION once for each different set of notifications
-- that you want to configure for a job.

-- associate an email notification with the job
-- using the default subject and body
BEGIN
DBMS_SCHEDULER.add_job_email_notification (
job_name => 'email_notification_job',
recipients => 'info@ahmedbaraka.com',
events => 'job_started, job_succeeded');
END;

-- subject and body specified:
BEGIN
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => 'email_notification_job',
recipients => 'info@ahmedbaraka.com, alissa@mydomain.com',
sender => 'do_not_reply@example.com',
subject => 'Scheduler Job Notification-%job_owner%.%job_name%-%event_type%',
body => '%event_type% occurred at %event_timestamp%. %error_message%',
events => 'JOB_FAILED, JOB_BROKEN, JOB_DISABLED, JOB_SCH_LIM_REACHED');
END;


-- configures an additional e-mail notification for the same job
-- for a different event
BEGIN
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => 'email_notification_job',
recipients => 'info@ahmedbaraka.com',
events => 'JOB_OVER_MAX_DUR');
END;


-- The notification fires only if a job fails with "600" "700" error codes
BEGIN
DBMS_SCHEDULER.add_job_email_notification (
job_name => 'email_notification_job',
recipients => 'info@ahmedbaraka.com',
events => 'job_failed',
filter_condition => ':event.error_code=600 or :event.error_code=700');
END;



/* Removing Email Notification */
Page 47 Oracle 11g New Features for Administrators - Summary Sheets

-- remove the notification from specified recipient/event
BEGIN
DBMS_SCHEDULER.remove_job_email_notification (
job_name => 'email_notification_job',
recipients => 'info@ahmedbaraka.com',
events => 'job_succeeded');
END;

-- remove the notification from all recipients and events
BEGIN
DBMS_SCHEDULER.remove_job_email_notification (
job_name => 'email_notification_job');
END;



/* Obtain Info about Email Notifications */
SELECT job_name, recipient, event, filter_condition, subject, body
FROM user_scheduler_notifications;

Fi l e Wat cher
A f ile wat cher is a new scheduler obj ect t hat enables a new t ype of even- based j ob t hat is t riggered by t he
arrival of a f ile in a specif ied locat ion. File wat chers can be def ined t o monit or locat ions on t he local server and
remot e servers, provided t hey have an agent inst alled on t hem.
/* Obtain Info about FW */
SELECT file_watcher_name, destination, directory_path, file_name, credential_name
FROM user_scheduler_file_watchers;



/* Configuration */
-- by default, a destination is checked every 10 mins. To change this:
CONN / AS SYSDBA
set serveroutput on
declare
v varchar2(1000);
begin
DBMS_SCHEDULER.GET_ATTRIBUTE ( 'FILE_WATCHER_SCHEDULE','REPEAT_INTERVAL', v);
DBMS_OUTPUT.PUT_LINE(V);
end;
/

BEGIN
DBMS_SCHEDULER.set_attribute(
'file_watcher_schedule',
'repeat_interval',
'freq=minutely; interval=5');
END;
/




/* Creating File Watcher */
-- create OS credential:
BEGIN
DBMS_SCHEDULER.create_credential(
credential_name => 'fw_credential',
username => 'oracle',
password => 'oracle');
END;
/


-- Grant EXECUTE on the credential to the schema that owns the
-- event-based job that the file watcher will start:
Page 48 Oracle 11g New Features for Administrators - Summary Sheets

GRANT EXECUTE ON fw_credential to DSSUSER;


-- create file watcher:
BEGIN
DBMS_SCHEDULER.create_file_watcher(
file_watcher_name => 'data_fw',
directory_path => '/tmp/test', -- if '?' = ORACLE_HOME
file_name => '*.dat', -- wildcard supported
credential_name => 'fw_credential',
destination => NULL, -- NULL=local server
enabled => FALSE);
END;
/


-- Grant EXECUTE on the file watcher to any schema that owns an event-based job
-- that references the file watcher.
GRANT EXECUTE ON data_fw to DSSUSER;


-- create a program raised by the file watcher
BEGIN
DBMS_SCHEDULER.create_program(
program_name => 'import_data_prog',
program_type => 'stored_procedure',
program_action => 'import_data_proc',
number_of_arguments => 1,
enabled => FALSE);
END;
/


-- define the metadata argument using the event_message attribute
-- the metadata contains info about the file, such as its name:
BEGIN
DBMS_SCHEDULER.define_metadata_argument(
program_name => 'import_data_prog',
metadata_attribute => 'event_message',
argument_position => 1);
END;
/


-- create the defined procedure:
-- It must accept an argument of the SCHEDULER_FILEWATCHER_RESULT type
CREATE TABLE received_files ( fileinfo VARCHAR2(4000), rdate date );

CREATE OR REPLACE PROCEDURE import_data_proc
(p_sfwr SYS.SCHEDULER_FILEWATCHER_RESULT) AS
v_message received_files.fileinfo%type;
BEGIN
v_message := p_sfwr.directory_path || '/' || p_sfwr.actual_file_name || ' (' ||
p_sfwr.file_size || ')';

INSERT INTO received_files
VALUES (v_message, sysdate);
COMMIT;
END;
/



-- create the job:
BEGIN
DBMS_SCHEDULER.create_job(
job_name => 'import_data_job',
program_name => 'import_data_prog',
event_condition => NULL, -- 'tab.user_data.file_size < 1024'
queue_spec => 'data_fw', -- file watcher name
Page 49 Oracle 11g New Features for Administrators - Summary Sheets

auto_drop => FALSE,
enabled => FALSE);
END;
/



-- By default, the arrival of new files will be ignored if the job is already running.
-- If you need the job to fire for each new arrival, regardless of whether the job is
already
-- running or not, set the PARALLEL_INSTANCES attribute for the job to true. The job
-- will then be run as a lightweight job:
BEGIN
DBMS_SCHEDULER.set_attribute('import_data_job','parallel_instances',TRUE);
END;
/



-- Enable all the objects:
EXEC DBMS_SCHEDULER.enable('data_fw,import_data_prog,import_data_job');


-- to test:
echo "This is a test" > /tmp/test/f1.dat
echo "This is a test too" > /tmp/test/f2.dat
echo "Yes another test" > /tmp/test/f3.dat

select * from received_files order by rdate desc;



/* Managing File Watchers */
-- enable/disable
EXEC DBMS_SCHEDULER.enable('data_fw') ;
EXEC DBMS_SCHEDULER.disable('data_fw') ;


-- change an attribute:
begin
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => 'data_fw',
attribute =>'directory_path',
value =>'/home/oracle/receivedfiles' ) ;
end;
/

begin
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => 'data_fw',
attribute =>'file_name',
value =>'*.txt' ) ;
end;
/

begin
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => 'data_fw',
attribute =>'credential_name',
value =>'fw_credential2' ) ;
end;
/


-- to drop a file watchers:
DBMS_SCHEDULER.DROP_FILE_WATCHER('data_fw');

Page 50 Oracle 11g New Features for Administrators - Summary Sheets

Fi ner - gr ai ned Dependency Management
I nvalidat ion of dependent schema obj ect s in response t o changes in t he obj ect s t hey depend upon is great ly
reduced in Oracle Dat abase 11g.
I f a single- t able view select s only a subset of columns in a t able, only t hose columns are involved in t he
dependency. For each dependent of an obj ect , if a change is made t o t he def init ion of any element involved in
t he dependency ( including dropping t he element ) , t he dependent obj ect is invalidat ed. Conversely, if changes
are made only t o def init ions of element s t hat are not involved in t he dependency, t he dependent obj ect remains
valid.
However, f or t riggers, t hey will be invalidat ed f or a redef ined t able, even if it is not af f ect ed by t he t able
modif icat ion. For mat erialized views t hat depend on t he modif ied t able, you should perf orm a complet e ref resh
on t hem.
Enhancement s i n Or acl e Dat abase Resour ce Manager
Per - Sessi on I / O Li mi t s
I n Oracle 11g, you can conf igure t he Dat abase Resource Manager so t hat sessions t hat exceed I / O resource
consumpt ion limi t s can be aut omat i cally swit ched t o anot her consumer group.
The f ollowing example creat es a resource plan direct ive f or t he OLTP group t hat t emporarily swit ches any session
in t hat group t o t he LOW_GROUP consumer group, if t he session exceeds 10, 000 I / O request s or exceeds 2, 500
Megabyt es of dat a t ransf erred.
begin
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (
PLAN => 'DAYTIME',
GROUP_OR_SUBPLAN => 'OLTP',
COMMENT => 'Auto Conditional Switch from OLTP group to Low_Group',
MGMT_P1 => 75, -- resource allocation value for level 1 (replaces CPU_P1)
SWITCH_GROUP => 'LOW_GROUP',
SWITCH_IO_REQS => 10000, SWITCH_IO_MEGABYTES => 2500,
SWITCH_FOR_CALL => TRUE);
end;

I / O Cal i b r at i on
The DBMS_RESOURCE_MANAGER package has a new procedure named as CALIBRATE_IO which assess t he I / O
perf ormance of t he dat abase server st orage syst em by perf orming an I / O int ensive read- only workload. This
should only be run during of f - peak t imes when t here is no workload on t he dat abase.
To successf ully run t he procedure, it requires t he I / O asynchronous disabled; ot herwise ORA- 56708 is raised.
Asynchronous I / O is enabled by set t ing t he FILESYSTEMIO_OPTIONS paramet er t o ASYNC or SETALL.
show parameter FILESYSTEMIO_OPTIONS
alter system set FILESYSTEMIO_OPTIONS=SETALL SCOPE=SPFILE;
shutdown immediate
startup
The CALIBRATE_IO procedure accept s t wo paramet ers t o specif y t he number of physical disks ( def ault 1) and t he
maximum t olerable lat ency ( def ault 20ms) . On complet ion, it ret urns t he maximum I / O request s per second, t he
maximum MB per second and t he act ual lat ency. To calculat e t he lat ency t ime, t he procedure requires
TIMED_STATISTICS paramet er is set t o TRUE.
SET SERVEROUTPUT ON
declare
l_max_iops PLS_INTEGER;
l_max_mbps PLS_INTEGER;
l_actual_latency PLS_INTEGER;
begin
DBMS_RESOURCE_MANAGER.calibrate_io ( num_physical_disks => 1,
max_latency => 20,
max_iops => l_max_iops,
max_mbps => l_max_mbps,
actual_latency => l_actual_latency);
DBMS_OUTPUT.put_line ('Max IO ps = ' || l_max_iops);
DBMS_OUTPUT.put_line ('Max MB ps = ' || l_max_mbps);
DBMS_OUTPUT.put_line ('Actual Latency = ' || l_actual_latency);
end;
Page 51 Oracle 11g New Features for Administrators - Summary Sheets

I nf ormat ion about calibrat ion runs can be obt ained f rom t he DBA_RSRC_IO_CALIBRATE view:
select * from DBA_RSRC_IO_CALIBRATE;
Ou t - Of - Th e- Box Mi x ed Wor k l oad Resou r ce Pl an
Oracle Dat abase includes a predef ined resource plan, MIXED_WORKLOAD_PLAN, t hat priorit izes int eract ive
operat ions over bat ch operat ions, and includes t he required subplans and consumer groups recommended by
Oracle. You can use t his predef ined plan, if it is appropriat e f or your environment .
The plan is def ined as f ollows:
CPU Resou r ce Al l ocat i on
Gr ou p or Su bpl an Lev el 1 Lev el 2 Lev el 3 Au t omat i c Con su mer Gr ou p
Sw i t ch i n g
Max Degr ee of
Par al l el i sm
BATCH_GROUP 100%
INTERACTIVE_GROUP 85% swit ch t o group: BATCH_GROUP
swit ch t i me: 60 seconds
swit ch f or cal l: TRUE
1
ORA$AUTOTASK_SUB_PLAN 5%
ORA$DIAGNOSTICS 5%
OTHER_GROUPS 5%
SYS_GROUP 100%

I n t his plan, because INTERACTIVE_GROUP is int ended f or short t ransact ions, any call t hat last s longer t han 60
seconds is aut omat ically swit ched t o BATCH_GROUP, which is int ended f or longer bat ch operat ions.
New Resou r ce Man ager Per f o r man ce vi ew s
Following are t he new dynamic perf ormance views in Oracle 11g t o monit or t he result s of t he Resource Manager
set t ings:
V$RSRC_PLAN
displays t he names of all current ly act ive resour ce plans.
V$RSRC_CONSUMER_GROUP
displays dat a relat ed t o current ly act ive resource consumer groups such as t he
cumulat ive amount of CPU t ime consumed, cumulat ive amount of t ime wait ing
f or CPU, and cumulat ive number of CPU wait s by all sessions in each consumer
group.
V$RSRC_SESSION_INFO
displays Resource Manager st at i st ics per session.
V$RSRC_PLAN_HISTORY
displays a hist ory of when a resource plan was enabled, disabled, or modif ied on
t he inst ance.
V$RSRC_CONS_GROUP_HIST
ORY
displays a hist ory of consumer group st at ist ics f or each ent r y in
V$RSRC_PLAN_HISTORY t hat has a non- NULL plan.

Max i mu m CPU Ut i l i zat i on Li m i t
Use t he MAX_UTILIZATION_LIMIT at t ribut e t o impose an absolut e upper limit on CPU ut ilizat ion f or a resource
consumer group. This absolut e limit overrides any redist ribut ion of CPU wit hin a plan.
You can also use t he MAX_UTILIZATION_LIMIT at t ribut e as t he sole means of limit ing CPU ut ilizat ion f or
consumer groups, wit hout specif ying level limit s.
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (
PLAN => 'APPS_PLAN',
GROUP_OR_SUBPLAN => 'APP1_GROUP',
COMMENT => 'Limit CPU for application #1 to 40%',
MAX_UTILIZATION_LIMIT => 40);


Enhanced TRUNCATE St at ement
DROP ALL STORAGE is a new opt ion added t o TRUNCATE st at ement in Oracle 11g R2. I t drops t he whole
segment . I n addit ion t o t he TRUNCATE TABLE st at ement , DROP ALL STORAGE also applies t o t he ALTER TABLE
TRUNCATE ( SUB) PARTI TI ON st at ement .
TRUNCATE TABLE emp DROP ALL STORAGE;
Page 52 Oracle 11g New Features for Administrators - Summary Sheets


Dr oppi ng Unused Obj ect St or age
I n Oracle Dat abase 11g release 2 ( 11. 2. 0. 2) , t he DBMS_SPACE_ADMI N. DROP_EMPTY_SEGMENTS procedure
enables you t o drop segment s f or empt y t ables and part it ions t hat have been migrat ed f rom previous releases.
-- to drop empty segments from every table in the database:
BEGIN
DBMS_SPACE_ADMIN.DROP_EMPTY_SEGMENTS();
END;

-- to drop empty segments from the HR.EMPLOYEES table
-- including dependent objects
BEGIN
DBMS_SPACE_ADMIN.DROP_EMPTY_SEGMENTS(
schema_name => 'HR',
table_name => 'EMPLOYEES');
END;




Page 53 Oracle 11g New Features for Administrators - Summary Sheets

Per f or mance Tuni ng
PL/ SQL Nat i v e Compi l at i on

PL/ SQL Nat ive Compilat ion was int roduced in Oracle 9i. I n Oracle 11g, The PL/ SQL compiler may now generat e
processor- specif ic nat ive code direct ly f rom t he PL/ SQL source code wit hout needing t o use a t hird- part y C
compiler and, as in Oracle 10g, st ores t he code in t he dat abase cat alog. When a unit is needed, t he Oracle
execut able loads t he code direct ly f rom t he cat alog int o memory, wit hout f irst st aging t he unit t hrough a . DLL or
. so f ile. This leads t o t he f ollowing advant ages:
• No t hird- part y C compiler.
• Fast er in compilat ion ( Oracle claims by t wo- and- a- half t imes) .
• Fast er in execut ion ( by 20 t imes) .
Not e Not e t hat t his f eat ure may not be available on all plat f orms in t he f irst release of Oracle 11g.
Con f i gu r i n g t h e Dat abase or Sessi on t o Au t omat i c PL/ SQL Nat i ve Compi l at i on
The new dynamic paramet er PLSQL_CODE_TYPE is used t o make any newly compiled PL/ SQL program unit use
nat ive PL/ SQL compilat ion. The paramet er t akes on of t wo values:
INTERPRETED
PL/ SQL program unit s will be compiled int o PL/ SQL byt ecode f ormat and t he PL/ SQL
int erpret er engine will execut e t hem.
COMPILED
PL/ SQL program unit s will be compiled t o machine code and execut ed nat ively.
The paramet er can be modif ied in t he syst em or session level. I t will af f ect t he newly compiled program unit s.
Usi n g PL/ SQL Nat i ve Compi l at i on i n t h e Pr ogr am Un i t Level
You can recompile a program unit in t he nat ive mode using t he ALTER .. COMPILE command as illust rat ed in t he
f ollowing example:
select PLSQL_CODE_TYPE from ALL_PLSQL_OBJECT_SETTINGS where name='MY_PROC';
ALTER PROCEDURE MY_PROC COMPILE PLSQL_CODE_TYPE=NATIVE;
Recompi l i n g Dat abase PL/ SQL Pr ogr am Un i t s Usi n g PL/ SQL Nat i ve Compi l at i on
To recompile all program unit s in a dat abase using t he nat ive PL/ SQL compilat ion and make t he nat ive
compilat ion as t he def ault , perf orm t he f ollowing st eps:
1. Set t he paramet er PLSQL_CODE_TYPE as f ollows:
ALTER SYSTEM SET PLSQL_CODE_TYPE=NATIVE SCOPE=SPFILE;
2. Make sure t he PLSQL_OPTIMIZER_LEVEL paramet er value is at least 2.
SHOW PARAMETER PLSQL_OPTIMIZER_LEVEL
ALTER SYSTEM SET PLSQL_OPTIMIZER_LEVEL=2 SCOPE=SPFILE;
3. Cleanly shut down t he dat abase
4. St art t he dat abase in upgrade mode.
5. Execut e t he f ollowing script will recompile all exist ing PL/ SQL unit s using nat ive compilat ion:
@ORACLE_HOME/rdbms/admin/dbmsupgnv.sql
6. Rest art t he dat abase.

Not e I f you want t o recompile t he PL/ SQL program unit s back usi ng t he int erpret ed compilat ion, perf orm
t he same st eps above except set t ing t he PLSQL_CODE_TYPE paramet er t o INTERPRETED and replacing
t he scrip dbmsupgnv.sql wit h dbmsupin.sql.

Page 54 Oracle 11g New Features for Administrators - Summary Sheets

Ser ver Resul t Cache
I n Oracle 11g, t here is a new SGA component called result cache, which is used cache SQL query and PL/ SQL
f unct ion result s. The dat abase serves t he result s f or t he execut ed SQL queries and PL/ SQL f unct ions f rom t he
cache inst ead of re- execut ing t he act ual query. Of course, t he t arget is t o obt ain high response t ime. The cached
result s st ored become invalid when dat a in t he dependent dat abase obj ect s is modif ied.
As clear f rom it s concept , result cache is most ly usef ul in f or f requent ly execut ed queries wit h rare changes on
t he ret rieved dat a.
Resu l t Cach e Rest r i ct i on s
Following are some rest rict ions wit h regards t o t he SQL result cache:
• Queries against dat a dict ionary obj ect s and t emporary t ables are not support ed.
• Queries t hat use t he f ollowing SQL f unct ions: CURRENT_DATE, CURRENT_TIMESTAMP, LOCAL_TIMESTAMP,
USERENV/SYS_CONTEXT, SYS_GUID, SYSDATE and SYS_TIMESTAMP are not support ed.
• Queries wit h bind variables can reuse a cached result only f or ident ical variable values.
• Result s of t he queries ret rieving non current version of dat a are not cached in t he result cache.
• Result s of t he f lashback queries are not cached.
Rest rict ions on PL/ SQL Funct ion Result Cache include:
• The f unct ion cannot be def ined in a module using invoker’s right s.
• The f unct ion cannot be used in an anonymous block.
• The f unct ion cannot have any OUT or I N OUT paramet ers.
• The f unct ion cannot have I N paramet ers t hat are BLOB, CLOB, NCLOB, REF CURSOR, collect ions, obj ect s, or
records.
• The f unct ion cannot ret urn a BLOB, CLOB, NCLOB, REF CURSOR, OBJECTS, or records. I t can ret urn a
collect ion as long as t he collect ion does not cont ain one of t hese t ypes.
Con f i gu r i n g Resu l t Cach e
You can enable and disable result cache in t he dat abase server using t he paramet er RESULT_CACHE_MAX_SIZE.
This paramet er specif ies t he maximum amount of SGA memory ( in byt es) t hat can be used by t he Result Cache.
I f t he value of t his paramet er is 0, t hen t he f eat ure is disabled.
Memory allocat ed f or t he result cache is t aken f rom t he shared pool. The def ault value of
RESULT_CACHE_MAX_SIZE paramet er is derived f rom values of ot her paramet ers and as shown in t he f ollowing
t able:
Par amet er Def au l t Per cen t age of Sh ar ed Pool t o Resu l t Cach e
MEMORY_TARGET
0. 25%
SGA_TARGET
0. 5%
SHARED_POOL_SIZE
1%
Of course, you can increase value of t he RESULT_CACHE_MAX_SIZE paramet er but in all cases Oracle does not
allocat e more t han 75 percent of shared pool memory t o result cache.
ALTER SYSTEM SET RESULT_CACHE_MAX_SIZE =128M;

Not e RESULT_CACHE_MAX_SIZE cannot be dynamically changed if it s value is set t o 0 during dat abase
st art up.
Con t r ol l i n g Resu l t Cach e Beh avi or
The RESULT_CACHE_MODE init ializat ion paramet er det ermines t he SQL query result cache mode. The paramet er
specif ies when a ResultCache operat or is spliced int o a query' s execut ion plan. The paramet er accept s t he
f ollowing values:
MANUAL
The ResultCache operat or is added, only if you use t he RESULT_CACHE hint in t he SQL query.
FORCE
The ResultCache operat or is added t o t he root of all SELECT st at ement s, if t hat is possible.
However, if t he st at ement cont ains a NO_RESULT_CACHE hint , t hen t he hint t akes precedence over
t he paramet er set t ing.
The paramet er can be modif ied in t he syst em or session level.
ALTER SYSTEM SET RESULT_CACHE_MODE =FORCE;
ALTER SESSION SET RESULT_CACHE_MODE =FORCE;
Page 55 Oracle 11g New Features for Administrators - Summary Sheets

Following is an example of using t he RESULT_CACHE hint .
SELECT /*+ result_cache */
AVG(SALARY), E.DEPARTMENT_ID
FROM HR.EMPLOYEES E, HR.DEPARTMENTS D
WHERE E.DEPARTMENT_ID = D.DEPARTMENT_ID GROUP BY E.DEPARTMENT_ID;
The paramet er RESULT_CACHE_MAX_RESULT specif ies t he percent age of RESULT_CACHE_MAX_SIZE t hat any single
result can use. I t s def ault value is f ive.
ALTER SYSTEM SET RESULT_CACHE_MAX_RESULT =25;
The paramet er RESULT_CACHE_REMOTE_EXPIRATION specif ies t he number of minut es t hat a result using a remot e
obj ect is allowed t o remain valid. Set t ing t his paramet er t o 0 ( t he def ault ) implies t hat result s using remot e
obj ect s should not be cached. Set t ing t his paramet er t o a non- zero value can produce st ale answers.
PL/ SQL Fu n ct i on Resu l t Cach e
When PL/ SQL f unct ion result cache is enabled, Oracle will check t he result cache t o see if a previous call t o t he
f unct ion exist s ( using t he same paramet er passed values) and if so it will ret urn t he cached result inst ead of
execut ing t he f unct ion.
A PL/ SQL f unct ion can t ake advant age of t he PL/ SQL Funct ion Result Cache by adding t he RESULT_CACHE clause
t o t he f unct ion def init ion. I n t he opt ional RELIES_ON clause, specif y any t ables or views on which t he f unct ion
result s depend. Following is an example:
CREATE OR REPLACE FUNCTION get_name (id NUMBER) RETURN VARCHAR2
RESULT_CACHE RELIES_ON(emp) IS ...

-- Package specification
CREATE OR REPLACE PACKAGE department_pks IS
-- Function declaration
FUNCTION get_dept_info (dept_id NUMBER) RETURN dept_info_record RESULT_CACHE;
END department_pks;

CREATE OR REPLACE PACKAGE BODY department_pks AS
-- Function definition
FUNCTION get_dept_info (dept_id NUMBER) RETURN dept_info_record
RESULT_CACHE RELIES_ON (EMPLOYEES)
IS
BEGIN ...
I f t here is a dependent t able in a f unct ion and t hat t able was modif ied, t hen t he result cache will be invalidat ed
( cache miss) . I n t his case, t he f unct ion will be re- execut ed when called. The same will also occur if you re-
compile t he f unct ion.
Caut i on When a session reads f rom a PL/ SQL f unct ion result cache, t he f unct ion body is not execut ed. This
means, if t he f unct ion includes any I O or audit ing code, t his code will not act ually be execut ed.
PL/ SQL Cached f unct ions works across sessions. This means, if t he f unct ion is cached by a session, it s result
cache will also be used when execut ing t he same f unct ion and argument s by ot her sessions.
I f you need t o apply a hot pat ch PL/ SQL code in a running syst em t o a PL/ SQL module on which a result cached
f unct ion direct ly or t ransit ively depends, t hen t he cached result s associat ed wit h t he result cache f unct ion are not
aut omat ically f lushed. I n t his case, t he f ollowing st eps must be undert aken:
1. Place t he result cache in bypass mode, and f lush exist ing result . When bypass mode is t urned on, it implies
t hat cached result s are no longer used and t hat no new result s are saved in t he cache.
begin
DBMS_RESULT_CACHE.BYPASS(TRUE);
DBMS_RESULT_CACHE.FLUSH;
end;
2. Apply t he PL/ SQL code pat ches.
3. Resume use of t he result cache, by t urning of f t he cache bypass mode.
exec DBMS_RESULT_CACHE.BYPASS(FALSE);
Page 56 Oracle 11g New Features for Administrators - Summary Sheets

Mon i t or i n g Resu l t Cach e
I f you display t he explain plan f or any query wit h a RESULT_CACHE hint , you will not ice t he ResultCache
operat or. You can use t he CACHE_ID value provided in t he explain plan t o f ind det ails about t he cached query
result s using t he V$RESULT_CACHE_OBJECTS view, as shown in t he f ollowing example:
select NAME, STATUS, ROW_COUNT, BLOCK_COUNT, NAMESPACE,
to_char(CREATION_TIMESTAMP,'HH12:MI AM') CREATE_TIME
from V$RESULT_CACHE_OBJECTS
where CACHE_ID='ctpgzz1qb222tfqw61j203h01b';
Following are t he possible values f or t he STATUS column and t heir descript ions:
NEW Result is st il l under const r uct ion
PUBLISHED Result is available f or use
BYPASS Result will be bypassed f rom use
EXPIRED Result has exceeded expirat ion t ime
INVALID Result is no longer available f or use
V$RESULT_CACHE_STATISTICS view provides inf ormat ion and st at ist ics on cache set t ings and memory usage.
select ID, NAME, VALUE from V$RESULT_CACHE_STATISTICS
The NAME column possible values are as f ollows:
Block Size ( Byt es) size of each memory block
Block Count Maximum number of memory blocks allowed
Block Count Current Number of memory blocks current ly allocat ed
Result Size Maximum ( Blocks) Maximum number of blocks all owed f or a single result
Create Count Success Number of cache result s successf ully creat ed
Create Count Failure Number of cache result s t hat f ailed t o creat e
Find Count Number of cached result s t hat were successf ul ly f ound
Invalidation Count Tot al number of invalidat ions
Delete Count I nvalid Number of invalid cached result s delet ed
Delete Count Valid Number of valid cached result s delet ed
The V$RESULT_CACHE_MEMORY view displays all t he memory blocks and t heir st at us. Of course, number of rows in
t his view increases as t he result cache is enlarged by it s usage.
The V$RESULT_CACHE_DEPENDENCY view displays t he depends- on relat ionship bet ween t he cached result s obj ect s.
Mon i t or i n g an d Man agi n g Resu l t Cach e w i t h DBMS_RESULT_ CACHE
Beside t he dict ionary views, t he package DBMS_RESULT_CACHE can also be used t o monit or and manage result
cache usage. Below are some examples of using it :
-- check the status of the Result Cache
-- Note: this is the reliable method to know whether result cache is enabled or not
SQL>select DBMS_RESULT_CACHE.STATUS from dual;
-- display report on result cache memory
SQL>set serveroutput on
SQL>exec DBMS_RESULT_CACHE.MEMORY_REPORT
-- turn bypass mode on and off
SQL>exec DBMS_RESULT_CACHE.BYPASS (TRUE);
-- to flush the result cache
SQL>exec DBMS_RESULT_CACHE.FLUSH

Cl i ent Si de Resul t Cache
I n Oracle 11g, you can conf igure t he client process t o cache it s query result s in t he client memory ( or in t he
server) .
When dealing wit h t he client cache, consider t he f ollowing:
• To t ake advant age of client cache, you must use Oracle 11g client libraries and connect t o an Oracle 11g
dat abase.
• Client cache can be conf igured in a host t hat runs any applicat ion t hat uses Oracle Dat abase 11g OCI client
like: ODBC, ODB. NET, PHP, JDBC- OCI and Oracle precompil ers.
• Client cache is suit able f or f requent ly execut ed queries t o st at ic dat a.
Page 57 Oracle 11g New Features for Administrators - Summary Sheets

Ser ver Si de Con f i gu r at i on
To conf igure client cache in t he dat abase server, set t he f ollowing paramet ers:
CLIENT_RESULT_CACHE_
SIZE
This st at ic paramet er specif ies t he maximum size of t he client per- process result
set cache ( in byt es) . I t represent s t he combined size of caches in all client s. I f it is
set t o zero ( def ault ) , t he client cache is disabled.
CLIENT_RESULT_CACHE_
LAG
This st at ic paramet er specif ies t he maximum t ime ( in milliseconds) since t he last
round t rip t o t he server, bef ore which t he OCI client query execut e makes a round
t rip t o get any dat abase changes relat ed t o t he queries cached on t he client .
Cl i en t Si de Con f i gu r at i on
You can use an opt ional client conf igurat ion f ile ( or make t he set t ings part of t he sqlnet.ora f ile on t he client ) .
Client set t ings will override client cache set t ings in t he server. The f ollowing paramet ers can be set in t he client :
OCI_RESULT_CACHE_MAX
_SIZE
This paramet er specif ies t he maximum size of t he client per- process result set
cache ( in byt es) .
OCI_RESULT_CAHCE_MAX
_RSET_SIZE
This paramet er specif ies t he maximum size of a single query result in t he client
cache f or a process ( in byt es) .
OCI_RESULT_CAHCE_MAX
_RSET_ROWS
This paramet er specif ies t he maximum number of rows a single query result in t he
client cache f or a process.
Af t er implement ing t his conf igurat ion, simply t he SELECT st at ement passed by t he applicat ion t o Oracle server
should only use t he hint /*+ result_cache */. As a result , ret rieved rows are cached on t he client side saving
net work round t rips and t he server CPU overhead.
To see t he client s t hat used client cache, issue t he f ollowing queries:
select * from CLIENT_RESULT_CACHE_STAT$;
select * from V$CLIENT_RESULT_CACHE_STATS;
See Oracle Call I nt erf ace Programmer' s Guide document at ion f or more inf ormat ion about t he client query cache.

Enhanced Or acl e Pr ocess Moni t or i ng
Monit oring background processes is enhanced in Oracle 11g so t hat more det ailed st at ist ics can be obt ained
about t heir operat ions. The f ollowing columns are added in t he V$SYSTEM_EVENT view:
TOTAL_WAITS_FG
Tot al number of wait s t hat a f oreground/ background session wait ed f or t he event .
TOTAL_TIMEOUTS_FG
Tot al number of t imeout s f or an event t hat a f oreground/ background session
wait ed.
TIME_WAITED_FG
Amount of t ime t hat a f oreground/ background session wait ed f or t he event in
cent aseconds.
AVERAGE_WAIT_FG
Average wait t ime t hat a f oreground/ background process wait ed f or t he event in
cent aseconds.
TIME_WAITED_MICRO_FG
Tot al t ime in microseconds t hat a f oreground session spent wait ing on an event .
The f ollowing query is t o f ind all cumulat ive wait s of more t han one second t hat occurred on
f oreground/ background processes:
SELECT EVENT, TOTAL_WAITS_FG TWG, TOTAL_TIMEOUTS_FG TTF,
TIME_WAITED_FG TWF, AVERAGE_WAIT_FG AWF, TIME_WAITED_MICRO_FG TWMF
FROM V$SYSTEM_EVENT
WHERE TIME_WAITED_MICRO_FG > 1000000
AND WAIT_CLASS !='Idle';
The AWR- relat ed view DBA_HIST_SYSTEM_EVENT provides t he f ollowing similar new columns:
TOTAL_WAITS_FG
Tot al number of wait s f or an event , f rom a f oreground session.
TOTAL_TIMEOUTS_FG
Tot al number of t imeout s f or an event , f rom a f oreground session.
TIME_WAITED_MICRO_FG
Tot al t ime in microseconds t hat a f oreground session spent wait ing on an event .

Page 58 Oracle 11g New Features for Administrators - Summary Sheets

Subpr ogr am I nl i ni ng
Subprogram inlining, or I nt ra Unit I nli ning, is a new f eat ur e in Oracle 11g t hat when used appropriat ely which
result in higher PL/ SQL execut ion perf ormance. Det ail s about t his f eat ure are discussed in Subprogram I nlinin
sect ion.
g
SQL Tuni ng Aut omat i on
The SQL Tuni ng Advisor is run by def ault every night during t he aut omat ed maint enance window. Basically, t he
advisor cat ches t he SQL st at ement s f rom AWR t hat are candidat e f or t uning ( t hey are called bucket s) dur ing f our
dif f erent t ime periods. I t t hen aut omat i cally creat es SQL prof ile f or any poor SQL st at ement , if t hat helps. Tuned
plans are aut omat ically added t o t he SQL plan baselines by t he aut omat ic SQL t uning t ask.
I f you want t he Aut omat ic SQL Tuning process t o st op accept ing and implement ing t he recommended SQL
prof iles aut omat i cally, issue t he f ollowing code:
exec DBMS_SQLTUNE.SET_TUNING_TASK_PARAMETER(TASK_NAME => 'SYS_AUTO_SQL_TUNING_TASK',
PARAMETER=>'ACCEPT_SQL_PROFILES', VALUE=>' FALSE');
The advisor also may recommend act ions like creat ing new indexes, ref reshing st at ist ics or re- wr it ing t he
st at ement . These act ions, however, are not aut omat ically implement ed by t he advisor.
The best met hod t o Manage Aut omat ic SQL Tuning is by using OEM. Fol low t he li nks Home Pag e> Ser ver
page> Or acl e Sch edu l er sect i on > Au t omat i c Mai n t en an ce Task s l i n k > Au t omat i c SQL Tu n i n g l i n k >
Task st at u s sect i on > Con f i gu r e bu t t on .
DBMS_SQLTUNE package is t he PL/ SQL int erf ace t o invoke SQL Tuning Advisor. Examples of using t his package
can be f ound in t he sect ion "The SQL Perf ormance Analyzer" . Furt her det ails on using it can be obt ained f rom t he
document at ion "Oracle Dat abase Perf ormance Tuning Guide 11g Release 1 ( 11. 1) " page 17- 10.
On Oracle 11g Release 2 ( 11. 2. 0. 2) , a new package named as DBMS_AUTO_SQLTUNE should be used inst ead of
t he DBMS_SQLTUNE package. The new package provides more rest ri ct ive access t o t he Aut omat ic SQL Tuning
f eat ure.
To use t he DBMS_AUTO_SQLTUNE package, you must have t he DBA role, or have EXECUTE privileges grant ed by an
administ rat or. The only except ion is t he EXECUTE_AUTO_TUNING_TASK procedure, which can only be run by SYS.
exec DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER( parameter =>
'ACCEPT_SQL_PROFILES', value => 'TRUE');

-- To set the number of days until the task is deleted:
exec dbms_auto_sqltune.set_auto_tuning_task_parameter('DAYS_TO_EXPIRE', 90);
To manually execut e t he aut omat i c execut ion t ask :
Manually execute the automatic execution task :
-- Only SYS can call this API.
set serveroutput on

-- function format
set serveroutput on
DECLARE
retVal VARCHAR2(1000);
BEGIN
retVal := dbms_auto_sqltune.EXECUTE_AUTO_TUNING_TASK;
dbms_output.put_line(retVal);
END;
/

-- procedure format:
exec dbms_auto_sqltune.EXECUTE_AUTO_TUNING_TASK;
To view t he aut omat i c SQL t uning report :
VARIABLE my_rept CLOB;
BEGIN
:my_rept :=DBMS_AUTO_SQLTUNE.REPORT_AUTO_TUNING_TASK(
begin_exec => NULL, end_exec => NULL,
type => 'TEXT',
level => 'TYPICAL',
Page 59 Oracle 11g New Features for Administrators - Summary Sheets

section => 'ALL',
object_id => NULL,
result_limit => NULL);
END;
/
PRINT :my_rept

Not e There are some t yping errors in t he document at ion about t he f unct ion
DBMS_AUTO_SQLTUNE. REPORT_AUTO_TUNI NG_TASK. The t rue possible values f or t he paramet er
SECTI ON are: SUMMARY, FI NDI NGS, PLANS, I NFORMATI ON, ERRORS and ALL ( def ault ) .

SQL Access Adv i sor Enhancement s
SQL Access Advisor i s enhanced in Oracle 11g wit h t he f ollowing improvement s:
• The advisor can now recommend creat ing part it i ons on t ables, provided t hat t he st at ement has some
predicat es and j oins on t he columns of t he NUMBER or DATE dat a t ypes and t he t ables have at least
10, 000 rows. .
• Expect ed gain can be est imat ed by t he advisor.
• A t ask can be broken up i nt o part s called publish point s or int er mediat e result s. Those int ermediat e
result s can be checked while t he advisor is execut ing.
To access t he t ool in OEM, f ollow t he links Dat ab ase Ho me page> Ad vi sor Cen t r al > SQL Ad vi sor s> SQL
Access Ad vi so r
The f ollowing examples show t hree met hods f or invoking t he t ool in PL/ SQL using DBMS_ADVISOR package:
1. Creat ing a t ask linked t o a workload. When creat ing a workload, it s input could be SQL cache or a STS.
2. Creat ing a t ask linked t o a STS.
3. Quick t une f or a single SQL st at ement .
-- Method 1: to invoke SQL Access Advisor task linked to a workload
declare
l_taskname VARCHAR2(30) := 'sql_access_test_task';
l_task_desc VARCHAR2(128) := 'Test SQL Access';
l_wkld_name VARCHAR2(30) := 'test_work_load';
l_saved_rows NUMBER := 0;
l_failed_rows NUMBER := 0;
l_num_found NUMBER;
BEGIN
-- create an SQL Access Advisor task.
select COUNT(*)
into l_num_found
from DBA_ADVISOR_TASKS
where TASK_NAME = l_taskname ;
IF l_num_found = 0 THEN
DBMS_ADVISOR.CREATE_TASK (
ADVISOR_NAME => DBMS_ADVISOR.SQLACCESS_ADVISOR,
TASK_NAME => l_taskname,
TASK_DESC => l_task_desc);
END IF;

-- reset the task ( remove all recommendations, and intermediate data from the task)
DBMS_ADVISOR.RESET_TASK(TASK_NAME => l_taskname);

-- create a workload.
SELECT COUNT(*)
INTO l_num_found
FROM USER_ADVISOR_SQLW_SUM
WHERE WORKLOAD_NAME = l_wkld_name;

IF l_num_found = 0 THEN
DBMS_ADVISOR.CREATE_SQLWKLD(WORKLOAD_NAME => l_wkld_name);
END IF;

-- link the workload to the task
SELECT count(*)
Page 60 Oracle 11g New Features for Administrators - Summary Sheets

INTO l_num_found
FROM USER_ADVISOR_SQLA_WK_MAP
WHERE TASK_NAME = l_taskname
AND WORKLOAD_NAME = l_wkld_name;

IF l_num_found = 0 THEN
DBMS_ADVISOR.ADD_SQLWKLD_REF(
TASK_NAME => l_taskname,
WORKLOAD_NAME => l_wkld_name);
END IF;

-- Set workload parameters.
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'ACTION_LIST',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'MODULE_LIST',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'SQL_LIMIT',
DBMS_ADVISOR.ADVISOR_UNLIMITED);
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'ORDER_LIST',
'PRIORITY,OPTIMIZER_COST');
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'USERNAME_LIST',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name, 'VALID_TABLE_LIST',
DBMS_ADVISOR.ADVISOR_UNUSED);

-- unmark the required option
/*
-- import the current contents of the server's SQL cache
DBMS_ADVISOR.IMPORT_SQLWKLD_SQLCACHE(l_wkld_name, 'REPLACE', 2, l_saved_rows,
l_failed_rows);
-- load a SQL workload from an existing SQL Tuning Set
DBMS_ADVISOR.IMPORT_SQLWKLD_STS (l_wkld_name, 'SOURCE_STS_Name', 'REPLACE',2,
l_saved_rows, l_failed_rows);
*/
-- Set task parameters.
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, '_MARK_IMPLEMENTATION', 'FALSE');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'EXECUTION_TYPE', 'INDEX_ONLY');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'MODE', 'COMPREHENSIVE');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'STORAGE_CHANGE',
DBMS_ADVISOR.ADVISOR_UNLIMITED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DML_VOLATILITY', 'TRUE');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'ORDER_LIST', 'PRIORITY,OPTIMIZER_COST');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'WORKLOAD_SCOPE', 'PARTIAL');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_INDEX_TABLESPACE',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_INDEX_OWNER',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_MVIEW_TABLESPACE',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_MVIEW_OWNER',
DBMS_ADVISOR.ADVISOR_UNUSED);

-- Execute the task: control will not return till the execution finishes
DBMS_ADVISOR.execute_task(task_name => l_taskname);
END;
/


-- Method 2: to invoke SQL Access Advisor linked to a specific STS
declare
l_taskname VARCHAR2(30) := 'sql_access_test_task2';
l_task_desc VARCHAR2(128) := 'Test SQL Access for a STS';
l_wkld_name VARCHAR2(30) := 'test_work_load';
l_sts_name VARCHAR2(30) := 'test_sts';
l_saved_rows NUMBER := 0;
l_failed_rows NUMBER := 0;
l_num_found NUMBER;
BEGIN
-- create an SQL Access Advisor task, if it doesn’t exist
select COUNT(*)
into l_num_found
Page 61 Oracle 11g New Features for Administrators - Summary Sheets

from DBA_ADVISOR_TASKS
where TASK_NAME = l_taskname ;
IF l_num_found = 0 THEN
DBMS_ADVISOR.CREATE_TASK (
ADVISOR_NAME => DBMS_ADVISOR.SQLACCESS_ADVISOR,
TASK_NAME => l_taskname,
TASK_DESC => l_task_desc);
END IF;

-- reset the task ( remove all recommendations, and intermediate data from the task)
DBMS_ADVISOR.RESET_TASK(TASK_NAME => l_taskname);

-- check if STS already exists
select count(*)
into l_num_found
from DBA_SQLSET where upper(NAME) = upper(l_sts_name) ;

IF l_num_found <> 0 THEN
DBMS_SQLTUNE.DROP_SQLSET ( sqlset_name => l_sts_name);
END IF;

-- create STS
DBMS_SQLTUNE.CREATE_SQLSET(SQLSET_NAME => l_sts_name, DESCRIPTION =>'To test Access
Advisor');

/* unmark the required option
-- (Option 1) Load l_sts_name from an AWR baseline.
-- The data has been filtered to select only the top 30 SQL statements ordered by
elapsed time.
declare
baseline_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
-- a ref cursor is opened to select from the specified baseline
OPEN baseline_cur FOR
SELECT VALUE(p)
FROM TABLE (DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(
'peak baseline',NULL, NULL, 'elapsed_time', NULL, NULL, NULL,30 )) p;

-- Next the statements and their statistics are loaded into the STS
DBMS_SQLTUNE.LOAD_SQLSET( SQLSET_NAME=>l_sts_name, POPULATE_CURSOR=>baseline_cur);
end;

-- (Option 2) Load l_sts_name with SQL statements that are not owned by SYS and
-- their elapsed time is greater than 20,000 seconds.
declare
sql_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
-- a ref cursor is opened to select the required SQL statments
OPEN sql_cur FOR
SELECT VALUE(p)
FROM TABLE (DBMS_SQLTUNE.SELECT_CURSOR_CACHE('parsing_schema_name <> ''SYS'' and
elapsed_time > 2000000',NULL, NULL, NULL, NULL,1, NULL, 'ALL')) p;
-- the statements are loaded into the STS
DBMS_SQLTUNE.LOAD_SQLSET( SQLSET_NAME=>l_sts_name, POPULATE_CURSOR=>sql_cur);
end;

-- (Option 3) Copy the contents of a SQL workload object to a SQL Tuning Set
-- check the example above for creating a workload
DBMS_ADVISOR.COPY_SQLWKLD_TO_STS ('My_WorkLoad', l_sts_name, 'REPLACE');
*/

-- link the STS to the task
DBMS_ADVISOR.ADD_STS_REF (l_taskname, null, l_sts_name);

-- Set task parameters.
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, '_MARK_IMPLEMENTATION', 'FALSE');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'EXECUTION_TYPE', 'INDEX_ONLY');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'MODE', 'COMPREHENSIVE');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'STORAGE_CHANGE',
DBMS_ADVISOR.ADVISOR_UNLIMITED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DML_VOLATILITY', 'TRUE');
Page 62 Oracle 11g New Features for Administrators - Summary Sheets

DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'ORDER_LIST', 'PRIORITY,OPTIMIZER_COST');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'WORKLOAD_SCOPE', 'PARTIAL');
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_INDEX_TABLESPACE',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_INDEX_OWNER',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_MVIEW_TABLESPACE',
DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname, 'DEF_MVIEW_OWNER',
DBMS_ADVISOR.ADVISOR_UNUSED);

-- Execute the task: control will not return till the execution finishes
DBMS_ADVISOR.EXECUTE_TASK(task_name => l_taskname);
END;
/


-- Method 3: Quick Tune for a single given statement
begin
-- a task and a workload will be created then the task will be executed
DBMS_ADVISOR.QUICK_TUNE(
ADVISOR_NAME => DBMS_ADVISOR.SQLACCESS_ADVISOR,
TASK_NAME => 'names_quick_tune',
ATTR1 => 'SELECT id FROM hr.names n WHERE id = 100');
end;
/
Fol l owi ng are exampl es of how t o manage t he t ask and obt ai n i nformat i on about t he advi sor’s out put repot .
-- while the task is being executed, you can monitor it using the following query:
select TASK_NAME, STATUS, PCT_COMPLETION_TIME, ERROR_MESSAGE
from DBA_ADVISOR_LOG
where TASK_NAME ='sql_access_test_task';

-- if you need to terminate the executing task (may be time consuming)
exec DBMS_ADVISOR.CANCEL_TASK(TASK_NAME =>'sql_access_test_task');

-- Display the resulting script ( method 1)
SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.GET_TASK_SCRIPT('sql_access_test_task') AS script FROM dual;
SET PAGESIZE 24

-- Display the resulting script ( method 2)
CREATE DIRECTORY ADVISOR_RESULTS AS 'C:\TEMP\';
exec DBMS_ADVISOR.CREATE_FILE(DBMS_ADVISOR.GET_TASK_SCRIPT('sql_access_test_task'),
'ADVISOR_RESULTS','advscript.sql');

-- alternatively, use the following queries
-- benefit is the total improvement in execution cost of all the queries
select REC_ID, RANK, BENEFIT, TYPE "Recommendation Type"
from DBA_ADVISOR_RECOMMENDATIONS
where TASK_NAME = 'sql_access_test_task'
order by RANK;

-- display processed statements in the workload
select SQL_ID, REC_ID, PRECOST, POSTCOST,
(PRECOST-POSTCOST)*100/PRECOST AS PERCENT_BENEFIT
from USER_ADVISOR_SQLA_WK_STMTS
where TASK_NAME = 'sql_access_test_task' AND workload_name = 'test_work_load';

-- see the actions for each recommendations
select REC_ID, ACTION_ID, SUBSTR(COMMAND,1,30) AS COMMAND
from USER_ADVISOR_ACTIONS where TASK_NAME = 'sql_access_test_task'
ORDER BY rec_id, action_id;

-- to delete a given task
exec DBMS_ADVISOR.DELETE_TASK('sql_access_test_task');

Page 63 Oracle 11g New Features for Administrators - Summary Sheets

Changi ng St at i st i cs Pr ef er ences
The f unct ion DBMS_STATS. GET_PARAM i s used t o in Oracle 10g t o ret urn t he def ault values of paramet ers of t he
DBMS_STATS package. This f unct ion is now obsolet e in Oracle 11g and replaced wit h GET_PREFS procedure.
Following is an example:
SET SERVEROUTPUT ON
declare
v_value varchar2(100);
begin
v_value := DBMS_STATS.GET_PREFS (
PNAME =>'STALE_PERCENT',
OWNNAME =>'HR',
TABNAME =>'EMPLOYEES');
DBMS_OUPTPUT.PUT_LINE(v_value);
end;
Regarding t he GET_PREFS f unct ion, consider t he f ollowing:
• PNAME paramet er indicat es t he pref erence name and can t ake one of t he f ollowing values: CASCADE,
DEGREE, ESTIMATE_PERCENT, METHOD_OPT, NO_INVALIDATE, GRANULARITY, PUBLISH, INCREMENTAL and
STALE_PERCENT.
• I f t he OWNNAME and TABNAME are provided and a pref erence has been ent ered f or t he t able, t he f unct ion
ret urns t he pref erence as specif ied f or t he t able. I n all ot her cases it ret urns t he global pref erence if it
has been specif ied, ot herwise t he def ault value is ret urned.
SET_GLOBAL_PREFS, SET_DATABASE_PREFS, SET_SCHEMA_PREFS, SET_TABLE_PREFS procedures are used t o set
t he st at ist i cs pref erences f or t he global, dat abase, schema or t able levels respect ively. Following is an example:
begin
DBMS_STATS.SET_GLOBAL_PREFS ( PNAME =>'ESTIMATE_PERCENT', PVALUE =>'75');
end;
Similarly, t he procedures DELETE_*_PREFS are used t o delet e current st at ist ics pref erences. EXPORT_*_PREFS and
IMPORT_*_PREFS procedures are used t o export and import st at ist ics pref erences. Following is an example:
begin
DBMS_STATS.EXPORT_DATABASE_PREFS(
STATTAB =>'mytable', -- table name to where statistics should be exported
STATID =>'prod_prefs', -- identifier to associate with these statistics
STATOWN =>'HR'); -- Schema containing stattab (if other than ownname)
end;

Enhanced St at i st i cs Mai nt enance
Pen di n g an d Pu bl i sh ed St at i st i cs
St art ing wit h Oracle 11g, when gat hering st at ist ics, you have t he opt ion t o aut omat ically publish t he st at ist ics at
t he end of t he gat her operat ion ( def ault behavior) , or t o have t he new st at ist ics saved as pending. Saving t he
new st at ist ics as pending allows you t o validat e t he new st at ist ics and publish t hem only if t hey are sat isf act ory.
You can check whet her or not t he st at ist ics will be aut omat ically published checking t he value of t he PUBLISH
at t ribut e using t he DBMS_STATS package as in t he f ollowing example:
SELECT DBMS_STATS.GET_PREFS('PUBLISH') PUBLISH FROM DUAL;
You can change t he PUBLISH set t ing at eit her t he schema or t able level. Following are examples t o do so:
-- setting PUBLISH at schema level
exec DBMS_STATS.SET_SCHEMA_PREFS('HR', 'PUBLISH', 'FALSE');
-- setting PUBLISH at table level
exec DBMS_STATS.SET_TABLE_PREFS('HR','EMPLOYEES', 'PUBLISH', 'FALSE');
Page 64 Oracle 11g New Features for Administrators - Summary Sheets

Published st at ist ics are st ored in dat a dict ionary views, such as DBA_TAB_STATISTICS and USER_IND_
STATISTICS. Pending st at ist ics are st ored in views such as DBA_TAB_PENDING_STATISTICS and
DBA_IND_PENDING_STATISTICS.
select NUM_ROWS, BLOCKS, AVG_ROW_LEN, SAMPLE_SIZE, LAST_ANALYZED
from DBA_TAB_PENDING_STATISTICS where OWNER='HR' AND TABLE_NAME ='EMPLOYEES';
By def ault , t he opt imizer uses t he published st at ist ics st ored in t he dat a dict ionary views. I f you want t he
opt imizer t o use t he newly collect ed pending st at ist ics, set t he init ializat i on paramet er
OPTIMIZER_PENDING_STATISTICS t o TRUE ( t he def ault value is FALSE) , and t hen run a workload against t he
t able or schema or j ust gat her it s st at ist i cs:
ALTER SESSION SET OPTIMIZER_PENDING_STATISTICS = TRUE;
The opt imizer will use t he pending st at ist ics ( if available) inst ead of t he published st at ist ics when compiling SQL
st at ement s. I f t he pending st at ist ics are valid, t hey can be made public by execut ing t he f ollowing st at ement :
-- for the whole database
exec DBMS_STATS.PUBLISH_PENDING_STATS(null, null);
-- publishing specific database object pending statistics
exec DBMS_STATS.PUBLISH_PENDING_STATS('HR','EMPLOYEES');
I f you do not want t o publish t he pending st at ist ics, delet e t hem by execut ing t he f ollowing st at ement :
exec DBMS_STATS.DELETE_PENDING_STATS('HR','EMPLOYEES');
Rest or i n g Pr evi ou s Ver si on s of St at i st i cs
Wit h Oracle Dat abase 11g, you can rest ore previous versions of st at ist ics. DBMS_STATS package has t he f ollowing
procedures t o do t hat : RESTORE_DICTIONARY_STATS, RESTORE_FIXED_OBJECTS_STATS, RESTORE_SCHEMA_STATS,
RESTORE_SYSTEM_STATS, and RESTORE_TABLE_STATS.
First , query t he view DBA_OPTSTAT_OPERATIONS t o know when gat hering t he st at ist ics has been done using
DBMS_STATS. Then decide t o which point in t ime you want t o rest ore t he st at ist ics.
-- list available versions of statistics
SELECT * FROM DBA_OPTSTAT_OPERATIONS;
-- restore to the point you want
begin
-- restore statistics of a specific schema
DBMS_STATS.RESTORE_SCHEMA_STATS(
OWNNAME => 'HR',
AS_OF_TIMESTAMP => '19-FEB-08 06.00.08.477333 AM -06:00');
-- restore statistics of a specific table
DBMS_STATS.RESTORE_SCHEMA_STATS(
OWNNAME => 'HR',
TABNAME => 'EMPLOYEES',
AS_OF_TIMESTAMP => '19-FEB-08 06.00.08.477333 AM -06:00');
end;
Oracle will manage t he hist orical st at ist ics reposit ory, purging t he st at ist ics on a regular basis, by def ault every
31 days. To adj ust t his ret ent ion, consider t he f ollowing examples:
-- get the current retention value
select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual;
- - get the oldest timestamp where statistics history is available
select DBMS_STATS.GET_STATS_HISTORY_AVAILABILITY from dual;
-- set the retention value
exec DBMS_STATS.ALTER_STATS_HISTORY_RETENTION ( 120 ); -- in days
Mu l t i Col u mn St at i st i cs
When mult iple columns f rom a single t able are used t oget her in t he where clause of a query ( mult iple single
column predicat es) , Oracle opt imizer in previous versions ( bef ore 11g) does not underst and t he relat ionship
bet ween t he columns. I n Oracle 11g, st at ist ics on t hese columns as a group ( column group) can be gat hered and
t hus result ing in high enhancement in CBO cardinalit y est imat ion.
Page 65 Oracle 11g New Features for Administrators - Summary Sheets


Not e The Mult iColumn St at ist ics and Expression St at ist ics new f eat ures are bot h const it ut e what is called
by Oracle as Ext ended St at ist ics. Expression St at ist ics is discussed in new f ollowing sub- sect ion.
You can also creat e column groups manually by using t he CREATE_EXTENDED_STATS f unct ion in t he DBMS_STATS
package. This f unct ion creat es a column st at ist ics ent ry in t he syst em f or a user specif ied column group or an
expression in a t able. This f unct ion ret urns a syst em- generat ed name of t his newly creat ed ent ry f or t he
ext ension. Following is an example:
declare
V_NAME VARCHAR2(30);
begin
-- stats of the combined columns will be collected next time the stats is gathered
V_NAME := DBMS_STATS.CREATE_EXTENDED_STATS(
OWNNAME => NULL,
TABNAME => 'EMPLOYEES',
EXTENSION => '(STATE_ID,COUNTRY_ID)');
-- you can then issue the gathering process
DBMS_STATS.GATHER_TABLE_STATS (NULL, 'EMPLOYEES', METHOD_OPT='for all columns size
skewonly' );
end;
The DBMS_STATS.GATHER_TABLE_STATS procedure can also be used t o creat e column group and gat her it s
st at ist ics all in one st ep. The keyword FOR COLUMNS is used in t his case as shown in t he f ollowing example:
begin
DBMS_STATS.GATHER_TABLE_STATS ('HR', 'EMPLOYEES',
METHOD_OPT=>'for all columns size skewonly for columns (STATE_ID,COUNTRY_ID)' );
end;

Not e The def ault value of METHOD_OPT is ' FOR ALL COLUMNS SIZE AUTO' which makes Oracle creat e
column groups f or a t able, based on t he workload analysis, similar t o how it is done f or hist ograms.
You can use t he met hods in t he f ollowing code examples t o ret rieve inf ormat ion on column groups t hat have
been creat ed:
-- you can query the data dictionary USER_STAT_EXTENSIONS
select EXTENSION_NAME, EXTENSION from USER_STAT_EXTENSIONS where TABLE_NAME='EMPLOYEES';
-- you can query USER_TAB_COL_STATISTICS (extension name appears as COLUMN_NAME)
select COLUMN_NAME, NUM_DISTINCT, HISTOGRAM
from USER_TAB_COL_STATISTICS where TABLE_NAME = 'EMPLOYEES';
-- you can use DBMS_STATS.SHOW_EXTENDED_STATS_NAME function
select DBMS_STATS.SHOW_EXTENDED_STATS_NAME(OWNNAME => 'HR',
TABNAME => 'EMPLOYEES',
EXTENSION => 'STATE_ID,COUNTRY_ID') AS E_NAME
from dual;
Af t er gat hering t he mult i- column st at ist ics as show in t he example, when you check t he explain plan f or a query
of a where condit ion like "STATE_ID = 'CA' AND COUNTRY_ID = 'US'", you will not ice t hat t he opt imizer has
ret rieved t he correct number of expect ed ret rieved rows. Pract ically, t his will lead t o a signif icant improvement in
t he st at ement execut ion.
Following is how t o drop a column group t hat you have previously def ined:
exec DBMS_STATS.DROP_EXTENDED_STATS('HR', 'EMPLOYEES', '(STATE_ID,COUNTRY_ID)');
Ex pr essi on St at i st i cs
I n Oracle 11g, you can creat e st at ist ics on an expression. Following are examples t o do t hat :
declare
V_NAME VARCHAR2(30);
begin
-- to create expression extended stats (not statistics are yet gathered)
V_NAME := DBMS_STATS.CREATE_EXTENDED_STATS(
OWNNAME => NULL,
Page 66 Oracle 11g New Features for Administrators - Summary Sheets

TABNAME => 'EMPLOYEES',
EXTENSION => '(lower(last_name))');
end;
begin
-- to create expression extended stats and gather the statistics in one step
DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>NULL,TABLE_NAME=>'EMPLOYEES',
METHOD_OPT=>'for all columns size skewonly for columns (lower(last_name))');
end;
Af t er execut ing t he code above, if you issue a query f rom EMPLOYEES t able wit h a condit ion like
LOWER(LAST_NAME)='ABC', t he opt imizer has st at ist ics about t he ret rieved rows and t hus will be able t o est imat e
t he correct number of ret urned rows. Consequent ly, t he opt imizer will most likely creat e a more ef f icient plan
t han if t hose st at ist ics were not present .
Use t he DBA_STAT_EXTENSIONS dat a dict ionary view t o ret rieve inf ormat ion on expression st at ist ics t hat have
been creat ed in t he dat abase.
select EXTENSION_NAME, EXTENSION from USER_STAT_EXTENSIONS where TABLE_NAME='EMPLOYEES';
Following is an example of t he removal of an ext ended expression st at ist ic:
exec DBMS_STATS.DROP_EXTENDED_STATS(null, 'EMPLOYEES', '(lower(lat_name))' );
Not e t hat you will not be able t o drop an ext ended expression st at ist ics, if a f unct ion- based index is dependent
on t hat st at ist ic ( ORA- 20000 error will be ret urned) .
Au t omat i cal l y Col l ect i n g St at i st i cs on Tabl es
I n Oracle Dat abase 11g, st at ist ics are collect ed aut omat ically f or t ables regardless of t he MONI TORI NG and
NOMONI TORI NG keywords used when creat ing t hem. Those keywords are deprecat ed and ignored, if used.
SQL Pl an Management
SQL plan management ( SPM) , is a new f eat ure in Oracle 11g t hat prevent s perf ormance regressions result ing
f rom sudden changes t o t he execut ion plan of a SQL st at ement by providing component s f or capt uring, select ing,
and evolving SQL plan inf ormat ion. Changes t o t he execut ion plan may be result ed f rom dat abase upgrades,
syst em and dat a changes, applicat ion upgrade or bug f ixes.
When SPM is enabled, t he syst em maint ains a plan hist ory t hat cont ains all plans generat ed by t he opt imizer and
st ore t hem in a component called plan baseline. Among t he plan hist ory in t he plan baseline, plans t hat are
verif ied not t o cause perf ormance regression are marked as accept able. The plan baseline is used by t he
opt imizer t o decide on t he best plan t o use when compiling a SQL st at ement .
Reposit ory st ored in dat a dict ionary of plan baselines and st at ement log maint ained by t he opt imizer is called
SQL management base ( SMB) .
SQL Plan management is implement ed by undert aking t he f ollowing phases:
1. Capt uring SQL Plan Baselines: t his can be done aut omat ically or manually.
2. Select ing SQL Plan Baselines by t he opt imizer
3. Evolving SQL Plan Baselines

Not e St ored out lines will be de- support ed in a f ut ure release in f avor of SQL plan management .
Au t omat i c Pl an Capt u r e
To enable aut omat ic plan capt ure, set t he OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES init ializat ion paramet er t o
TRUE in t he syst em or session level. I t s def ault value is FALSE.
alter system set OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES = TRUE;
Man u al Pl an Loadi n g
SQL plan baselines can be manually loaded wit h exist ing plans f or a set of SQL st at ement s. The plans are not
checked f or perf ormance but will be loaded wit h t he ACCEPTED st at us.
You can load t he plans f rom SQL Tuning Set s, AWR Snapshot s, or Cursor Cache. Following are code examples t o
achieve t hat :
-- to load plans from a SQL Tuning Set (STS)
declare
Page 67 Oracle 11g New Features for Administrators - Summary Sheets

my_plans pls_integer;
begin
my_plans := DBMS_SPM.LOAD_PLANS_FROM_SQLSET( SQLSET_NAME => 'tset1');
end;

-- to load plans from a AWR baseline
declare
baseline_cursor DBMS_SQLTUNE.SQLSET_CURSOR;
my_plans pls_integer;
begin
-- create STS
DBMS_SQLTUNE.CREATE_SQLSET(
SQLSET_NAME => 'Top30_STS',
DESCRIPTION => 'Top 30 SQL Statements in peak workload');

-- load STS from AWR
-- select the top 30 SQL statements ordered by elapsed time
OPEN baseline_cursor FOR
SELECT VALUE(p)
FROM TABLE (DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(
'peak baseline', -- name of the AWR baseline
NULL, NULL,
'elapsed_time',
NULL, NULL, NULL, 30)) p;
DBMS_SQLTUNE.LOAD_SQLSET(SQLSET_NAME => 'Top30_STS',
POPULATE_CURSOR => baseline_cursor);
my_plans := DBMS_SPM.LOAD_PLANS_FROM_SQLSET( SQLSET_NAME => 'Top30_STS');
end;

-- loading Plans from the Cursor Cache
declare
my_sql_plan pls_integer;
v_sql varchar2(1000);
begin
FOR dd in (select sql_id from v$sqlarea
where lower(sql_text) like 'select * from scott.emp') LOOP
IF LENGTH (dd.sql_id) > 0 THEN
my_sql_plan := DBMS_SPM.LOAD_PLANS_FROM_CURSOR_CACHE(sql_id=>dd.sql_id);
END IF;
END LOOP;
end;
Sel ect i n g SQL Pl an Basel i n es
Each t ime a SQL st at ement is compiled, t he opt imizer will f irst use a cost - based search met hod t o build a best -
cost plan, it will compare it t o t he plans in t he plan baseline. Event ually, t he opt imizer will decide t o select t he
lowest - cost plan in t he plan baseline.
To enable t he use of SQL plan baselines, t he OPTIMIZER_USE_SQL_PLAN_BASELINES paramet er must be set t o
TRUE.
alter system set OPTIMIZER_USE_SQL_PLAN_BASELINES = TRUE ;

Not e When you use aut ot race, you can t ell if a baseline is being used. You will see t he f ollowing not e in t he
aut ot race out put :
SQL plan baseline "SYS_SQL_PLAN_a3185cea611ea913" used for this statement
Evol vi n g SQL Pl an Basel i n es
During t he SQL plan baseline evolut ion phase, t he opt imizer det ermines if non- accept ed plans in t he baseline
should be accept ed. This can be done by t he f ollowing t hree ways:
o When t he plan is manually loaded t o t he SQL plan baseline. I n t his case, all loaded plans are added as
accept ed plans.
o When a SQL plan baseline plan is manually evolved.
o Aut omat ic SQL Tuning ( SQL Tuning Advisor) .
A SQL plan baseline plan can be manually evolved using t he f unct ion DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE.
This f unct ion t ries t o evolve new plans added by t he opt imizer t o t he plan hist ory of exist ing plan baselines and if
Page 68 Oracle 11g New Features for Administrators - Summary Sheets

it verif ies t hat a new plan perf orms bet t er t han a plan chosen f rom t he corresponding plan baseline, t he new
plan is added as an accept ed plan. The f ollowing is an example:
declare
report clob;
begin
report := DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE( SQL_HANDLE => 'SYS_SQL_593bc74fca8e6738');
DBMS_OUTPUT.PUT_LINE(report);
end;
When t uning SQL st at ement s wit h t he SQL Tuning Advisor, if t he advisor f inds a t uned plan and verif ies it s
perf ormance t o be bet t er t han a plan chosen f rom t he corresponding SQL plan baseline, it makes a
recommendat ion t o accept a SQL prof ile.
Fi x ed SQL Pl an Basel i n es
A SQL plan baseline is f ixed if it cont ains at least one enabled plan whose FIXED at t ribut e is set t o YES. The
opt imizer will pick a f ixed plan wit h t he least cost even t hough a non- f ixed plan may have an even lower cost .
The opt imizer will not add new plans t o a f ixed SQL plan baseline.
declare
n PLS_INTEGER;
begin
n:= DBMS_SPM.ALTER_SQL_PLAN_BASELINE (
PLAN_NAME => 'SYS_SQL_PLAN_bbedc741a57b5fc2', -- or SQL_HANDLE
ATTRIBUTE_NAME =>'fixed',
ATTRIBUTE_VALUE =>'YES');
DBMS_OUTPUT.PUT_LINE('Number of Altered Plans:' || n);
end;
Di spl ayi n g SQL Pl an Basel i n es
You can view t he plans st ored in t he SQL plan baseline f or a given st at ement or a given plan.
-- the FORMAT paramaeter accepts BASIC, TYPICAL (default) or ALL
select * from table( DBMS_XPLAN.DISPLAY_SQL_PLAN_BASELINE(
SQL_HANDLE=>'SYS_SQL_209d10fabbedc741',
FORMAT=>'basic'));

select * from table( DBMS_XPLAN.DISPLAY_SQL_PLAN_BASELINE(
PLAN_NAME=>'SYS_SQL_PLAN_bbedc741a57b5fc2',
FORMAT=>'basic'));

select ORIGIN, SQL_HANDLE, PLAN_NAME, ENABLED, ACCEPTED, FIXED from
DBA_SQL_PLAN_BASELINES where CREATOR='HR';
Vi ew i n g SPM Con f i gu r at i on Par amet er s
The current conf igurat ion set t ings f or t he SQL management can be viewed using t he f ollowing query:
select PARAMETER_NAME, PARAMETER_VALUE from DBA_SQL_MANAGEMENT_CONFIG;
Di sk Space Usage by SMP
By def ault , t he limit f or t he SPM is no more t han 10% of t he size of t he SYSAUX t ablespace. The allowable range
f or t his limit is bet ween 1% and 50%. To change t he percent age limit , use t he CONFIGURE procedure of t he
DBMS_SPM package:
exec DBMS_SPM.CONFIGURE('space_budget_percent',30);
When t he space occupied by SQL management base exceeds t he def ined space budget limit , a weekly dat abase
alert is generat ed.
Pu r gi n g Pol i cy
As part of t he aut omat ed t ask in t he maint enance window, any plan t hat has not been used f or more t han 53
weeks are purged. To conf igure t he ret ent ion period, use t he CONFIGURE procedure of t he DBMS_SPM package:
exec DBMS_SPM.CONFIGURE('plan_retention_weeks',105); -- between 5 and 523
Page 69 Oracle 11g New Features for Administrators - Summary Sheets

I mpor t i n g an d Ex por t i n g SQL Pl an Basel i n es
Oracle Dat abase support s t he export and import of SQL plan baselines using it s import and export ut ilit ies or
Oracle Dat a Pump, as f ollows:
1. On t he original syst em, creat e a st aging t able as f ollows:
exec DBMS_SPM.CREATE_STGTAB_BASELINE(TABLE_NAME => 'stage1');
2. Pack t he SQL plan baselines you want t o export f rom t he SQL management base int o t he st aging t able as
f ollows:
declare
my_plans number;
begin
-- you can also specify the PLAN_NAME or SQL_HANDLE
my_plans := DBMS_SPM.PACK_STGTAB_BASELINE(
TABLE_NAME => 'stage1', ENABLED => 'yes', CREATOR => 'HR');
DBMS_OUTPUT.PUT_LINE('Number of SQL plans packed: ' || my_plans);
end;
3. Export t he st aging t able stage1 int o a f lat f ile using t he export command or Oracle Dat a Pump.
4. Transf er t he f lat f ile t o t he t arget syst em.
5. I mport t he st aging t able stage1 f rom t he f lat f ile using t he import command or Oracle Dat a Pump.
6. Unpack t he SQL plan baselines f rom t he st aging t able int o t he SPM on t he t arget syst em as f ollows:
declare
v_plans number;
begin
v_plans := DBMS_SPM.UNPACK_STGTAB_BASELINE( TABLE_NAME => 'stage1', FIXED => 'yes');
DBMS_OUTPUT.PUT_LINE('Number of SQL Plans Unpacked: ' || v_plans);
end;
Dr oppi n g SQL pl an basel i n es
You can drop SQL plan baselines wit h t he DBMS_SPM.DROP_SQL_PLAN_BASELINE f unct ion which ret urns t he
number of plans t hat were removed.
declare
v_plans_dropped PLS_INTEGER;
begin
-- you can pass PLAN_NAME or SQL_HANDLE or both
v_plans_dropped:=DBMS_SPM.DROP_SQL_PLAN_BASELINE(
SQL_HANDLE =>'SYS_SQL_353e8c17a551f70c',
PLAN_NAME =>'SYS_SQL_PLAN_a551f70c695cc014');
DBMS_OUTPUT.PUT_LINE('Number of SQL Plans Dropped: ' || v_plans);
end;

ADDM New Feat ur es
Dat abase ADDM
Oracle Dat abase 11g has added a new layer of analysis t o ADDM called Dat abase ADDM. The mode ADDM was
working in Oracle 10g is now called inst ance ADDM. The main t arget of dat abase ADDM is t o analyze and report
on RAC environment .
To enable Dat abase ADDM, you set t he paramet er INSTANCES in DBMS_ADVISOR. Following are t he available
opt ions t o set t his paramet er:
-- Disable Database ADDM for all instances
exec DBMS_ADVISOR.SET_DEFAULT_TASK_PARAMETER('ADDM','INSTANCES','UNUSED');
-- Configure Database ADDM for instances 1 and 3 only
exec DBMS_ADVISOR.SET_DEFAULT_TASK_PARAMETER('ADDM','INSTANCES','1,3');
-- Configure Database ADDM for all instances
exec DBMS_ADVISOR.SET_DEFAULT_TASK_PARAMETER('ADDM','INSTANCES','ALL');
Page 70 Oracle 11g New Features for Administrators - Summary Sheets

The result s of t his addit ional level of analysis will appear in several places in OEM, such as t he Clust er dat abase
home page in t he Perf ormance Analysis page.
ADDM New Vi ew s
Oracle Dat abase 11g has added t he f ollowing new ADDM- relat ed views:
DBA_ADDM_TASKS
displays inf ormat ion about all ADDM t asks in t he dat abase.
DBA_ADDM_INSTANCES
provides inst ance- level inf ormat ion f or ADDM t asks t hat f inished execut ing.
DBA_ADDM_FINDINGS
displays t he ADDM f indings discovered by all advisors in t he dat abase
DBA_ADDM_FDG_BREAKDOWN
describes t he cont ribut ion f or each f inding f rom t he dif f erent inst ances.
Following are some queries f rom t hose views:
-- STATUS takes one of the following: INITIAL, EXECUTING, INTERRUPTED, COMPLETED, ERROR
select TASK_NAME, ADVISOR_NAME, STATUS, PCT_COMPLETION_TIME, ERROR_MESSAGE
from DBA_ADDM_TASKS
order by EXECUTION_END desc

-- TYPE takes on of the following: PROBLEM, SYMPTOM, ERROR, INFORMATION
-- can be linked to DBA_ADDM_TASKS using TASK_ID
select TASK_NAME, FINDING_NAME, TYPE, OBJECT_ID, IMPACT_TYPE, IMPACT, MESSAGE
from DBA_ADDM_FINDINGS
order by IMPACT desc

-- STATUS takes one of the following: ANALYZED, BOUNCED, NO_SNAPS, NO_STATS, NOT_FOUND
select INSTANCE_NAME, STATUS
from DBA_ADDM_INSTANCES
Fi n di n g Cl assi f i cat i on s
A f inding name has been added t o t he Advisor f ramework in Oracle Dat abase 11g. The f inding name provides
addit ional inf ormat ion t hat helps t o classif y t he f inding being given. Finding name can be f ound in t he
DBA_ADVISOR_FINDING_NAMES view.
select to_char(EXECUTION_END, 'hh24') hour , count(*)
from DBA_ADVISOR_FINDINGS a, DBA_ADVISOR_TASKS b
where FINDING_NAME like 'CPU Usage%'
and a.TASK_ID=b.TASK_ID
group by to_char(EXECUTION_END, 'hh24')
order by 1;
Page 71 Oracle 11g New Features for Administrators - Summary Sheets

Man agi n g ADDM w i t h DBMS_ADDM
Oracle Dat abase 11g int roduces t he DBMS_ADDM package t o assist t he DBA in administ rat ion of Oracle ADDM.
Using t he package DBMS_ADVISOR is st ill act ive. Below are code examples on using t he DBMS_ADDM package:
/* to execute a database wide ADDM analysis and report on the results */
-- get the list of valid snapshots within the last 4 hours
select INSTANCE_NUMBER, SNAP_ID
from WRM$_SNAPSHOT
where END_INTERVAL_TIME < SYSTIMESTAMP - INTERVAL '4' HOUR
order by 1,2;
INSTANCE_NUMBER SNAP_ID
--------------- ----------
1 24
2 23
2 25
2 26

VAR tname varchar2(60);
begin
:tname:='ADDM Database Task';
DBMS_ADDM.ANALYZE_DB(:tname, 25, 26); -- or use ANALYZE_INST ANALYZE_PARTIAL procedures
end;

set long 1000000
spool /tmp/addmrpt.txt
SELECT DBMS_ADDM.GET_REPORT(:tname ) FROM dual;
spool off
-- remove the ADDM analysis
exec DBMS_ADDM.DELETE('ADDM Database Task');
Di r ect i ves
To exclude various ADDM analysis and f indings f rom appearing in t he report , you can set direct ives. These
direct ives can be assigned t o a specif ic ADDM t ask, or can be set as a syst em direct ive. Direct ives can be set via
command line, or f rom wit hin OEM. See t he f ollowing examples of t he procedures used t o set direct ives:
/* To create a new ADDM task to analyze a local instance.
The result of GET_REPORT will only show an 'Undersized SGA' finding if the finding
is responsible for at least 2 average active sessions during the analysis period,
and this constitutes at least 10% of the total database time during that period. */
var tname VARCHAR2(60);
begin
DBMS_ADDM.INSERT_FINDING_DIRECTIVE(
TASK_NAME => NULL, -- apply the directive to all subsequently created ADDM Tasks
DIR_NAME => 'Undersized SGA Directive', -- directives must be given unique names
FINDING_NAME => 'Undersized SGA', -- derived from NAME in DBA_ADVISOR_FINDING_NAMES
MIN_ACTIVE_SESSIONS => 2,
MIN_PERC_IMPACT => 10);
:tname := 'my_instance_analysis_mode_task';
DBMS_ADDM.ANALYZE_INST(:tname, 1, 2);
end;
SELECT DBMS_ADVISOR.GET_TASK_REPORT(:tname, 'TEXT', 'ALL') FROM DUAL;
/* To create a directive to prevent ADDM from creating actions to alter the
value of a specific system parameter. */
var tname varchar2(60);
BEGIN
DBMS_ADDM.INSERT_PARAMETER_DIRECTIVE(
TASK_NAME => NULL,
DIR_NAME => 'System Parameter Directive',
PARAMETER_NAME=>'sga_target');
:tname := 'my_instance_analysis_mode_task';
DBMS_ADDM.ANALYZE_INST(:tname, 1, 2);
END;
SELECT DBMS_ADVISOR.GET_TASK_REPORT(:tname, 'TEXT', 'ALL') FROM DUAL;
Page 72 Oracle 11g New Features for Administrators - Summary Sheets

/* To creates a directive that will prevent ADDM from creating actions to "run
Segment Advisor" for specific owner, segment, subsegment, or a specific object number. */
var tname VARCHAR2(60);
BEGIN
DBMS_ADDM.INSERT_SEGMENT_DIRECTIVE(
TASK_NAME => NULL,
DIR_NAME=>'my Segment directive',
OWNER_NAME=>'SCOTT', -- owner of the segment to be filtered out
OBJECT_NAME=>null, -- all objects (wildcards are allowed)
SUB_OBJECT_NAME=>null, -- a partition or sub partition
OBJECT_NUMBER => null); -- found in views DBA_OBJECTS or DBA_SEGMENTS
:tname := 'my_instance_analysis_mode_task';
DBMS_ADDM.ANALYZE_INST(:tname, 1, 2);
END;
SELECT DBMS_ADVISOR.GET_TASK_REPORT(:tname, 'TEXT', 'ALL') FROM DUAL;
/* to create a directive to limit reporting of actions on the SQL id 'abcd123456789'.
The result of GET_REPORT will only show actions for that SQL (actions to tune the
SQL, or to investigate application using it) if the SQL is responsible for at
least 2 average active sessions during the analysis period, and the average
response time was at least 1 second. */
var tname VARCHAR2(60);
BEGIN
DBMS_ADDM.INSERT_SQL_DIRECTIVE(
TASK_NAME => NULL,
DIR_NAME =>'my SQL directive',
SQL_ID =>'abcd123456789',
MIN_ACTIVE_SESSIONS =>2,
MIN_RESPONSE_TIME=>1000000);
:tname := 'my_instance_analysis_mode_task';
DBMS_ADDM.ANALYZE_INST(:tname, 1, 2);
END;
SELECT DBMS_ADVISOR.GET_TASK_REPORT(:tname, 'TEXT', 'ALL') FROM DUAL;
A new column, FILTERED, which can be f ound in a number of views, indicat es if a part icular row in t he view was
f ilt ered out by a direct ive. Views wit h t he FILTERED column include: DBA_ADVISOR_FINDINGS,
DBA_ADVISOR_RECOMMENDATIONS, DBA_ADVISOR_ACTIONS.
Following are examples of t he procedures t o remove direct ives:
exec DBMS_ADDM.DELETE_FINDING_DIRECTIVE(DIR_NAME =>'my_directive');
exec DBMS_ADDM.DELETE_PARAMETER_DIRECTIVE(DIR_NAME =>'my_directive');
exec DBMS_ADDM.DELETE_SEGMENT_DIRECTIVE(DIR_NAME =>'my_directive');
exec DBMS_ADDM.DELETE_SQL_DIRECTIVE(DIR_NAME =>'my_directive');

AWR New Feat ur es
Def au l t Ret en t i on of AWR Sn apsh ot s Ch an ged
By def ault , Oracle Dat abase 11g will now ret ain eight days of AWR snapshot inf ormat ion ( as opposed t o seven in
Oracle 10g) .
New Types of AWR Basel i n es
Oracle Dat abase 11g of f ers t he f ollowing new t ypes of AWR baseline:
• Moving Window Baselines: current ly t here is only one named as SYSTEM_MOVING_WINDOW
• Baseline Templat es: t hey enable you t o creat e baselines f or a cont iguous t ime period in t he f ut ure. There are
t wo t ypes of baseline t emplat es:
o Single baseline
o Repeat ing baseline
Movi n g Wi n dow Basel i n es
A moving window baseline ( it s name is always SYSTEM_MOVING_WINDOW) corresponds t o all AWR dat a t hat exist s
wit hin t he AWR ret ent ion period. This is usef ul when using adapt ive t hresholds because t he AWR dat a in t he
ent ire AWR ret ent ion period can be used t o comput e met ric t hreshold values.
Page 73 Oracle 11g New Features for Administrators - Summary Sheets

You can resize t he moving window baseline by changing t he number of days in t he moving window t o a value
t hat is equal t o or less t han t he number of days in t he AWR ret ent ion period as in t he f ollowing example:
-- first increase AWR retention period (in minutes)
exec DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(RETENTION=> 43200);
-- then you can increase window size (in days)
exec DBMS_WORKLOAD_REPOSITORY.MODIFY_BASELINE_WINDOW_SIZE ( WINDOW_SIZE => 30);
-- info about the window
select BASELINE_NAME, BASELINE_TYPE, START_SNAP_TIME, END_SNAP_TIME
from DBA_HIST_BASELINE;
Si n gl e Basel i n e Templ at e
A single baseline t emplat e can be used t o creat e a baseline during a single, f ixed t ime int erval in t he f ut ure. For
example, you can creat e a single baseline t emplat e t o generat e a baseline t hat is capt ured on July 2, 2007 f rom
5: 00 p. m. t o 8: 00 p. m.
begin
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
START_TIME => '2007-07-02 17:00:00 PST',
END_TIME => '2007-07-02 20:00:00 PST',
BASELINE_NAME => 'Baseline_070702',
TEMPLATE_NAME => 'Template_070702',
EXPIRATION => 30, -- (in days) if unspecified, it will never expire
DBID => 3310949047 -- optional: if unspecified, the local db id is used
);
end;
Repeat i n g Basel i n e Templ at e
A repeat ing baseline t emplat e is used t o aut omat ically creat e baselines t hat repeat during a part icular t ime
int erval over a specif ic period in t he f ut ure. For example, you can creat e a repeat ing baseline t emplat e t o
generat e a baseline t hat repeat s every Monday f rom 5: 00 p. m. t o 8: 00 p. m. f or t he year 2007.
begin
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
DAY_OF_WEEK => 'monday', -- the day of the week on which the baseline will repeat
HOUR_IN_DAY => 17, -- (0 to 23) the hour in the day when the baseline will start
DURATION => 3, -- number of hours the baseline will last
EXPIRATION => 30, -- number of days to retain each created baseline
START_TIME => '2007-04-02 17:00:00 PST',
END_TIME => '2007-12-31 20:00:00 PST',
BASELINE_NAME_PREFIX =>'bas_07_mon', -- will be appended to the baseline names
TEMPLATE_NAME => 'template_2007_mondays',
DBID => 3310949047);
end;
Ren ame Basel i n es
You can use t he st at ement as in t he f ollowing example t o rename exist ing baselines:
begin
DBMS_WORKLOAD_REPOSITORY.RENAME_BASELINE(
OLD_BASELINE_NAME =>'workload_baseline',
NEW_BASELINE_NAME =>'workload_baseline0407',
DBID => 3310949047);
end;
Dr oppi n g Basel i n e Templ at es
Following is an example on how t o drop a baseline t emplat e:
Exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE_TEMPLATE( TEMPLATE_NAME => 'MyTemplate' );
Obt ai n i n g I n f or mat i on Abou t Ex i st i n g Basel i n es
Use t he code in t he f ollowing example t o obt ain inf ormat ion about exist ing baselines in t he dat abase:
-- info about Baseline Templates
select TEMPLATE_NAME, TEMPLATE_TYPE,
START_TIME,END_TIME, DAY_OF_WEEK, HOUR_IN_DAY, DURATION, EXPIRATION, REPEAT_INTERVAL
from DBA_HIST_BASELINE_TEMPLATE;
-- info on baselines taken in the system
Page 74 Oracle 11g New Features for Administrators - Summary Sheets

-- if BASELINE_TYPE equals GENERATED, it is generated by the system using a template
select BASELINE_NAME, BASELINE_TYPE, START_SNAP_ID, START_SNAP_TIME,
END_SNAP_ID, END_SNAP_TIME, MOVING_WINDOW_SIZE,
EXPIRATION, TEMPLATE_NAME
from DBA_HIST_BASELINE;
-- details about the baseline
-- PCT_TOTAL_TIME Amount of time captured in snapshots, divided by the total possible
-- time for this baseline
select INSTANCE_NUMBER, BASELINE_ID, BASELINE_NAME, BASELINE_TYPE,
START_SNAP_ID, START_SNAP_TIME, END_SNAP_ID, END_SNAP_TIME,
SHUTDOWN, ERROR_COUNT, PCT_TOTAL_TIME, LAST_TIME_COMPUTED,
MOVING_WINDOW_SIZE, EXPIRATION, TEMPLATE_NAME
from DBA_HIST_BASELINE_DETAILS

Set t i ng Met r i c Thr eshol ds f or Basel i nes
Set t i n g Met r i c Th r esh ol ds f or t h e Def au l t Movi n g Basel i n e u si n g Wor k l oad Pr of i l es
To set met ric t hresholds f or t he def ault moving baseline in OEM:
1. Follow t he links Dat abase Home page> Rel at ed Li n k s sect i on > Basel i n e Met r i c Th r esh ol ds> Qu i ck
Con f i gu r at i on > Wor k l oad Pr of i l e sect i on > sel ect on e of t h e f ol l ow i n g opt i on s:
• Primarily OLTP
• Primarily Dat a Warehousing
• Alt ernat ing
2. Click Con t i n u e t hen click Fi n i sh .
Set t i n g Met r i c Th r esh ol ds f or Sel ect ed Basel i n es
To set a met ric t hreshold f or a select ed baseline in OEM:
1. Follow t he links Dat abase Home> Rel at ed Li n k s> Basel i n e Met r i c Th r esh ol ds
2. I n t he Vi ew list , select Basi c Met r i cs.
3. Specif y t he met ric you want t o edit ( f rom t he Cat egory/ Name column) and t he name of a baseline ( f rom t he
AWR Baseline column) t hen click Edi t Th r esh ol ds.
4. Modif y any t hreshold set t ing t hen click Appl y Th r esh ol ds.
Per f or mance- Rel at ed Changes i n Dat abase Cont r ol
Cu st omi zed Per f or man ce Page
You can in Oracle 11g set up a cust omized Dat abase Perf ormance page in Dat abase Cont rol.
Click t he Set t i n gs l i n k t o go t o t he Per f or man ce Page Set t i n gs page. The Perf ormance Page Set t ings page
has t wo sect ions. The Det ai l ed Ch ar t Set t i n gs sect i on let s you choose def ault s f or displaying t he inst ance
act ivit y chart s. The Basel i n e Di spl ay Set t i n gs sect i on let s you select if and how t he AWR baseline values are
displayed in t he Perf ormance page chart s.
Aver age Act i ve Sessi on s
The aver age act i ve sessi on s sect i on on t he Per f or man ce page of f ers shows, in graphical f orm, what
proport ion of t ime users are wait ing and t he t ime t hey spend on an act ivit y, such as I O.
ADDM Per f or man ce An al ysi s
On t he Dat abase Cont rol Dat abase home page, you can now see an ADDM perf ormance analysis summary t able,
which provides you a quick overview of current ADDM f indings.

Mi scel l aneous New Per f or mance Tuni ng Feat ur es
Act i ve sessi on h i st or y ( ASH) en h an cemen t s
ASH st at ist ics are enhanced t o provide row- level act ivit y inf ormat ion f or each SQL st at ement t hat is capt ured. As
wit h Oracle 10g, current ASH is st ored in V$ACTIVE_SESSION_HISTORY view and it s hist orical dat a st ored in t he
DBA_HIST_ACTIVE_SESS_HISTORY view.
Page 75 Oracle 11g New Features for Administrators - Summary Sheets

En h an ced I / O st at i st i cs
I / O st at ist ics are collect ed f or all I / O calls made by Oracle Dat abase in t he f ollowing dimensions: consumer
group, dat abase f ile, and dat abase f unct ion. Following are t he new views providing t his inf ormat ion:
V$IOSTAT_CONSUMER_GR
OUP

capt ures I / O st at ist ics f or consumer groups. I f Oracle Dat abase Resource Manager is
enabled, I / O st at ist ics f or all consumer groups t hat are part of t he current ly enabled
resource plan are capt ured.
V$IOSTAT_FILE
This view displays I / O st at ist ics of dat abase f iles t hat are or have been accessed. The
SMALL_SYNC_READ_LATENCY column displays t he lat ency f or single block synchronous
reads ( in milliseconds) , which t ranslat es direct ly t o t he amount of t ime t hat client s
need t o wait bef ore moving ont o t he next operat ion.
V$IOSTAT_FUNCTION

The V$IOSTAT_FUNCTION view capt ures I / O st at ist ics f or dat abase f unct ions ( such as
t he LGWR and DBWR) .
Following are examples of queries on t hose views:
-- I/O stats for Datafiles and Tempfiles
-- Single block operations are small I/Os that are less than or equal to 128 kilobytes.
-- SMALL_SYNC_READ_LATENCY is Latency for single block synch reads (ms)
select FILE_NO, FILETYPE_NAME,
SMALL_SYNC_READ_REQS "synch single block read reqs",
SMALL_READ_REQS "single block read requests",
SMALL_WRITE_REQS "single block write requests",
round(SMALL_SYNC_READ_LATENCY/1000,2) "Single Block Read Latency (s)",
LARGE_READ_REQS "multiblock read requests",
LARGE_WRITE_REQS "multiblock write requests",
ASYNCH_IO "asynch I/O Availability"
from V$IOSTAT_FILE
where FILETYPE_ID IN (2,6); -- data file and temp file
-- I/O stats by functionality
select FUNCTION_NAME,
SMALL_READ_REQS "single block read requests",
SMALL_WRITE_REQS "single block read requests",
LARGE_READ_REQS "multiblock read requests",
LARGE_WRITE_REQS "multiblock write requests",
NUMBER_OF_WAITS "I/O waits",
round(WAIT_TIME/1000,2) "Total wait time (ms)"
from V$IOSTAT_FUNCTION
order by FUNCTION_NAME;

Real - Ti me SQL Moni t or i ng
The real- t ime SQL monit oring f eat ure of Oracle Dat abase enables you t o monit or t he perf ormance of SQL
st at ement s while t hey are execut ing. By def ault , SQL monit oring is aut omat ically st art ed when a SQL st at ement
runs parallel, or when it has consumed at least 5 seconds of CPU or I O t ime in a single execut ion.
The st at ist ics f or monit ored SQL st at ement execut ion can be displayed using t he V$SQL_MONITOR and
V$SQL_PLAN_MONITOR views.
select STATUS,
to_char(M.FIRST_REFRESH_TIME,'hh24:mi') "First Refresh Time",
to_char(M.LAST_REFRESH_TIME,'hh24:mi') "Last Refresh Time",
M.ELAPSED_TIME "Elapsed Time (micro s)",
M.CPU_TIME "CPU Time (micro s)",
M.BUFFER_GETS,
M.DISK_READS,
M.USER_IO_WAIT_TIME "IO Wait Time (micro s)"
from V$SQL_MONITOR M, V$SQL S
where M.SQL_ID = S.SQL_ID AND
upper(SQL_TEXT) like 'SELECT%FROM%NAMES%'
An alt ernat ive more convenient met hod is t o generat e t he SQL monit or report using t he
DBMS_SQLTUNE.REPORT_SQL_MONITOR f unct ion as f ollows:
variable my_rept CLOB;
BEGIN
:my_rept :=DBMS_SQLTUNE.REPORT_SQL_MONITOR();
Page 76 Oracle 11g New Features for Administrators - Summary Sheets

END;
/
print :my_rept
The SQL monit oring f eat ure is enabled at t he dat abase level by def ault when t he STATISTICS_LEVEL init ializat ion
paramet er is eit her set t o ALL or TYPICAL ( t he def ault value) . Addit ionally, t he
CONTROL_MANAGEMENT_PACK_ACCESS paramet er must be set t o DIAGNOSTIC+TUNING ( t he def ault value) .
To f orce SQL monit oring at t he SQL st at ement level, use t he MONITOR hint . To prevent t he hint ed SQL st at ement
f rom being monit ored, use t he NO_MONITOR reverse hint .
select /*+MONITOR*/ from ..;

Adapt i v e Cur sor Shar i ng
When bind variables are used in t he SELECT st at ement s against columns cont aining skewed dat a, t hey
somet imes lead t o less t han opt imum execut ion plans. The opt imizer creat es t he execut ion plan during t he hard
parse when t he st at ement is f irst present ed t o t he server. This execut ion plan is t hen used f or all every
execut ion of t he st at ement , regardless of t he bind variable values.
Oracle 11g uses Adapt ive Cursor Sharing which compares t he ef f ect iveness of execut ion plans bet ween
execut ions wit h dif f erent bind variable values. I f it not ices subopt imal plans, it allows cert ain bind variable
values, or ranges of values, t o use alt ernat e execut ion plans f or t he same st at ement . This f unct ionalit y requires
no addit ional conf igurat ion.



Page 77 Oracle 11g New Features for Administrators - Summary Sheets

Dat abase Secur i t y
St r onger Passw or d Hash Al gor i t hm

I n Oracle Dat abase 11g, t he SHA- 1 st andard became t he new algorit hm f or password hashing. SHA- 1 is a 160-
bit hash employed in several widely used securit y applicat ions and prot ocols, including TLS and SSL, PGP, SSH,
S/ MI ME, and I Psec.
Secur i t y Out of t he Box
Def au l t Dat abase Secu r i t y Set t i n gs
I f you creat e a dat abase using DBCA and you select t o enable t he securit y set t ings, Oracle by def ault will creat e
t he dat abase wit h new level of securit y set t ings as f ollows:
Dat abase audit s of relevant SQL st at ement s and privileges
Modif icat ions t o t he def ault prof ile. The new def ault prof ile is set wit h t hese set t ings:
PASSWORD_LOCK_TIME=1
PASSWORD_GRACE_TIME=7
PASSWORD_LIFE_TIME=180
FAILED_LOGIN_ATTEMPTS=10
PASSWORD_REUSE_MAX=UNLIMITED
PASSWORD_REUSE_TIME=UNLIMITED
DBCA will aut omat ically set t he AUDIT_TRAIL init ializat ion paramet er t o DB.
To display t he privileges t hat are audit ed, issue t he f ollowing query:
select PRIVILEGE, SUCCESS, FAILURE
from DBA_PRIV_AUDIT_OPTS
order by PRIVILEGE;
Def au l t Au di t i n g
Whet her you creat e a new Oracle 11g dat abase or you upgrade t he dat abase t o Oracle 10g, if you accept t o t he
audit ing def ault s, t he f ollowing operat ions will be audit ed:
Alter any procedure Create any job Drop any table
Alter any table Create any library Drop profile
Alter database Create any procedure Drop user
Alter profile Create any table Exempt access policy
Alter system Create external job Grant any object privilege
Alter user Create public database link Grant any privilege
Audit role by access Create session Grant any role
Audit system Create user Audit system by access
Drop any procedure
As wit h previous versions, audit dat a is st ored in AUD$ t able which should be manually maint ained by you. I f you
want t o disable audit ing a specif ic operat ion, use t he NOAUDIT command.
Del ayed Fai l ed Logi n s
I f a user t ries t o connect t o t he dat abase mult iple t imes using an erroneous password, t he dat abase will delay
t he response t o t he client af t er t he t hird at t empt . The delays of response back t o t he client are repeat ed even if
t he connect ions are init iat ed f rom dif f erent I P addresses or host s.
Case- Sen si t i ve Passw or ds
Oracle 11g int roduces case- sensit ive passwords f or dat abases creat ed wit h t he def ault Oracle Dat abase 11g
enhanced securit y.
The SEC_CASE_SENTITIVE_LOGON paramet er must be set t o TRUE t o enable case- sensit ive dat abase passwords.
alter system set SEC_CASE_SENSITIVE_LOGON = TRUE;
I f you import a dump f ile of users f rom Oracle Dat abase 9i or 10g, users’ passwords will remain case- insensit ive
unt il you manually reset t hem. Same rule apply when you upgrade a dat abase f rom an earlier version t o Oracle
11g. The f ollowing query will display t he dat abase users whose passwords are not case sensit ive:
select USERNAME, PASSWORD_VERSIONS
from DBA_USERS
Page 78 Oracle 11g New Features for Administrators - Summary Sheets

where PASSWORD_VERSIONS NOT LIKE '%11G%'
order by USERNAME;
Case- Sen si t i ve Passw or d Fi l es
Passwords creat ed in t he password f ile can be set as case- sensit ive by using t he new opt ion ignorecase wit h t he
ut ilit y orapwd. Following is an example:
orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=ORAcle123 \
entries=25 ignorecase=n
Ch an ge Def au l t User Passw or ds
The new DBA_USERS_WITH_DEFPWD view report s t hose account s wit h def ault passwords f or Oracle- supplied
dat abase account s. I t is a good pract ice t o change passwords of users displayed by t his view.
select USERNAME from DBA_USERS_WITH_DEFPWD order by USERNAME;
Dat abase Li n k s an d Case Sen si t i vi t y
I f you creat e a dat abase link in an earlier version of Oracle t han 11g, you must alt er t he password on Oracle
Dat abase 11g t o t he uppercase equivalent of t he password designat ed in t he dat abase link’s CONNECT TO
USERNAME IDENTIFIED BY clause sect ion.
Hi di n g Passw or d Hash Val u es i n DBA_USERS
To provide f urt her level of securit y, t he DBA_USERS view in Oracle Dat abase 11g has t he password column
blanked out inst ead of displaying t he hashed value of t he password.
select USERNAME, PASSWORD from DBA_USERS order by USERNAME;
New Passw or d Ver i f i cat i on Fu n ct i on
Oracle 11g provides a new password verif icat ion f unct ion wit h st ronger set t ings t han t hose in t he f unct ions of
earlier versions. This f unct ion, however, is not enabled by def ault .
The script $ORACLE_HOME/rdbms/admin/utlpwdmg.sql creat es t he new f unct ion ( named as
VERIFY_FNCTION_11G) , enables it in t he def ault prof ile and also it creat es t he Oracle 10g f unct ion f or legacy
compat ibilit y.
@$ORACLE_HOME/rdbms/admin/utlpwdmg.sql
The f unct ion f orces rest rict ions on t he dat abase users' passwords like minimum eight charact ers, cannot be same
or similar t o t he user name or t he host name, and must has at least one let t er and one digit .
Ant i Net w or k At t ack s Par amet er s
Oracle Dat abase 11g provides some init ializat ion paramet ers t o prot ect against I nt ernet at t acks including t he
f ollowing:
SEC_PROTOCOL_ERROR_FURTHER_ACTION
Specif ies t he f urt her execut ion of a server process when receiving bad packet s f rom a possibly malicious client .
Following are it s possible values:

CONTINUE
The server process cont inues execut ion. The dat abase server may be subj ect t o a Denial of
Service ( DoS) if bad packet s cont inue t o be sent by a malicious client .

(DELAY, n)
The client experiences a delay of n seconds bef ore t he server process accept s t he next
request f rom t he same client connect ion.

(DROP, n)
The server f orcef ully t erminat es t he client connect ion af t er n bad packet s. The server
prot ect s it self at t he expense of t he client ( f or example, a client t ransact ion may be lost ) .
SEC_PROTOCOL_ERROR_TRACE_ACTION
Specif ies t he t race level when bad packet s are received f rom a possibly malicious client .

NONE
The dat abase server ignores t he bad packet s and does not generat e any t race f iles or log
messages.

TRACE
A det ailed t race f ile is generat ed when bad packet s are received, which can be used t o debug
any problems in client / server communicat ion.

LOG
A minimal log message is print ed in t he alert logf ile and in t he server t race f ile. A minimal
Page 79 Oracle 11g New Features for Administrators - Summary Sheets

amount of disk space is used.

ALERT
An alert message is sent t o a DBA or monit oring console.
SEC_MAX_FAILED_LOGIN_ATTEMPTS
Def ines t he number of aut hent icat ion at t empt s t hat a given client connect ion can make on t he server bef ore
t he client process is dropped. The def ault value is 10.
SEC_RETURN_SERVER_RELEASE_BANNER
Det ermines if t he server banner will be ret urned t o a client connect ion. Not ret urning t he banner will make
hacking a dat abase more dif f icult since t he user will not know which version of t he dat abase t hey are t rying t o
hack.

Tabl espace Encr ypt i on
I n Oracle Dat abase 11g, as an ext ension t o Transparent Dat a Encrypt ion ( TDE) , you can encrypt an ent ire
t ablespace. Tablespace encrypt ion relies on encrypt ion keys in a wallet out side t he dat abase. When you use an
encrypt ed t ablespace, t he ent ire t ables and associat ed indexes in t he t ablespace are encrypt ed. Also, t he dat a
remains encrypt ed when it is st ored in t he redo logs.
En cr y pt ed Tabl espace Li mi t at i on s
• You cannot encrypt an exist ing t ablespace.
• exp and imp ut ilit ies are not support ed wit h obj ect s in t he encrypt ed t ablespaces. Whereas expdp and impdp
ut ilit ies are support ed.
• You cannot re- creat e t he t ablespace encrypt ion key.
• The NO SALT opt ion is not support ed.
• Temporary and undo t ablespaces cannot be encrypt ed.
• You cannot t ransport an encrypt ed t ablespace t o a dat abase t hat already has an Oracle wallet f or TDE. I n
t his case, use Oracle Dat a Pump t o export t he obj ect s in t he t ablespace using t he expdp wit h
ENCRYPTION_MODE= password and t hen import t hem t o t he dest inat ion dat abase.
• COMPATIBLE paramet er must be set t o 11. 1 or higher.
• BFI LES and ext ernal t ables are not encrypt ed.
• Logically, encrypt ed t ablespace is less ef f icient t han normal un- encrypt ed t ablespace.

Caut i on Losing t he mast er key or t he wallet f ile will lead t o losing t he dat a in t he encrypt ed t ablespace.
Always include t he wallet f ile in your backup plan and save t he mast er key password in saf e place.
Set t i n g u p TDE
As wit h Oracle 10g, you can perf orm t he f ollowing st eps t o set up TDE:
Add t he f ollowing t o t he sqlnet.ora f ile:
ENCRYPTION_WALLET_LOCATION =
(SOURCE=
(METHOD=file)
(METHOD_DATA=
(DIRECTORY=C:\oracle\OraDb10g\admin\ora10g\wallet)))
Set t he mast er key. This is done only on ce:
ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY <password>;
Open i n g an d Cl osi n g t h e Wal l et
I f you rest art t he inst ance, t he Wallet must be opened using t he f ollowing command:
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY password>;
ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;
To verif y t hat a wallet is open, you can query t he V$ENCRYPTION_WALLET view:
select WRL_PARAMETER, STATUS from V$ENCRYPTION_WALLET;
Page 80 Oracle 11g New Features for Administrators - Summary Sheets

En cr y pt i n g a Tabl espace
The t ablespace creat ion st at ement f or an encrypt ed t ablespace has t he f ollowing synt ax:
CREATE TABLESPACE <tbsp_name> ...
[ENCRYPTION [USING <ALGORITHM>]] -- specify encryption algorithm
DEFAULT STORAGE(ENCRYPT) -- encrypt objects in the tablespace
The ALGORITHM clause accept s one of t he f ollowing values:
o AES192 Advanced Encrypt ion St andard ( t he def ault ) .
o 3DES168 Triple Dat a Encrypt ion St andard 168- bit encrypt ion
o AES128 Advanced Encrypt ion St andard 128- bit encrypt ion
o AES256 Advanced Encrypt ion St andard 256- bit encrypt ion
To know whet her an exist ing t ablespace is encrypt ed or not , issue t he f ollowing query:
select vt.NAME, vet.ENCRYPTIONALG, vet.ENCRYPTEDTS
from V$ENCRYPTED_TABLESPACES vet, V$TABLESPACE vt
where vet.TS#=vt.TS#

Fi ne- Gr ai ned Access Cont r ol f or UTL_* Pack ages
Oracle Dat abase 11g provides a mechanism t o ref ine t he level of access t o t he net work access packages
UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, and UTL_INADDR. You can use t he DBMS_NETWORK_ACL_ADMIN
package t o f acilit at e management of t he UTL_* net work access packages as in t he f ollowing st eps:
1) Creat e an Access Cont rol List ( ACL) : All ACL def init ions are st ored in XML DB in t he f orm of XML document s.
The ACL XML f iles reside in t he /sys/acls direct ory of t he XML DB reposit ory. Following is an example of
using t he CREATE_ACL procedure t o creat e an XML f ile called dba.xml:
begin
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
ACL => 'dba.xml', -- case sensitive
DESCRIPTION=> 'Network Access Control for the DBAs',
PRINCIPAL => 'SCOTT', -- user or role the privilege is granted or denied (upper case)
IS_GRANT => TRUE, -- privilege is granted or denied
PRIVILEGE => 'connect', -- or 'resolve' (case sensitive)
START_DATE => null, -- when the access control entity ACE will be valid
END_DATE => null); -- ACE expiration date (TIMESTAMP WITH TIMEZONE format)
end;
Regarding t he PRIVILEGE paramet er, t he dat abase user needs t he connect privilege t o an ext ernal net work host
comput er if he or she is connect ing using t he UTL_TCP, UTL_HTTP, UTL_SMTP, and UTL_MAIL ut ilit y packages. To
resolve a host name t hat was given as a host I P address, or t he I P address t hat was given as a host name, wit h
t he UTL_INADDR package, grant t he dat abase user t he resolve privilege.
You can t hen query t he RESOURCE_VIEW view t o f ind t he dba.xml ACL in t he /sys/acls direct ory:
select ANY_PATH
from RESOURCE_VIEW
where ANY_PATH LIKE '/sys/acls/dba%'
Too may ent ries in t he ACL may lead t o signif icant XML DB perf ormance drop because ACL are checked f or each
access t o Oracle XML DB reposit ory. As general rule of t humb, ACL check operat ions perf orm best when t he
number of ACEs in t he ACL is at 16 ent ries or less.
2) Add Access Cont rol Ent ries: Once you creat e t he init ial ACL, you can cont inue t o add more privileges t o t he
XML f ile. The f ollowing example will add t he user RAMI t o t he dba.xml f ile and grant him net work access:
begin
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE (
ACL => 'dba.xml',
PRINCIPAL => 'RAMI',
IS_GRANT => TRUE,
PRIVILEGE => 'connect',
START_DATE => null, -- if the time interval is defined,
END_DATE => null); -- the ACE will expire after the specified date range
end;
COMMIT;
Page 81 Oracle 11g New Features for Administrators - Summary Sheets

I n ACL, t he securit y ent ries are evaluat ing in order precedence. I f you have t wo cont radict ing ent ries in t he list ,
t he f irst one in t he order will t ake ef f ect . You can cont rol t he order number of an added ent ry as f ollows:
begin
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE (
POSITION => 1, -- on the top
ACL => 'dba.xml', PRINCIPAL => 'SAMI',
IS_GRANT => FALSE, PRIVILEGE => 'connect',
START_DATE => null, END_DATE => null);
end;
3) Assign Host s: The ASSIGN_ACL procedure is used t o aut horize access t o one or more net work host s as
f ollows:
begin
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
ACL => 'dba.xml', HOST => 'dbaexpert.com',
LOWER_PORT => 80, UPPER_PORT => 443);
end;
COMMIT;
The lower port and t he upper port def ine t he lower and t he upper boundaries of t he allowable port range. They
should be set f or connect privileges not resolve privileges.
4) Validat e t hat t he ACL permissions worked accordingly. Following is an example t o t est t he code in t he
previous st ep.
select UTL_HTTP.REQUEST('http://www.ahmedbaraka.com') from dual;
I f t he suf f icient ACL privileges or ACL assignment s are not provided, you will receive t he ORA- 24247 error.
Access Con t r ol Li st s Mai n t en an ce
Use DELETE_PRIVILEGE t o remove an access cont rol ent ry f rom t he XML f ile.
exec DBMS_NETWORK_ACL_ADMIN.DELETE_PRIVILEGE( ACL=>'dba.xml', PRINCIPAL=> 'RAMI');
Use t he DROP_ACL procedure t o remove t he XML f ile f rom t he /sys/acls direct ory as f ollows:
exec DBMS_NETWORK_ACL_ADMIN.DROP_ACL ( ACL=>'dba.xml' );
Qu er y You r Access Con t r ol Li st
To display list of t he ACLs creat ed in t he dat abase, use t he f ollowing query:
select HOST, LOWER_PORT, UPPER_PORT, ACL from DBA_NETWORK_ACLS
You can query t he DBA_NETWORK_ACL_PRIVILEGES view t o query net work privileges grant ed or denied f or t he
access cont rol list as f ollows:
select PRINCIPAL, PRIVILEGE, IS_GRANT
from DBA_NETWORK_ACL_PRIVILEGES
where ACL like '%dba.xml'
Logged on users can use t he f ollowing query t o see t heir access ent ries in t he dba.xml f ile:
select HOST, LOWER_PORT, UPPER_PORT, STATUS privilege
from USER_NETWORK_ACL_PRIVILEGES
where HOST in
(select * from
table(DBMS_NETWORK_ACL_UTILITY.DOMAINS('dbaexpert.com')))
and PRIVILEGE = 'connect'
order by DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(host) desc, LOWER_PORT;

Fur t her Secur i t y New Feat ur es
New SYSASM Pr i vi l ege f or ASM Admi n i st r at i on
SYSASM is a new privilege int roduced in Oracle 11g. Users who are grant ed t his privilege can perf orm ASM
administ rat ion t asks. The idea behind t his privilege is t o separat e dat abase management and t he st orage
Page 82 Oracle 11g New Features for Administrators - Summary Sheets

management responsibilit ies. For f urt her det ails about using t his privilege, ref er t o t he chapt er "Aut omat ic
St orage Management ".
Dat a Pu mp En cr ypt i on
Oracle Dat abase 11g int roduces t he encrypt ion of Dat a Pump dump f iles. For det ails of all t he new enhancement s
relat ed t o Dat a Pump, ref er t o t he chapt er "Dat a Pump".
RMAN Vi r t u al Pr i vat e Cat al og
I n Oracle Dat abase 11g, you can rest rict access t o t he recovery cat alog by grant ing access t o only a subset of
t he met adat a in t he recovery cat alog. For complet e det ails on RMAN virt ual privat e cat alogs, ref er t o t he sect ion
"Virt ual Privat e Cat alogs".
Page 83 Oracle 11g New Features for Administrators - Summary Sheets

Back up and Recover y New Feat ur es
Enhanced Bl ock Medi a Recov er y

I n Oracle Dat abase 11g, t here is a new command t o perf orm block media recovery, named t he recover ...
block command replacing t he old blockrecover command. The new command is more ef f icient since because it
searches t he f lashback logs f or older uncorrupt ed versions of t he corrupt blocks. This requires t he dat abase t o
work in archivelog mode and has t he Dat abase Flashback enabled.
While t he block media recovery is going on, any at t empt by users t o access dat a in t he corrupt blocks will result
in an error message, t elling t he user t hat t he dat a block is corrupt .
Following are examples of using t he new command:
RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10;
RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10 FROM TAG = sundaynight;
RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10 FROM BACKUPSET = 11;
-- to fix all corrupted blocks in the database
-- after validate database, corrupted blocks are reported in V$DATABASE_BLOCK_CORRUPTION
RMAN> VALIDATE DATABASE;
RMAN> RECOVER CORRUPTION LIST;

RMAN Subst i t ut i on Var i abl es
You can now use subst it ut ion variables in RMAN command f iles, which you can t hen incorporat e in shell script s.
RMAN command line now has a new keyword, t hat is USING, which is used t o pass subst it ut ion variables t o t he
command line. Following are examples on how t o do t hat .
Following are t he st eps t o creat e dynamic shell script t hat accept s subst it ut ion variables in a Unix plat f orm:
1. Creat e an RMAN command f ile t hat uses subst it ut ion variables. Following is an example:
# quarterly_backup.cmd
CONNECT TARGET /
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=&1)';
BACKUP DATABASE TAG &2 FORMAT '/disk2/bck/&1%U.bck' KEEP FOREVER
RESTORE POINT &3;
}
EXIT;
2. Creat e a shell script t hat you can use t o run t he RMAN command f ile creat ed in t he previous st ep. Following
is an example:
#!/bin/tcsh
# name: runbackup.sh
# usage: use the tag name and number of copies as arguments
set media_family = $argv[1]
set format = $argv[2]
set restore_point = $argv[3]
rman @'/u01/scripts/quarterly_backup.cmd' USING $media_family $format $restore_point
3. Run t he shell script and pass t he values t o t he subst it ut ion variables. Following is an example:
%runbackup.sh archival_backup bck0906 FY06Q3
Page 84 Oracle 11g New Features for Administrators - Summary Sheets

Following is an example of achieving t he same concept st eps but in Windows plat f orm:
-- RMAN command file hr_backup.cmd
CONNECT TARGET /
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
BACKUP DATAFILE 'c:\oracle\oradata\ora11g\HR_TBS1.DBF'
TAG &1 FORMAT 'c:\orabackup\&1%U.bck';
SQL 'CREATE RESTORE POINT &2';}
EXIT;

-- Batch file hr_backup.bat
rman @'C:\orabackup\scripts\hr_backup.cmd' USING %1 %2

--- run the batch file
hr_backup.bat HR01MAR08 RS_HR01MAR08

New RMAN Conf i gur at i on Par amet er s
The COMPRESSION ALGORITHM and ARCHIVELOG DELETION POLICY paramet ers are new RMAN conf igurat ion
paramet ers in t he Oracle Dat abase 11g.
The OMPRESSION ALGORITHM paramet er set s t he compression algorit hm used by RMAN f or compressing a
backup. I t s possible values are t he f ollowing:
consumes more CPU resour ce t han ZLI B, but will usually produce more compact backups.

ZLIB
I t is opt imized f or CPU ef f iciency. I t requires t he Oracle Advanced Compression opt ion.
The ARCHIVELOG DELETION POLICY paramet er will be discussed in Conf iguring an Archived Redo Log Delet ion
Policy sect ion.
The Mul t i sect i on Back ups
Oracle 11g let s you back up and rest ore a large f ile in sect ions. I n a mult isect ion backup, each RMAN channel
backs up a dif f erent sect ion of a dat af ile. You can have up t o 256 sect ions per dat af ile.
This leads t o t he f ollowing benef it s:
o Backup perf ormance of a large f ile is signif icant ly enhanced by allocat ing mult iple channels t o backup t he
dat af ile.
o I f a backup process f ailed, only t hose sect ions t hat were not backed up prior t o t he backup f ailure are
required t o backup.
o I f you have a dat af ile of a size larger t han t he maximum size of your st orage medium unit ( f or example t he
t ape) , you can backup t he dat af ile int o sect ions wit h each sect ion of a size equals t o t he size of your st orage
unit .
Use t he new backup command clause SECTION SIZE t o perf orm mult isect ion backups as f ollows:
run
{ allocate channel c1 device type disk ;
allocate channel c2 device type disk ;
allocate channel c3 device type disk ;
backup SECTION SIZE 500m tablespace example; } -- three channels operate in parallel
The example above shows how t o use t he mult isect i on backup in a block. I f t he backup command was execut ed
in command- line, t he out put backupset will have backup pi eces of si ze 500 MB each. No parallelism, however,
will t ake place, if it was not conf igured in RMAN.
The V$BACKUP_DATAFILE and RC_BACKUP_DATAFILE views have t he new column SECTION_SIZE. This column
specif ies t he number of blocks in each sect ion of a mult i sect i on backup and it s value is 0 f or whole f ile backups.
select PIECE#, SECTION_SIZE from V$BACKUP_DATAFILE;

Page 85 Oracle 11g New Features for Administrators - Summary Sheets

Cr eat i ng Ar chi v al Back ups
BZIP2
The BACKUP ... KEEP command can be used t o creat e a backup t hat is bot h all- inclusive and exempt f rom t he
backup ret ent ion policy. The backup is all- inclusive because every f ile needed ( including archived redo logs) t o
rest ore and recover t he dat abase is backed up t o a single disk or t ape locat ion f or long- t erm st orage. The
general name f or a backup creat ed wit h BACKUP ... KEEP is an archival backup.
I n Oracle 11g, some modif icat ions made on t he RMAN BACKUP ... KEEP command. I n t he new version of t he
command, t he KEEP, NOKEEP, FOREVER, and UNTIL TIME opt ions are ret ained. However, t he LOGS and NOLOGS
opt ions are not t here any longer. I nst ead, you have a new opt ion, RESTORE POINT. The RESTORE POINT opt ion
let s RMAN aut omat ically creat e a normal rest ore point .
The f ollowing examples illust rat e how t o use t he command:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=archival_backup)';
-- with forever option (recovery catalog is required)
BACKUP DATABASE TAG BAKQ108 KEEP FOREVER RESTORE POINT FY08Q1;
-- backup will be kept for 365 days (long-term)
BACKUP DATABASE TAG BAKQ108 KEEP UNTIL TIME 'SYSDATE+365' RESTORE POINT FY08Q1;
-- After one day, the backup becomes obsolete,
-- regardless the configured retention policy
BACKUP DATABASE FORMAT '/u01/oraclebck/%U.bck'
TAG TESTDB KEEP UNTIL 'SYSDATE+1' RESTORE POINT TESTDB08;
}

Not e You can’t use t he KEEP clause f or backup f iles in t he f lash recovery area. Also, you cannot use t he
CHANGE ... KEEP command f or backup f iles st ored in t he f lash recovery area.
I f you want t o change t he st at us of a regular backup t o an archival backup, use t he CHANGE command as f ollows:
CHANGE BACKUP TAG 'weekly_bkp' KEEP FOREVER;
-- make it follow back the retention policy
CHANGE BACKUP TAG 'weekly_bkp' NOKEEP;
Rest or i n g an Ar ch i val Back u p
The procedure f or rest oring t he archival backup is t he same as f or duplicat ing a dat abase except in t he
DUPLICATE command you must specif y t he rest ore point t hat was creat ed wit h t he archival backup. Det ails about
how t o achieve t hat is explained in t he document at ion "Oracle Dat abase Backup and Recovery User' s Guide 11g
Release 1 ( 11. 1) B28270- 0 ", sect ion "Using DUPLICATE t o Rest ore an Archival Backup", page 23- 21. 2
VALI DATE Command
You can use t he new command VALIDATE t o manually check f or physical and logical corrupt ions in dat af iles,
backup set s, and even individual dat a blocks. The command by def ault checks f or physical corrupt ion. You can
opt ionally specif y CHECK LOGICAL. Corrupt ed blocks are report ed in V$DATABASE_BLOCK_CORRUPTION.
Following are examples of some VALI DATE command opt ions:
validate [CHECK LOGICAL] database;
validate SKIP INACCESSIBLE database;
validate copy of database;
validate tablespace hr_tbs;
validate copy of tablespace hr_tbs;
validate backupset 17,18;
validate datafile 3 block 24;
-- validates recovery files created in the current and all previous flash recovery area
-- destinations
validate recovery area;

Not e The VALIDATE command checks only f or int rablock corrupt i on bot h physical and l ogical in nat ure. I t
doesn’t check f or int erblock cor rupt ion.
Page 86 Oracle 11g New Features for Administrators - Summary Sheets


Validat ing large dat af iles can be speeded up by split t ing t he checked f iles int o sect ions and t hose sect ions are
checked in parallel. Following is an example on how t o do t hat :
run
{ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;
VALIDATE DATAFILE 3 SECTION SIZE = 500M;}

Conf i gur i ng an Ar chi v ed Redo Log Del et i on Pol i cy
You can use RMAN t o creat e a persist ent conf igurat ion t hat cont rols when archived redo logs are eligible f or
delet ion f rom disk or t ape. This delet ion policy applies t o all archiving dest inat ions, including t he f lash recovery
area. When t he policy is conf igured, it applies on t he aut omat ic delet ion of t he logs in t he f lash recovery area
and t he manual delet ion by t he BACKUP ... DELETE and DELETE ... ARCHIVELOG commands.
To enable an archived redo log delet ion policy, run t he CONFIGURE ARCHIVELOG DELETION POLICY BACKED UP n
TIMES command wit h t he desired opt ions. Following are examples:
-- archived redo logs are eligible for deletion when there are at least two backups of
-- them on the tape
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO SBT;
-- disable the policy
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;

Caut i on The BACKUP ARCHIVELOG command is af f ect ed by t he archived log delet ion policy. I f t he delet ion
policy is conf igured wit h t he BACKED UP n TIMES clause, t hen a BACKUP ARCHIVELOG command
copies t he logs unless n backups already exist on t he specif ied device t ype. I f n backups of t he logs
exist , t hen t he BACKUP ARCHIVELOG command skips t he logs.
You can, however, override t he archived redo log delet ion policy you conf igured by specif ying t he
FORCE clause in t he BACKUP ARCHIVELOG command.

Not e DELETE OBSOLETE considers only t he backup ret ent ion policy and does not use t he conf igured
archived log delet ion policy t o det ermine which logs are obsolet e. I n cont rast , DELETE ARCHIVELOG
ALL considers only t he conf igured archived log delet ion policy.

Act i v e Dat abase Dupl i cat i on
I n Oracle Dat abase 11g, you can direct ly duplicat e a dat abase over t he net work wit hout having t o back up and
provide t he source dat abase f iles. This direct dat abase duplicat ion is called act ive dat abase duplicat ion. I t can be
done eit her wit h Dat abase Cont rol or t hrough RMAN. I nst ance t hat runs t he duplicat ed dat abase is called
auxiliary inst ance.
Pr er equ i si t es
• Bot h t he t arget and dest inat ion dat abases must be on an ident ical operat ing syst em plat f orm.
• Oracle Net must be aware of bot h t he t arget and duplicat e inst ances.
• The password f ile must exist f or t he source dat abase and bot h t he t arget and dest inat ion dat abases must
have t he same SYS password.
• The t arget dat abase must be open or in mount st at e.
• I f t he t arget dat abase is open, it must be in ARCHI VELOG mode.
I mplement ing act ive dat abase duplicat ion includes t he f ollowing st eps:
1. Decide on Duplicat e File Names
I f you are duplicat ing t o a dif f erent host t hat uses t he same direct ory st ruct ure as t he source host , and if you
want t o name t he duplicat e f iles t he same as t he source dat abase f iles, t hen skip t o t he next st ep.
1. 1 Decide on what are t he names of t he duplicat e f iles on t he dest inat ion server. Duplicat e f iles include:
cont rol f iles, dat af iles, online redo logs, and t empf iles. When you issue t he DUPLICATE command lat er,
you will use it s opt ions t o implement t he new names.
Page 87 Oracle 11g New Features for Administrators - Summary Sheets

2. Prepare t he Auxiliary I nst ance
2. 1 Creat e a password f ile in t he dest inat ion server wit h t he same SYSDBA password as t he source dat abase.
You can creat e t he password f ile manually or by specif ying t he PASSWORD FILE opt ion on t he DUPLICATE
command.
-- use PASSWORD FILE option
RMAN>DUPLICATE TARGET DATABASE ... PASSWORD FILE ...
-- manually
#orapwd FILE=PWDora11g2.ora PASSWORD=mypassword ENTRIES=10 ignorecase=n
2. 2 Est ablish Oracle Net connect ivit y t o t he auxiliary inst ance in bot h t he sour ce and dest inat ion servers.
Also add t he auxiliary dat abase service t o t he list ener configurat ion f ile in t he source server. Following ar e
examples of a conf igurat ion in tnsnames.ora and listener.ora f iles:
dup1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = 192.168.255.32)
(Port = 1521)
)
)
(CONNECT_DATA = (SID =dup1) (SERVER = DEDICATED)
)
)
SID_LIST_LISTENER =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/10g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = dup1)
(ORACLE_HOME = /u01/app/oracle/product/10g/)
(SID_NAME =dup1)
)
)
2. 3 I ncluding SPFILE opt ion in t he DUPLICATE command will make RMAN copy t he SPFILE f rom t he source
server t o t he dest inat ion. I n t his case, you need t o creat e a t ext - based init ializat ion paramet er f ile f or t he
auxiliary inst ance t hat cont ains only one paramet er: DB_NAME which can be set t o an arbit rary value.
#contents of the init.ora in the destination
DB_NAME=dup1
2. 4 Use SQL* Plus t o connect t o t he auxiliary dat abase inst ance wit h SYSOPER privileges. St art t he inst ance in
NOMOUNT mode, specif ying t he PFILE paramet er:
SQL>conn sys/mypassword@dup1 as sysoper
SQL>STARTUP NOMOUNT pfile=c:\..\pfile.init
3. St art and Conf igure RMAN Bef ore Duplicat ion
3. 1. St art RMAN and connect t o t he source dat abase as TARGET, t he duplicat e dat abase inst ance as
AUXI LI ARY, and, if applicable, t he recovery cat alog dat abase.
RMAN>CONNECT TARGET SYS@prod # source database
RMAN>CONNECT AUXILIARY SYS@dupdb # duplicate database instance
RMAN>CONNECT CATALOG rman@catdb # recovery catalog database
3. 2. You may want t o increase t he parallelism set t ing of your source dat abase disk channels so t hat RMAN
copies f iles over t he net work in parallel.
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
Page 88 Oracle 11g New Features for Administrators - Summary Sheets

4. Run t he DUPLICATE command
Following are t he opt ions t o issue t he DUPLICATE command in t he RMAN session. Af t er t he duplicat ion is f inished,
RMAN will rest art t he inst ance wit h RESETLOGS.
-- duplicating a database to a remote host with the same directory structure
DUPLICATE TARGET DATABASE
TO dupdb
PASSWORD FILE -- RMAN should duplicate the password file from the source
FROM ACTIVE DATABASE
SPFILE
NOFILENAMECHECK;

-- if you want to recover the duplicate database to one week ago
DUPLICATE TARGET DATABASE
TO dupdb
PASSWORD FILE
SPFILE
NOFILENAMECHECK
UNTIL TIME 'SYSDATE-7';

-- duplicating a database to a remote host with a different directory structure
DUPLICATE TARGET DATABASE TO dupdb
FROM ACTIVE DATABASE
DB_FILE_NAME_CONVERT '/oracle/oradata/prod/','/scratch/oracle/oradata/dupdb/'
SPFILE
PARAMETER_VALUE_CONVERT '/oracle/oradata/prod/', '/scratch/oracle/oradata/dupdb/'
SET SGA_MAX_SIZE '300M'
SET SGA_TARGET '250M'
SET LOG_FILE_NAME_CONVERT '/oracle/oradata/prod/redo/',
'/scratch/oracle/oradata/dupdb/redo/';


I mpor t i ng and Mov i ng Recov er y Cat al ogs
You can use t he IMPORT CATALOG command in RMAN t o merge one recovery cat alog schema int o anot her.
Pr er equ i si t es f or I mpor t i n g a Recover y Cat al og
I f a dat abase is current ly regist ered in bot h t he source and dest inat ion cat alog schemas, t hen unregist er t he
dat abase f rom source cat alog schema bef ore perf orming t he import .
connect target sys/mypassword@db1 catalog rman/rman@dest
UNREGISTER DATABASE;
When using IMPORT CATALOG, t he version of t he source recovery cat alog schema must be equal t o t he current
version of t he RMAN execut able wit h which you run t he command. I f t he source cat alog schema is a lower
version, t hen upgrade it t o t he current version bef ore import ing t he schema.
# to determine the schema version of the recovery catalog
# start SQL*Plus and connect to the recovery catalog database as the catalog owner
SQL>conn rman/ramn@mydb
#the highest version in the RCVER table is the current catalog schema version
SQL>SELECT * FROM rcver;
# to upgrade a recovery catalog schema to the current RMAN version
# make sure the CREATE TYPE privilege is granted to the RECOVERY_CATALOG_OWNER role
SQL>SELECT PRIVILEGE
FROM ROLE_SYS_PRIVS
WHERE ROLE='RECOVERY_CATALOG_OWNER' AND PRIVILEGE = 'CREATE TYPE';
GRANT CREATE TYPE TO rman;
# start RMAN and connect to the recovery catalog database
RMAN catalog rman/rman@mydb
# upgrade the catalog (run the command twice to confirm)
RMAN>UPGRADE CATALOG;
RMAN>UPGRADE CATALOG;
Page 89 Oracle 11g New Features for Administrators - Summary Sheets

I mpor t i n g a Recover y Cat al og
Following are examples of using t he IMPORT CATALOG command:
#connect to the destination recovery catalog
RMAN>connect catalog rman/rman@dest

#Issue the import catalog command
# all RMAN repository metadata is imported from src to dest
RMAN>IMPORT CATALOG rman1/rman1@src;
# in the source, you will notice all databases are unregistered from RMAN repository
RMAN>LIST INCARNATION;
RMAM>connect target rman1/rman1@src;
RMAN>LIST INCARNATION;

# to import from source without the automatice databases unregistration
RMAN>IMPORT CATALOG rman1/rman1@src NO UNREGISTER;

# to import metadata of specific databases
RMAN>IMPORT CATALOG rman1/rman1@src DBID = 123456, 123457;
RMAN>IMPORT CATALOG rman1/rman1@src DB_NAME = mydb1, mydb2;

Not e I f you have global st ored script s in t he bot h recovery cat alogs wit h ident ical names, RMAN
aut omat i cally renames t he script s f rom t he source recovery cat alog ( t he f ormat f or t he renamed f iles
is COPY OF Script_Name) .
Movi n g a Recover y Cat al og t o An ot h er Dat abase
By f ollowing t he same st eps of using t he IMPORT CATALOGE t o import a recovery cat alog schema, you can also
move a cat alog schema f rom one dat abase ( source) t o anot her ( dest inat ion) . Only make sure t he dest inat ion has
a new recovery cat alog wit hout any dat abase regist ered in it .
Vi r t ual Pr i v at e Cat al ogs
I n Oracle Dat abase 11g, you can rest rict access t o t he recovery cat alog by grant ing access t o only a subset of t he
met adat a in t he recovery cat alog. The subset t hat a user has read/ writ e access t o is t ermed as virt ual privat e
cat alog, or j ust virt ual cat alog. The cent ral or source recovery cat alog is now called t he base recovery cat alog.
Following are t he st eps t o creat e a new privat e cat alog f or t he dat abase user SCOTT:
# grant the role RECOVERY_CATALOG_OWNER to the user
SQL>GRANT RECOVERY_CATALOG_OWNER TO scott;
# in RMAN session, connect as the base catalog owner
RMAN>CONNECT CATALOG rman/rman@mydb
RMAN>GRANT CATALOG FOR DATABASE db1, db2 TO SCOTT;
# connect as the granted user (virtual catalog onwer) and create the virtual catalog
RMAN>CONNECT CATALOG scott/lion@mydb
RMAN>CREATE VIRTUAL CATALOG;
# make sure only granted dbs are seen
RMAN>LIST INCARNATION;
I f t he cat alog is t o be used f or releases pre- Oracle 11g client s, in t he SQL* Plus log on as t he virt ual privat e
cat alog owner and run t he f ollowing procedure, where "rman" is t he name of t he base cat alog owner:
SQL> CONN scott/lion@mydb
SQL> EXEC rman.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG;

Not e A virt ual privat e cat alog owner can creat e a l ocal st ored script , but has only read- only access t o
global script s.
The CATALOG FOR DATABASE privileges include t he privilege t o regist er and unregist er t hose
dat abases f or which t he cat alog f or dat abase privilege was grant ed.
The set of views and synonyms t hat makes up t he virt ual privat e cat alog is st ored in t he schema of
t he virt ual cat alog owner.
Page 90 Oracle 11g New Features for Administrators - Summary Sheets

Man agi n g Vi r t u al Pr i vat e Cat al ogs
The base recovery cat alog owner can opt ionally grant a virt ual cat alog owner t he right t o regist er new t arget
dat abases in t he recovery cat alog by specif ying t he REGISTER dat abase clause wit h t he GRANT command.
Following is an example:
RMAN> grant register database to scott;
The virt ual cat alog owner must have t he SYSDBA and SYSOPER privileges on t he t raget dat abase, t o perf orm
most of t he RMAN operat ions on it .
Following are examples of removing t he privileges f rom a virt ual cat alog owner:
# To remove recovery catalog access to a database from a user:
RMAN>CONNECT CATALOG RMAN/RMAN@MYDB;
RMAN>REVOKE CATALOG FOR DATABASE db1 FROM scott;
# To revoke the ability to register new databases from a virtual private catalog owner:
RMAN>REVOKE REGISTER DATABASE FROM scott;
# To revoke both the catalog and register privileges from a user:
RMAN>REVOKE ALL PRIVILEGES FROM scott;
Dr oppi n g a Vi r t u al Pr i vat e Cat al og
Virt ual privat e cat alog owners can drop t he privat e recovery cat alog t hey own by issuing t he DROP CATALOG
command. Following is an example:
# Log in as the virtual catalog owner:
RMAN>CONNECT CATALOG scott/<password>@mydb;
# Issue the drop catalog command
RMAN>DROP CATALOG;

Caut i on When t he DROP CATALOG command is issued by t he virt ual cat alog owner, all t he met adat a
pert aining t o it is delet ed f rom t he base recovery cat alog.


Mi scel l aneous New Feat ur es i n RMAN
Ar ch i ved Redo Log Fai l over
The archived redo log f ailover f eat ure enables RMAN t o complet e a backup even when some archiving
dest inat ions have missing logs or cont ain logs wit h corrupt blocks. The RMAN will search and use an alt ernat ive
dest inat ion.
Opt i mi zed Back i n g Up of Un do Dat a
I n Oracle Dat abase 11g, during a backup, t he commit t ed dat a is not backed up, t hus leading t o a saving of
st orage space as well as f ast er backups f or large OLTP- t ype dat abases. Since t he new opt imized undo backup is
aut omat ically enabled, you do not have t o conf igure anyt hing special t o t ake advant age of t his f eat ure.

Page 91 Oracle 11g New Features for Administrators - Summary Sheets

Dat a Pump Ut i l i t i es
Compr essi on Enhancement

I n Oracle Dat abase 11g, Oracle provides t he mechanism t o compress bot h dat a and met adat a during t he ext ract
operat ion. The available opt ions f or t he COMPRESSION paramet er are as f ollows:
compression={all | data_only | metadata_only | none}
Following is an example:
$expdp full=yes userid="'/ as sysdba'" dumpfile=dbadir:full.compress.dmp compression=all

Encr y pt i on Enhancement s
To secure t he export ed dump f ile, t he f ollowing new paramet ers are present ed in Oracle 11g Dat a pump:
ENCRYPTION, ENCRYPTION_PASSWORD and ENCRYPTION_ALGORITHM. To enable encrypt ion, you must specif y eit her
t he ENCRYPTION or ENCRYPTION_PASSWORD paramet er, or bot h. Those paramet ers are valid only in t he Ent erprise
Edit ion of Oracle Dat abase 11g.
ENCRYPTI ON Par amet er
This paramet er specif ies whet her or not t o encrypt dat a bef ore writ ing it t o t he dump f ile set .
The def ault value depends upon t he combinat ion of encr ypt ion- relat ed paramet ers t hat are used. I f only t he
ENCRYPTION_PASSWORD paramet er is specif ied, t hen t he ENCRYPTION paramet er def ault s t o ALL. I f neit her
ENCRYPTION nor ENCRYPTION_PASSWORD is specif ied, t hen ENCRYPTION def ault s t o NONE.
The ENCRYPTION paramet er has t he f ollowing opt ions:
ENCRYPTION = {all | data_only | encrypted_columns_only | metadata_only | none}
Following is an example:
expdp hr DUMPFILE=dp_dir.hr_enc.dmp JOB_NAME=enc ENCRYPTION=data_only
ENCRYPTION_PASSWORD=mypassword
ENCRYPTI ON_ALGORI THM Par amet er
This paramet er specif ies which crypt ographic algorit hm should be used t o perf orm t he encrypt ion. Following is it s
synt ax:
ENCRYPTION_ALGORITHM = { AES128 | AES192 | AES256 }
The ENCRYPTION_ALGORITHM paramet er requires t hat you also specif y eit her t he ENCRYPTION or
ENCRYPTION_PASSWORD paramet er.
Following is an example:
expdp hr DIRECTORY=dp_dir DUMPFILE=hr_enc.dmp /
ENCRYPTION_PASSWORD=mypassword ENCRYPTION_ALGORITHM=AES128
ENCRYPTI ON_MODE Par amet er
This paramet er works t he same way t he encrypt ion mode was operat ing in RMAN in Oracle 10g. I t specif ies t he
t ype of securit y t o use when encrypt ion and decrypt ion are perf ormed. I t synt ax is as f ollows
ENCRYPTION_MODE = { DUAL | PASSWORD | TRANSPARENT }
PASSWORD mode requires t hat you provide a password when creat ing encrypt ed dump f ile set s.
TRANSPARENT mode allows an encrypt ed dump f ile set t o be creat ed wit hout any int ervent ion f rom a dat abase
administ rat or ( DBA) , provided t he required Oracle Encrypt ion Wallet is available.
DUAL mode creat es a dump f ile set t hat can lat er be import ed eit her t ransparent ly or by specif ying a password
t hat was used when t he dual- mode encrypt ed dump f ile set was creat ed.
Following is an example:
expdp hr DIRECTORY=dp_dir DUMPFILE=hr_enc.dmp
ENCRYPTION=all ENCRYPTION_PASSWORD=mypassword
ENCRYPTION_ALGORITHM=AES256 ENCRYPTION_MODE=dual

Page 92 Oracle 11g New Features for Administrators - Summary Sheets

Reusi ng a Dump Fi l e
I n Oracle 11g dat a pump export ut ilit y, t he new paramet er REUSE_DUMPFI LES enables you t o overwrit e a
preexist ing dump f ile.
Following is an example:
expdp hr DIRECTORY=dp_dir DUMPFILE=hr.dmp TABLES=employees REUSE_DUMPFILES=y

Remappi ng Dat a
There is a new paramet er t hat allows you during export or import t o modif y t he input or out put dat a based on
your remapping scheme. The REMAP_DATA paramet er specif ies a remap f unct ion t hat t akes as a source t he
original value of t he designat ed column and ret urns a remapped value t hat will replace t he original value in t he
dump f ile. The synt ax of t he using t he paramet er is as f ollows:
REMAP_DATA=[schema.]tablename.column_name:[schema.]pkg.function
Following is an example of how t o use it .
-- function(s) used by the remap
Create or replace package remap_pckg
as
function modify_char ( p_in_data varchar2) return varchar2;
end;
/

Create or replace package body remap_pckg
as
function modify_char (p_in_data varchar2) return varchar2
as
v_return varchar2(30);
begin
v_return:=translate(p_in_data,'abcdefghijklmnopqrstuvwxyz','bcdefghijklmnopqrstuvwxyza');
return v_return;
end;
end;
/

expdp hr/passwd DIRECTORY=dp_dir DUMPFILE=remap.dmp
TABLES=hr.employees REMAP_DATA=hr.employees.last_name:hr.remap_pckg.modifychar
Remap f unct ion should not issue any COMMIT or ROLLBACK st at ement s.
Renami ng Tabl es Dur i ng Ex por t or I mpor t
I n Oracle 11g, t he Dat a Pump allows you t o rename a t able during t he import process wit h t he REMAP_TABLE
paramet er. Synt ax of t his paramet er is as f ollows:
REMAP_TABLE=[schema.]old_tablename[.partition]:new_tablename
Following are examples of using t his paramet er
impdp dumpfile=dp_dir:docs.dmp REMAP_TABLE=hr.docs:docs2 userid=hr/password
impdp dumpfile=dp_dir:docs.dmp REMAP_TABLE=hr.docs.part1:docs3 userid=hr/password

Not e Tables wil l not be remapped if t hey already exist even if t he TABLE_EXISTS_ACTION i s set t o
TRUNCATE or APPEND.

Dat a Pump and Par t i t i oned Tabl es
The new paramet er PARTITION_OPTIONS specif ies how t able part it ions should be creat ed during an import
operat ion. This paramet er t akes one of t he f ollowing values:
NONE creat es t ables as t hey exist ed on t he syst em f rom which t he export operat ion was
perf ormed.
Page 93 Oracle 11g New Features for Administrators - Summary Sheets

DEPARTITION promot es each part it ion or subpart it ion t o a new individual t able. The def ault name of t he
new t able will be t he concat enat ion of t he t able and part it ion name or t he t able and
subpart it ion name, as appropriat e.
MERGE combines all part it ions and subpart it ions int o one t able.
The def ault is DEPARTITION when part it ion names are specif ied on t he TABLES paramet er and
TRANPORTABLE=ALWAYS is set ( whet her on t he import operat ion or t he export ) . Ot herwise, t he def ault is NONE.
Rest r i ct i on s
• I f t he export operat ion t hat creat ed t he dump f ile was perf ormed wit h t he TRANSPORTABLE met hod and if
a part it ion or subpart it ion was specif ied, t hen t he import operat ion must use t he DEPARTITION opt ion.
• I f t he export operat ion t hat creat ed t he dump f ile was perf ormed wit h t he t ransport able met hod, t hen
t he import operat ion cannot use t he MERGE opt ion.
• I f t here are any grant s on obj ect s being depart it ioned, an error message is generat ed and t he obj ect s
are not loaded.
Following are examples of using t his new paramet er:
-- merge all the partitions in sh.sales into one non-partitioned table in scott schema.
impdp system/mypassword TABLES=sh.sales PARTITION_OPTIONS=merge DIRECTORY=dp_dir
DUMPFILE=sales.dmp REMAP_SCHEMA=sh:scott

-- unload the P_Q1Y08 partition of the sh.sales table with the TRANSPORTABLE=ALWAYS
expdp TABLES=sh.sales:p_q1y08 USERID=sh/sh DIRECTORY=dp_dir DUMPFILE=p_q1y08.dmp \
LOGFILE=logq1y08.log REUSE_DUMPFILES=Y TRANSPORTABLE=always

-- import the P_Q1Y08 partition of the sh.sales table
impdp USERID="'/ as sysdba'" PARTITION_OPTIONS=departition DUMPFILE=dp_dir:p_q1y08.dmp \
LOGFILE=logdir:logq1y08.log TRANSPORT_DATAFILES='+FRA/dba11g1/kb2.dbf'

I gnor i ng Nondef er r ed Const r ai nt s
I n Oracle 11g, set t ing t he DATA_OPTIONS paramet er t o SKIP_CONSTRAINT_ERRORS will cause t he import program
t o skip errors generat ed by t he nondef erred dat abase const raint s. I n t he case of def erred const raint s, import s
will always be rolled back.
impdp Robert/robert DIRECTORY=data_pump_dir DUMPFILE=remap.dmp tables=ROBERT.NAMES
data_options=SKIP_CONSTRAINT_ERRORS

Ex t er nal Tabl es Based on Dat a Pump Dr i v er
I n Oracle 11g, creat ing ext ernal t ables using ORACLE_DATAPUMP driver is enhanced.
You can t ake advant age of t he new COMPRESSION and ENCRYPTION ( required TDE enabled) opt ions.
create table docs organization external
( type ORACLE_DATAPUMP
default directory dbadir
access parameters
( logfile logdir:docs COMPRESSION ENABLED) -- you can add ENCRYPTION ENABLED
location ('docs.dmp') )
as select * from documents
Anot her improvement , a row error will not cause a t able load t o abort . I n Oracle Dat abase 10g, you needed t he
REJECT LIMIT clause t o do so.
Enhancement i n t he Tr anspor t abl e Par amet er
Wit h Oracle 11g, when you use t he TRANSPORTABLE paramet er in t he dat a pump import and export ut ilit ies, only
t he met adat a associat ed wit h specif ic t ables, part it ions, or subpart it ions will be ext ract ed, rat her t han all
met adat a. Ot her t han t hat , t he behavior of t he paramet er remains t he same as in t he previous version.
Page 94 Oracle 11g New Features for Administrators - Summary Sheets

Aut omat i c St or age Management ( ASM)
SYSASM Pr i v i l ege and OSASM Gr oup

This f eat ure int roduces a new SYSASM privilege t hat is specif ically int ended f or perf orming ASM administ rat ion
t asks. Using t he SYSASM privilege inst ead of t he SYSDBA privilege provides a clearer division of responsibilit y
bet ween ASM administ rat ion and dat abase administ rat ion.
Following are code examples illust rat ing how t o use t his privilege:
-- grant the privilege
GRANT SYSASM TO firas;

-- check the granted privilege
SELECT * FROM V$PWFILE_USERS;

-- ASM management commands are available to Adam
CONNECT firas/his_password
ALTER DISKGROUP dg1 DISMOUNT;
ALTER DISKGROUP dg2 MOUNT;
.. and so on.
Be aware t hat users wit h SYSOPER privilege have some ASM privileges. Following t able shows available and
rest rict ed ASM privilege f or users wit h SYSOPER privilege:
Av ai abl e ASM Pr i v i l ege Rest r i ct ed ASM Pr i v i l ege
STARTUP AND SHUTDOWN
ALTER DISKGROUP MOUNT
ALTER DISKGROUP DISMOUNT
ALTER DISKGROUP ONLINE DISK
ALTER DISKGROUP OFFLINE DISK
ALTER DISKGROUP REBALANCE
ALTER DISKGROUP CHECK
CREATE DISKGROUP / DISK
DROP DISKGROUPS / DISKS
ALTER DISKGROUP / DISK RESIZE

OSASM is a new operat ing syst em group t hat is used exclusively f or ASM. Members of t he OSASM group can
connect as SYSASM using operat ing syst em aut hent icat ion and have f ull access t o ASM.
Upgr adi n g ASM u si n g DBUA
Dat abase Updat e Assist ant ( DBUA) can be used t o upgrade t he ASM inst ance f rom Oracle Dat abase 10g t o
Oracle Dat abase 11g. To do t hat , perf orm t he f ollowing st eps:
1. Change t he direct ory t o t he new $ORACLE_HOME/bin and launch DBUA.
cd $ORACLE_HOME/bin
$ ./dbua
2. I n t he Upgrades Operat ions page, click t he Upgr ade Au t omat i c St or age Man agemen t I n st an ce radio
but t on, and click t he Nex t but t on.
3. I n t he summary page, conf irm t he source and t arget inf ormat ion, t hen click on Fi n i sh but t on.
4. When t he operat ion f inishes, a successf ul message should be displayed. The DBUA ut ilit y logs it s operat ion
in t he $ORACLE_BASE/cfgtoollogs/dbua/logs/ASMUpgrade.log.
Upgr adi n g ASM Man u al l y
Following are t he st eps you f ollow t o upgrade an exist ing Oracle 10g ASM t o 11g:
1. I nst all t he Oracle Dat abase 11g sof t ware t o a new ORACLE_HOME direct ory.
2. Updat e t he /etc/oratab or /var/opt/oracle/oratab f ile wit h t he new ASM ORACLE_HOME locat ion.
3. Copy t he ASM init ializat ion f ile f rom t he old ORACLE_HOME t o t he new one.
4. Edit any direct ory- based paramet ers ( such as diag and dump) in t he ASM init ializat ion f ile as required.
Page 95 Oracle 11g New Features for Administrators - Summary Sheets

5. I f you are upgrading a non- RAC ASM inst ance, you should reconf igure t he Oracle CSS using t he new
ORACLE_HOME. You can do t his by execut ing t he localconfig command f rom t he new home. Once t he
CSS conf igurat ion is complet e, you need t o change your ORACLE_HOME t o t he new Oracle version 11. 1
ORACLE_HOME and st art t he ASM inst ance.
cd $ORACLE_HOME/bin
# ./localconfig reset
6. I f you are upgrading a ASM inst ance in a RAC environment s, you can modif y t he new ASM home wit hin t he
OCR using t he srvctl ut ilit y as f ollows:
srvctl modify asm -n racnode1 -i +ASM1 -o /apps/oracle/product/11.1.0/asm -p
init+ASM1.ora
7. Grant t he SYSASM role t o t he SYS
GRANT SYSASM to sys;
8. I f you have obsolet e init ializat ion paramet ers, you can address t hem now. To get a list ing of all t he obsolet e
init ializat ion paramet ers, ref er t o t he ASM alert log f ile.
ASM Rest r i ct ed Mode
I n Oracle 11g, you can st art t he ASM inst ance in rest rict ed mode. When in rest rict ed mode, dat abases will not be
permit t ed t o access t he ASM inst ance. Also, individual diskgroup can be set in rest rict ed mode.
-- in the ASM instance level
SQL>STARTUP RESTRICT;
-- in the diskgroup level
SQL>ALTER DISKGROUP DATA MOUNT RESTRICTED;
-- check status of diskgroups
SQL>SELECT NAME,STATE FROM V$ASM_DISKGROUP;
ORA-15236 error will be ret urned, if t he dat abase t ries t o access an ASM inst ance st art ed in rest rict ed mode.
Di sk gr oup At t r i but es
Oracle Dat abase 11g int roduces a new concept called ASM at t ribut es at t he diskgroup level. The at t ribut es f or
t he diskgroup can be est ablished at creat e diskgroup t ime or can be modif ied using t he ALTER DISKGROUP
command lat er.
Following are t he at t ribut es you can set :
• Allocat ion unit ( AU) sizes.
• The compatible.rdbms at t ribut e.
• The compatible.asm at t ribut e.
• disk_repair_time in unit s of minut e ( M) or hour ( H) and is set by t he ALTER DISKGROUP command
• The redundancy at t ribut e f or a specif ic t emplat e.
• The st ripping at t ribut e f or a specif ic t emplat e.
All of t he diskgroup at t ribut es can be queried f rom t he V$ASM_ATTRIBUTE view.
Consider t he f ollowing examples:
CREATE DISKGROUP data
disk '/dev/raw/raw1',
...
attribute 'au_size' = '16M', 'compatible.asm' = '11.1';
ALTER DISKGROUP data SET ATTRIBUTE 'compatible.asm' = '11.1.0.0.0';
select NAME, VALUE from V$ASM_ATTRIBUTE where GROUP_NUMBER=1;
Page 96 Oracle 11g New Features for Administrators - Summary Sheets

Var i abl e AU Si zes
The def ault size of Allocat ion Unit ( AU) is 1 MB which is suf f icient f or most regular dat abases. However, when
you have dat abases wit h TB sizes, you will have enormous number of AUs. Wit h Oracle 11g, AU size can be
specif ied at diskgroup creat ion t ime t o 1, 2, 4, 8, 16, 32, or 64MB in size. You can check t he AU size t hrough t he
f ollowing query:
select NAME, ALLOCATION_UNIT_SIZE from V$ASM_DISKGROUP;
Compat i bi l i t y Set t i n gs
Compat ibilit y in ASM is cont rolled in t hree ways, as shown below:
COMPATIBLE
init ializat ion
paramet er

The compat ible init ializat ion paramet er can be set f or eit her ASM or t he dat abase inst ance.
I t t akes one of t he f ollowing values: 10. 1, 10. 2, or 11. 1.
Set t ing t he init ializat ion paramet er t o a lesser value t han t he sof t ware release will exclude
availabilit y of t he new f eat ures int roduced in t he new release.
RDBMS
Compat ibilit y
This is a diskgroup- level compat ibilit y and is specif ied by set t ing t he COMPATIBLE.RDBMS
at t ribut e. This at t ribut e det ermines t he minimum COMPATIBLE dat abase init ializat ion
paramet er set t ing f or any dat abase inst ance t hat uses t he disk group. I t s def ault value is
10. 1.
ASM
Compat ibilit y
This is a diskgroup- level compat ibilit y and is specif ied by set t ing t he COMPATIBLE.ASM
at t ribut e. I t det ermines t he minimum sof t ware version f or an ASM inst ance t hat uses t he
disk group.
I f you assign any of t he compat ibilit y set t ing t o a higher value, you cannot lat er reverse it t o a lower value.
Following are some queries t o obt ain inf ormat ion about t he compat ibilit y set t ings:
-- diskgroup compatibility setting
select NAME, BLOCK_SIZE, ALLOCATION_UNIT_SIZE AU_SIZE, STATE,
COMPATIBILITY ASM_COMP, DATABASE_COMPATIBILITY DB_COMP
from V$ASM_DISKGROUP;
-- Compatibility of the database clients that use the ASM
select DB_NAME, STATUS,SOFTWARE_VERSION,COMPATIBLE_VERSION from V$ASM_CLIENT;
ASM Fast Mi r r or Resyn c
Any problems t hat make a f ailure group t emporarily unavailable are considered t ransient f ailures t hat can be
recovered by t he ASM f ast mirror resync f eat ure. Disk pat h malf unct ions; such as cable f ailures, host bus
adapt er f ailures, cont roller f ailures, or disk power supply int errupt ions; can cause t ransient f ailures.
ASM f ast resync keeps t rack of pending changes t o ext ent s on an OFFLINE disk during an out age. The ext ent s
are resynced when t he disk is brought back online.
Following are t he st eps t o enable and handle t his f eat ure:
-- diskgroup compatibility must be set to 11.1
ALTER DISKGROUP dg1 SET ATTRIBUTE 'compatible.asm' = '11.1';
ALTER DISKGROUP dg1 SET ATTRIBUTE 'compatible.rdbms'='11.1';
-- specify the duration of the disk_repair_time (default is 3.6 hour)
ALTER DISKGROUP dg1 SET ATTRIBUTE 'disk_repair_time' = '5H'; -- in hours
ALTER DISKGROUP dg1 SET ATTRIBUTE 'disk_repair_time' = '40M'; -- minutes
-- verify the attribute settings
select NAME, VALUE from V$ASM_ATTRIBUTE;
-- if you get an offline disk because of a transient failure, you can see the
-- remaining time left in SECONDS before ASM drops an offline disk
select NAME, HEADER_STATUS, MOUNT_STATUS, MODE_STATUS, STATE, REPAIR_TIMER/60 from
V$ASM_DISK WHERE GROUP_NUMBER=1;
-- while the fix is in progress, if you want to reset the elapsed time, just take
-- the disk(s) offline
ALTER DISKGROUP dg1 OFFLINE DISK d3_0001;
ALTER DISKGROUP dg1 OFFLINE DISKS IN FAILGROUP f2;
-- you can also make a disk offline with a repair time different from its
-- disk_repair_time attribute
ALTER DISKGROUP dg1 OFFLINE DISK d3_0001 DROP AFTER 50m;
-- disks in a failure group (f2) can also be taken offline
ALTER DISKGROUP dg1 OFFLINE DISKS IN FAILGROUP f2 DROP AFTER 5m;
Page 97 Oracle 11g New Features for Administrators - Summary Sheets

-- if the disk needs to be dropped immediately and before the repair time has expired
-- Note: ALTER DISKGROUP DROP DISK will not work
ALTER DISKGROUP dg1 OFFLINE DISK D3_0001 DROP AFTER 0m;
-- after the disk(s) are fixed, you can bring them online
ALTER DISKGROUP dg1 ONLINE ALL;
ALTER DISKGROUP dg1 ONLINE DISK d3_0001;

Check i ng Di sk gr oup
St art ing f rom Oracle Dat abase 11g, you can validat e t he int ernal consist ency of ASM diskgroup met adat a using
t he ALTER DISKGROUP ... CHECK command. Summary of errors is logged in t he ASM alert log f ile.
-- check specific diskgroup with automatic repair
SQL>ALTER DISKGROUP data CHECK;
-- disable automatic repair
SQL>ALTER DISKGROUP data CHECK NOREPAIR;

Page 98 Oracle 11g New Features for Administrators - Summary Sheets

asmcmd Ut i l i t y Commands
Oracle 11g int roduces new commands in t he asmcmd ut ilit y and it also provides backward compat ibilit y wit h
Oracle Dat abase 10g ASM inst ances. Following are summary of some of t hem:
Comman d Sy n t ax Descr i pt i on an d Ex ampl es
lsct [-gH] [group]
List s inf ormat i on about current ASM client s.
>lsct dgroup1
lsdg [-gcH] [group] list s all diskgroups and t heir at t ribut es.
>lsdg dgroup2
lsdsk [-ksptagcHI] [-d
diskg_roup_name] [pattern]
list s t he disks t hat are visible t o ASM by scanning t he disk
headers of t he disks seen by t he value of t he ASM_DISKSTRING
>lsdsk -k -d DATA *_001
>lsdsk -s -d DATA *_001
>lsdsk -t -d DATA *_001
>lsdsk -c -t -d DATA *_001
>lsdsk -g -t -d DATA *_001
cp [-ifr] [connect_string:]src_fname
[connect_string:]tgt_fname
cp [-ifr]
[connect_string:]src_fnameN,
src_fnameN+1 ...
[connect_string:]tgt_directory

The connect_string is in t he f orm of :
user_name@host_name[.port_number].SID
- i int eract ive
- f f orce overwrit e ( aliases cannot be
overwrit t en)
- r recursive
Enables you t o copy f iles bet ween ASM disk groups on local
inst ances t o and f rom remot e inst ances.
>cp +dg1/vdb.ctf1 /backups/vdb.ctf1
>cp /home/oracle/encrypted.dmp +dg1
>cp vdb.ctf1 /tmp
# the target ASM instance must be registered with the
LISTENER
>cp +DATA/DBA11g/DATAFILE/DOCS_D1.289.631914611
sys@rac1.+ASM:+DATA/DBA11g1/datafile/xxx
remap
Repairs a range of physical blocks on disk ( only blocks exhibit ing
read disk I / O error s are repaired) excluding t hose wit h corrupt ed
cont ent s.
I nt ernally, it reads t he blocks f rom a good copy of an ASM mirror
and rewrit es t hem t o an alt ernat e locat ion on disk, if t he blocks
on t he original locat i on cannot be properly read.
remap <disk group name> <disk name> <block range>
> remap DISK_GRP1 DATA_0001 5000-5999
Back i n g u p an d Rest or i n g Di sk gr ou p Met adat a
The md_backup command capt ures inf ormat ion about ASM disks, diskgroup and f ailure group conf igurat ions, and
t emplat e and alias direct ory st ruct ures, and st ores t hem in a user- designat ed backup t ext f ile. Following is t he
basic synt ax of t he command:
md_backup [-b <backup_file_path> ] [-g diskgroup_name [-g diskgroup_name …]]
Following is an example of using t he command:
md_backup –b /tmp/asm_backup.mdb -g dg1 –g dg2
I f t he backup f ile already exist s, you should remove it bef ore issuing t he command.
I f you issue t he md_backup command wit hout any opt ion, it creat es a f ile named as
ambr_backup_intermediate_file which cont ains t he met adat a inf ormat ion of all t he mount ed diskgroups.
The md_restore command reads t he backup f ile and rest ores a disk group. You can set it s opt ions t o build a
script f ile t hat cont ains t he SQL st at ement s required t o rebuild t he ASM component s f rom t he backup f ile.
Following is t he synt ax of t he command and descript ion of it s swit ches:
md_restore -b <backup_file> [-li]
[-t (full)|nodg|newdg] [-f <sql_script_file>]
[-g '<diskgroup_name>,<diskgroup_name>,...']
[-o '<old_diskgroup_name>:<new_diskgroup_name>,...']
-t
t ype of rest ore.
full t ag specif ies t hat all t he diskgroups should be re- creat ed using t he same conf igurat ion f rom t he
Page 99 Oracle 11g New Features for Administrators - Summary Sheets

MDB backup f ile.
nodg rest ore met adat a only and skip t he diskgroup creat ion.

newdg creat e disk group wit h a dif f erent name and rest ore met adat a; -o is required. This t ag is used t o
allow t he user t o change diskgroup name.
-f
writ e SQL commands t o <sql_script_file> inst ead of execut ing t hem.
-o
override opt ion is used only wit h t he newdg opt ion t o remap t he diskgroup name, disk name, pat hs, and
f ailure groups.
-i
ignore errors. By def ault , t he command abort s when it encount ers an error.
-l
log all messages t o a log f ile.
Following are examples of using t he command:
# To perform a restore of the dg1 diskgroup from the MDB backup file, use this:
md_restore –b /tmp/backupfile –t full –g dg1 -i
# To just restore the metadata for the dg1 diskgroup (the diskgroup already exists).
md_restore –b /tmp/backupfile –t nodg –g dg1 –i
# To create a different diskgroup name:
md_restore –b /tmp/backupfile –t newdg -o "DGNAME=dg1:dg3" –i
# To apply the override options as specified in the dg_over.txt file and restore
# from the backup file:
md_restore –b /tmp/backupfile –t newdg –of /tmp/dg_override.txt –i
Not e t hat md_backup is a backup of t he met adat a of t he ASM inst ance. The dat a is being backed up by RMAN.
Af t er t he diskgroup is creat ed, along wit h all t he direct ories, you can rest ore t he RMAN backup t o t he diskgroup.
Bad Bl ock Recover y
I f ASM cannot read a physical block f rom a disk, it considers t hat t he block has I O error. I n t his case, ASM will
aut omat ically read a mirrored block and writ e a relocat ed copy t o produce successf ul copy. However, you can
manually repair blocks t hat have read disk I / O errors using t he remap command. Following is t he synt ax of t he
command:
remap <diskgroup name> <disk name> <block range>
Fast Rebal ance
I n Oracle 11g, f ast rebalance eliminat es ASM messaging among t he ASM inst ances in a RAC conf igurat ion when
a disk is added t o a disk group.
This f eat ure is enabled by using t he STARTUP RESTRICT or ALTER DISKGROUP … MOUNT RESTRICT commands.
When t he diskgroup is in rest rict ed mode, dat abases are not allowed t o access t he dat af iles in it .
The FORCE opt i on w i t h Dr op Di sk gr oup Command
I f a disk is dest royed beyond repair, you want t o drop it . But because t he disk is pract ically damaged, you cannot
mount it and t hus you cannot issue t he DROP DISKGROUP command against it . I n such a condit ion, Oracle 11g
provides t he FORCE INCLUDING CONTENTS opt ion t o drop t he diskgroup even if it is not mount ed. Following is an
example:
SQL>DROP DISKGROUP dg7 FORCE INCLUDING CONTENTS;

Mi scel l aneous ASM New Feat ur es
Oracle 11g int roduces some ot her new f eat ures in it s ASM relat ed t o t he clust ered ASM archit ect ure. Discussing
t hose f eat ures is beyond t he scope of t his document . For det ails about t hem, you can ref er t o t he new
document at ion "Oracle Dat abase St orage Administ rat or' s Guide 11g". Following is a brief descript ion about t hose
f eat ures:
Page 100 Oracle 11g New Features for Administrators - Summary Sheets

Pr ef er r ed Read Fai l u r e Gr ou ps
You can conf igure ASM t o read f rom a secondary ext ent if t hat ext ent is closer t o t he node inst ead of ASM
reading f rom t he primary copy which might be f art her f rom t he node. This conf igurat ion is described as Pref erred
Read Failure Group. Using pref erred read f ailure groups is most usef ul in ext ended clust ers.
ASM Rol l i n g Upgr ades
ASM rolling upgrades enable you t o independent ly upgrade or pat ch clust ered ASM nodes wit hout af f ect ing
dat abase availabilit y, t hus providing great er upt ime. Rolling upgrade means t hat all of t he f eat ures of a clust ered
ASM environment f unct ion when one or more of t he nodes in t he clust er use dif f erent sof t ware versions.
Or acl e Di r ect NFS
Oracle Dat abase 11g kernel has built - in support f or t he net work f ile syst em ( NFS) wit hout relying on OS support
f or NFS. I f Oracle’s Direct NFS is not able t o open t he NFS server, Oracle will ut ilize t he operat ing syst em’s NFS
client as specif ied in / et c/ f st ab and post an error message in t he alert log. This f eat ure has t he f ollowing
advant ages:
• You can achieve bet t er I O perf ormance, more ef f icient syst em resource ut ilizat ion, and lower operat ing
cost s in NAS environment s.
• You can implement Net work I nt erf ace Card ( NI C) bonding wit hout t he need of t he expensive advanced
Et hernet swit ches. I t is not eit her necessary t o have homogeneous net work cards.
Using ASM versus Direct NFS is st ill cont roversial subj ect .

Not e I n Oracle 11g ASM, you can creat e an ASM disk group using NFS f iles.
Page 101 Oracle 11g New Features for Administrators - Summary Sheets

PL/ SQL New Feat ur es
PL/ SQL New Feat ur es

CONTINUE St at emen t
I n Oracle 11g PL/ SQL, you can exit t he current it erat ion of a loop using t he new st at ement s: CONTINUE or
CONTINUE-WHEN. When a CONTINUE st at ement is encount ered, t he current it erat ion of t he loop complet es
immediat ely and cont rol passes t o t he next it erat ion of t he loop, as in t he f ollowing example:
DECLARE
x NUMBER := 0;
BEGIN
LOOP -- After CONTINUE statement, control resumes here
DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR(x));
x := x + 1;
IF x < 3 THEN
CONTINUE;
END IF;
DBMS_OUTPUT.PUT_LINE ('Inside loop, after CONTINUE: x = ' || TO_CHAR(x));
EXIT WHEN x = 5;
END LOOP;
DBMS_OUTPUT.PUT_LINE (' After loop: x = ' || TO_CHAR(x));
END;
When a CONTINUE-WHEN st at ement is encount ered, t he condit ion in t he WHEN clause is evaluat ed. I f t he condit ion
is t rue, t he current it erat ion of t he loop complet es and cont rol passes t o t he next it erat ion. The previous example
can be alt ered as in t he f ollowing code:
DECLARE
x NUMBER := 0;
BEGIN
LOOP -- After CONTINUE statement, control resumes here
DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR(x));
x := x + 1;
CONTINUE WHEN x < 3;
DBMS_OUTPUT.PUT_LINE ('Inside loop, after CONTINUE: x = ' || TO_CHAR(x));
EXIT WHEN x = 5;
END LOOP;
DBMS_OUTPUT.PUT_LINE (' After loop: x = ' || TO_CHAR(x));
END;
Sequ en ces Wi t h ou t Sel ect i n g f r om Du al
I t is no longer necessary t o execut e a SELECT .. FROM DUAL st at ement in PL/ SQL when you want t o assign a
NEXTVAL of a sequence t o a variable. Following is an example:
DECLARE
new_Val NUMBER;
BEGIN
new_Val := my_sequence.nextval;
...
END;
SI MPLE_I NTEGER
SIMPLE_INTEGER is a new dat a t ype int roduced in Oracle 11g PL/ SQL. I t has t he same range as of PLS_INTEGER
( –2, 147, 483, 648 t o 2, 147, 483, 647) but wit h t he f ollowing dif f erences:
PLS_I NTEGER SI MPLE_I NTEGER
cannot be null accept s NULL
less perf ormance in nat ive compiled PL/ SQL higher perf ormance in nat ive compiled PL/ SQL
when it t akes values out of it s range, error ret urned when it t akes values out of it s range, t he value wrap
f rom smallest t o largest and f rom largest t o smallest
Page 102 Oracle 11g New Features for Administrators - Summary Sheets

Named an d Mi x ed Not at i on i n PL/ SQL Su bpr ogr am I n vocat i on s
The use of NAME= > value is now support ed in PL/ SQL f unct ion calls t hat are cont ained in expressions in SQL
st at ement s. So f or example, all of t he f ollowing SELECT st at ement s are now valid:
SELECT EMP_PKG.GET_INFO(EMPLOYEE_ID,DEPARTMENT_ID) FROM EMPLOYEES;
SELECT EMP_PKG.GET_INFO(EMPLOYEE_ID,P_DEPT_ID=>DEPARTMENT_ID) FROM EMPLOYEES;
SELECT EMP_PKG.GET_INFO(P_EMP_ID=>EMPLOYEE_ID,P_DEPT_ID=> DEPARTMENT_ID) FROM EMPLOYEES;
Su bpr ogr am I n l i n i n g
Subprogram inlining replaces a subprogram call ( t o a subprogram in t he same program unit ) wit h a copy of t he
called subprogram. This will lead t o bet t er perf ormance in almost all t he cases.
The PLSQL_OPTIMIZE_LEVEL init ializat ion paramet er specif ies t he level of opt imizat ion used t o compile t he
PL/ SQL library unit and is used t o swit ch on and of f subprogram inlining in a PL/ SQL code. The paramet er
accept s t he f ollowing values:
1
No PL/ SQL compilat ion opt imizat ions are done.
2
PL/ SQL will rearrange code f or perf ormance but will not aut omat ically inline subprograms. I t will inline
subprogram calls t he developer has f lagged wit h t he pragma I NLI NE direct ive.
3
I n addit ion t o t he level 2 opt imizat ions, t he PL/ SQL compiler will aut omat ically inline subprograms where
perf ormance gains are predict ed, as well as place a high priorit y on inlining programmer f lagged calls.
The pragma INLINE compiler direct ive specif ies t hat a subprogram call is, or is not , t o be inlined. I t must appear
immediat ely bef ore t he subprogram call. I t t akes t he f ollowing t wo argument s:
ident if ier The name of t he subprogram.
Mode Eit her YES or NO.
For NO, no inlining will occur f or t he subprogram.
I f YES and PLSQL_OPTIMIZE_LEVEL= 2, t he subprogram will be inlined.
I f YES and PLSQL_OPTIMIZE_LEVEL= 3, t he opt imizer will place a high priorit y on inlining t he
subprogram. The opt imizer may f ind a bet t er opt imizat ion t hat does not need inlining.
Following are illust rat ed examples:
-- example 1
ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=2;
DECLARE
PROCEDURE PROC1(p_idata IN VARCHAR2) IS
BEGIN
....
dbms_output.put_line(dbms_utility.format_call_stack());
END;
BEGIN
-- inlining is NOT used
PROC1('test');
END;

-- example 2
ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=3;
DECLARE
PROCEDURE PROC1(p_idata IN VARCHAR2) IS
BEGIN
....
dbms_output.put_line(dbms_utility.format_call_stack());
END;
BEGIN
-- inlining is NOT used
pragma INLINE(PROC1,'YES');
PROC1('test');
-- inlining is used
pragma INLINE(PROC1,'YES');
PROC1('test');
END;

-- example 3
ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=3;
Page 103 Oracle 11g New Features for Administrators - Summary Sheets

DECLARE
PROCEDURE PROC1(p_idata IN VARCHAR2) IS
BEGIN
....
dbms_output.put_line(dbms_utility.format_call_stack());
END;
BEGIN
-- inlining may occur, if performance gain is predicted
PROC1('test');
-- inlining is used
pragma INLINE(PROC1,'YES');
PROC1('test');
END;
PL/ SQL Fu n ct i on Resu l t Cach e
Fundament als of using t his new f eat ure are described in t he sect ion "PL/ SQL Funct ion Result Cache". For f urt her
det ails, ref er t o t he document at ion "Oracle Dat abase PL/ SQL Language Ref erence 11g".
Or der i n g of Tr i gger s
I n Oracle 11g, you can cont rol t he order on which t he t riggers on a t able are f ired using t he new clause
FOLLOWS. Following is an example of using t his new clause.
CREATE TRIGGER Trigger3
BEFORE INSERT ON EMPLOYEES
FOLLOWS trigger2,trigger1
WHEN ...
The t riggers you specif y wit h FOLLOWS clause must already exist , be def ined on t he same t able as t he t rigger
being creat ed, and have been successf ully compiled. They need not be enabled.
Cr eat i n g Tr i gger s As ENABLED or DI SABLED
Two new keywords, ENABLED and DISABLED, have been added t o t he t rigger creat ion st at ement . They appear
immediat ely bef ore t he opt ional WHEN clause and af t er t he opt ional FOLLOWS clause.
CREATE TRIGGER EMP_CHECK_SAL
BEFORE INSERT ON EMPLOYEES
DISABLED
WHEN ...
Compou n d Tr i gger s Type
Oracle 11g int roduces a new t ype of t riggers called compound t riggers. A compound t rigger implement s all of t he
t iming- point logic ( bef ore st at ement , bef ore each row, af t er each row, af t er st at ement ) wit hin it s body, and all of
t hose sect ions share t he same set of variables declared in t he t rigger’s common declarat ion sect ion. The
compound t rigger makes it easier if you want t riggers of various t iming point s t o share common dat a.
The f ollowing example illust rat es t he general synt ax of creat ing a compound t rigger:
CREATE TRIGGER trigger_name
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
-- Declaration Section
-- Variables declared here have firing-statement duration.
threshold CONSTANT SIMPLE_INTEGER := 200;
BEFORE STATEMENT IS
BEGIN
...
END BEFORE STATEMENT;
AFTER STATEMENT IS
BEGIN
...
END AFTER STATEMENT;
BEFORE EACH ROW IS
BEGIN
...
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN
...
Page 104 Oracle 11g New Features for Administrators - Summary Sheets

END AFTER EACH ROW;
END trigger_name;
When using compound t riggers, consider t he f ollowing:
• A compound t rigger def ined on a view has an INSTEAD OF EACH ROW t iming- point sect ion, and no ot her
t iming- point sect ion.
• Timing- point sect ions must appear in t he order shown in t he example above.
• Any sect ion can include t he f unct ions Inserting, Updating, Deleting, and Applying.
Following are some of t he rest rict ions in t he compound t riggers:
• A compound t rigger must be def ined on eit her a t able or a view.
• An except ion t hat occurs in one sect ion must be handled in t hat sect ion. I t cannot t ransf er cont rol t o anot her
sect ion.
• Only t he BEFORE EACH ROW sect ion can change t he value of :NEW.
Two common uses of t he compound t riggers are:
• To accumulat e rows insert ed int o a t able by a st at ement t o bulk- insert t hem int o anot her t able. The t arget
here is t o have some perf ormance gain.
• To avoid t he mut at ing- t able error ( ORA- 04091) .
Examples of implement ing t hose t wo t arget s are copied f rom Oracle document at ion and past ed in t he f ollowing
examples:
-- Compound Trigger Records Changes to One Table in Another Table
CREATE TABLE employee_salaries (
employee_id NUMBER NOT NULL,
change_date DATE NOT NULL,
salary NUMBER(8,2) NOT NULL,
CONSTRAINT pk_employee_salaries PRIMARY KEY (employee_id, change_date),
CONSTRAINT fk_employee_salaries FOREIGN KEY (employee_id)
REFERENCES employees (employee_id) ON DELETE CASCADE)
/

CREATE OR REPLACE TRIGGER maintain_employee_salaries
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
-- Declaration Section:
-- Choose small threshhold value to show how example works:
threshhold CONSTANT SIMPLE_INTEGER := 7;
TYPE salaries_t IS TABLE OF employee_salaries%ROWTYPE INDEX BY SIMPLE_INTEGER;
salaries salaries_t;
idx SIMPLE_INTEGER := 0;

PROCEDURE flush_array IS
n CONSTANT SIMPLE_INTEGER := salaries.count();
BEGIN
FORALL j IN 1..n
INSERT INTO employee_salaries VALUES salaries(j);
salaries.delete();
idx := 0;
DBMS_OUTPUT.PUT_LINE('Flushed ' || n || ' rows');
END flush_array;

-- AFTER EACH ROW Section:
AFTER EACH ROW IS
BEGIN
idx := idx + 1;
salaries(idx).employee_id := :NEW.employee_id;
salaries(idx).change_date := SYSDATE();
salaries(idx).salary := :NEW.salary;
IF idx >= threshhold THEN
flush_array();
END IF;
END AFTER EACH ROW;

-- AFTER STATEMENT Section:
AFTER STATEMENT IS
BEGIN
Page 105 Oracle 11g New Features for Administrators - Summary Sheets

flush_array();
END AFTER STATEMENT;
END maintain_employee_salaries;
The f ollowing example implement s a business rule t hat st at es t hat an employee' s salary increase must not
exceed 10% of t he average salary f or t he employee' s depart ment .
CREATE OR REPLACE TRIGGER check_Employee_Salary_Raise
FOR UPDATE OF Salary ON Employees
COMPOUND TRIGGER
Ten_Percent CONSTANT NUMBER := 0.1;
TYPE Salaries_t IS TABLE OF Employees.Salary%TYPE;
Avg_Salaries Salaries_t;
TYPE Department_IDs_t IS TABLE OF Employees.Department_ID%TYPE;
Department_IDs Department_IDs_t;
TYPE Department_Salaries_t IS TABLE OF Employees.Salary%TYPE
INDEX BY VARCHAR2(80);
Department_Avg_Salaries Department_Salaries_t;

BEFORE STATEMENT IS
BEGIN
SELECT AVG(e.Salary), NVL(e.Department_ID, -1)
BULK COLLECT INTO Avg_Salaries, Department_IDs
FROM Employees e
GROUP BY e.Department_ID;
FOR j IN 1..Department_IDs.COUNT() LOOP
Department_Avg_Salaries(Department_IDs(j)) := Avg_Salaries(j);
END LOOP;
END BEFORE STATEMENT;

AFTER EACH ROW IS
BEGIN
IF :NEW.Salary - :Old.Salary >
Ten_Percent*Department_Avg_Salaries(:NEW.Department_ID) THEN
Raise_Application_Error(-20000, 'Raise too big');
END IF;
END AFTER EACH ROW;
END check_Employee_Salary_Raise;
Con ver t i n g bet w een Dyn ami c Cu r sor an d REF CURSOR
I n Oracle Dat abase 11g, t he supplied package DBMS_SQL has a new f unct ion, TO_REFCURSOR, which convert s t he
DBMS_SQL dynamic cursor t o a ref cursor. Here is an example of such a conversion:
CREATE OR REPLACE PROCEDURE list_trans_by_store ( p_store_id NUMBER ) IS
TYPE num_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE type_refcur IS REF CURSOR;
c_ref_trans_cur TYPE_REFCUR;
c_trans_cur NUMBER;
trans_id NUM_TAB;
trans_amt NUM_TAB;
ret INTEGER;
l_stmt CLOB;
begin
c_trans_cur := Dbms_Sql.Open_Cursor;
l_stmt :=
'select trans_id, trans_amt from trans where store_id = :store_id';
DBMS_SQL.PARSE(c_trans_cur, l_stmt, dbms_sql.native);
DBMS_SQL.BIND_VARIABLE(c_trans_cur, 'store_id', p_store_id);
ret := DBMS_SQL.EXECUTE(c_trans_cur);
c_ref_trans_cur := DBMS_SQL.TO_REFCURSOR(c_trans_cur);
FETCH c_ref_trans_cur BULK COLLECT into trans_id, trans_amt;
FOR ctr in 1 .. trans_id.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(trans_id(ctr) || ' ' || trans_amt(ctr));
END LOOP;
CLOSE c_ref_trans_cur;
END;
Page 106 Oracle 11g New Features for Administrators - Summary Sheets


Suppose you want t o writ e a generic procedure where you do not know t he column list in t he select clause at
compile t ime. This is where t he nat ive dynamic SQL comes in handy; you can def ine a ref cursor f or t hat . Now,
suppose you do not know t he bind variable as well, f or which DBMS_SQL is more appropriat e. How can you
accomplish t his complex requirement wit h minimal code? Simple: Just st art wit h DBMS_SQL f or t he bind part and
t hen convert it t o ref cursor lat er f or t he ot her part .
Similarly, if you want t o convert a Nat ive Dynamic SQL t o REF CURSOR, you will need t o call anot her f unct ion,
TO_CURSOR_NUMBER:
cur_handle := DBMS_SQL.TO_CURSOR_NUMBER (c_ref_cur);
The ref cursor specif ied by t he variable c_ref _cur must be opened prior t o t his call. Af t er t his call, t he lif e of t he
ref cursor is over; it can be manipulat ed only as a DBMS_SQL cursor.
Suppose you know t he binds at compile t ime but not t he select list ; you st art wit h nat ive dynamic sql wit h a ref
cursor and lat er change it t o DBMS_SQL t o describe and f et ch t he columns f rom t he cursor.
Page 107 Oracle 11g New Features for Administrators - Summary Sheets

Dat a War ehousi ng
Secur eFi l es

Oracle Dat abase 11g complet ely reengineers LOB st orage t o what t hey call SecureFiles. The previous BLOB dat a
t ypes are ref erred t o as BasicFiles. The primary f ocus of t he SecureFiles f eat ure is t o do t he f ollowing:
• I mprove perf ormance
• Reduce space consumpt ion
• Enhance securit y
Cr eat i n g Secu r eFi l e LOB Col u mn s
Use t he clause STORE AS SECUREFILE or STORE AS BASICFILE t o creat e a SecureFile or BasicFile columns in a
t able. This is, however, cont rolled by t he init ializat ion paramet er DB_SECUREFILE. Using t he paramet er will be
discussed in t he next sub- sect ion. Following is an example of creat ing a t able wit h a SecureFile LOB column:
CREATE TABLE employees
( employee_id NUMBER NOT NULL PRIMARY KEY,
name VARCHAR2(255) NOT NULL,
...
cv_content BLOB )
TABLESPACE tools
LOB (cv_content) STORE AS SECUREFILE (
KEEP_DUPLICATES -- or DEDUPLICATE
TABLESPACE tools ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGGING);
DEDUPLICATE opt ion makes Oracle st ores a single copy of a f ile when st oring many ident ical f iles. Thus, space is
signif icant ly saved. This opt ion can be alt ered f or an exist ing SecureFile:
ALTER TABLE employees MODIFY LOB(cv_content) (DEDUPLICATE);
Be aware t hat t he command shown in t he example above will make Oracle read t he values in t he column and
remove duplicat es.
You can enable encrypt ion f or SecureFiles LOBs using t he TDE. Following is an example:
ALTER TABLE employees MODIFY (cv_content ENCRYPT USING 'AES192');
Available encrypt ion algorit hms are: AES192 ( t he def ault ) , 3DES168, AES128, and AES256. Encrypt ion f or
SecureFiles must use SALT. You can query t he DBA_ENCRYPTED_COLUMNS view t o conf irm t hat LOB columns are
encrypt ed.
Encrypt ion can be disabled using t he f ollowing command:
ALTER TABLE employees MODIFY (blob_content DECRYPT)
Compression in SecureFiles can be enabled by using t he COMPRESS clause in t he CREATE TABLE or ALTER TABLE
commands as in t he f ollowing example:
.. LOB (cv_content) STORE AS SECUREFILE (COMPRESS HIGH) -- or medium
Not e t hat Oracle will not be able t o signif icant ly reduce t he size of a SecureFile, if you st ore an already
compressed f ile int o it .
Compression can be disabled using t he NOCOPRESS clause. Remember t hat compression and decompression will
t ake ef f ect immediat ely when you enable or disable compression.
Not e Beside ALTER TABLE command, deduplicat ion, encrypt ion, and compression set t ings of SecureFile
LOBs can be alt ered using DBMS_LOB.SETOPTIONS.
Th e DB_SECUREFILE I n i t i al i zat i on Par amet er
Creat ing SecureFiles in t he dat abase is cont rolled by t he new dynamic init ializat ion paramet er DB_SECUREFILE.
This paramet er specif ies whet her or not t o t reat LOB f iles as SecureFiles. Following are it s accept able values:
NEVER
Any LOBs t hat are specif ied as SecureFiles are creat ed as BasicFile LOBs. All SecureFile- specif ic
st orage opt ions and f eat ures ( f or example, compress, encrypt , deduplicat e) will cause an
except ion. The BasicFile LOB def ault s will be used f or st orage opt ions not specif ied.
PERMITTED
( t he def ault ) LOBs are allowed t o be creat ed as SecureFiles.
Page 108 Oracle 11g New Features for Administrators - Summary Sheets

ALWAYS

All LOBs creat ed in t he syst em are creat ed as SecureFile LOBs. Any BasicFile LOB st orage opt ions
are ignored. The SecureFile def ault s will be used f or all st orage opt ions not specif ied.
IGNORE
The SECUREFILE keyword and all SecureFile opt ions are ignored.
I f t he COMPATIBLE init ializat ion paramet er is not set t o 11. 1 or higher, t hen LOBs are not t reat ed as SecureFiles.
Also, SecureFile LOB must be creat ed in a Aut omat ic Segment Space Managed ( ASSM) t ablespace.
Following is an example of modif ying t his paramet er:
ALTER SYSTEM SET DB_SECUREFILE='ALWAYS';
Space u sed by Secu r eFi l e
The procedure DBMS_SPACE.SPACE_USAGE can be used t o obt ain t he space usage inf ormat ion of dat a blocks in a
segment . There is a f orm of t his procedure t hat specif ically ret urns inf ormat ion about SECUREFI LE LOB space
usage. I t displays t he space act ively used by t he LOB column, f reed space t hat has ret ent ion expired, and f reed
space t hat has ret ent ion unexpired.
Following is t he synt ax of t hat f orm of t he procedure:
DBMS_SPACE.SPACE_USAGE(
segment_owner IN VARCHAR2,
segment_name IN VARCHAR2,
segment_type IN VARCHAR2, possible values are: TABLE, TABLE PARTITION, TABLE SUBPARTITION
INDEX, INDEX PARTITION, INDEX SUBPARTITION, CLUSTER, LOB,
LOB PARTITION, LOB SUBPARTITION
segment_size_blocks OUT NUMBER,
segment_size_bytes OUT NUMBER,
used_blocks OUT NUMBER,
used_bytes OUT NUMBER,
expired_blocks OUT NUMBER,
expired_bytes OUT NUMBER,
unexpired_blocks OUT NUMBER,
unexpired_bytes OUT NUMBER,
partition_name IN VARCHAR2 DEFAULT NULL);

Accessi n g a LOB Usi n g SQL an d PL/ SQL
I n most cases, you can use t he same SQL semant ics on a LOB column ( BasicFile or SecureFile) t hat you would
use on a VARCHAR2 column. Following are t he SQL operat ions t hat are not support ed on LOB columns:
SELECT DISTINCT clobCol from...
SELECT... ORDER BY clobCol
SELECT... GROUP BY clobCol
SELECT clobCol1 from tab1 UNION SELECT clobCol2 from tab2;
SELECT... WHERE tab1.clobCol = tab2.clobCol
CREATE... ON tab(clobCol)...
Accessing LOB columns in Oracle 11g PL/ SQL is t he same as in t he previous version. Following are examples:
-- LOBs with INSERT, UPDATE, and SELECT Operations
CREATE TABLE t (id number, clob_col CLOB, blob_col BLOB);
INSERT INTO t VALUES(1,'row1', 'aaaaa');
declare
c_buffer VARCHAR2(100);
begin
INSERT INTO t(id, clob_col, blob_col)
VALUES(2, 'row2', 'FFFF'); -- blob is passed a hexadecimal number
UPDATE t SET clob_col= 'ROW2'
WHERE id=2;
-- This will get the LOB column if it is up to 100 bytes, (exception otherwise)
SELECT clob_col INTO c_buffer FROM t WHERE id=2;
end;

-- LOBs in Assignments and Parameter Passing
Page 109 Oracle 11g New Features for Administrators - Summary Sheets

declare
var_buf VARCHAR2(100);
clob_buf CLOB;
blob_buf BLOB;
begin
SELECT clob_col, blob_col INTO clob_buf, blob_buf FROM t WHERE id=1;
var_buf := clob_buf; -- coversion from VARCHAR2 to CLOB
clob_buf := var_buf; -- CLOB to VARCHAR2 conversion
end;

CREATE OR REPLACE PROCEDURE FOO ( a IN OUT CLOB) IS
begin
-- Any procedure body
a := 'abc';
end;

CREATE OR REPLACE PROCEDURE BAR (b IN OUT VARCHAR2) IS
begin
-- Any procedure body
b := 'xyz';
end;

On l i n e Redef i n i t i on
Online redef init ion is t he only recommended met hod f or migrat ion of BasicFile LOBs t o SecureFiles. I t can be
done at t he t able or part it ion level.
Online Redef init ion Advant ages:
o No need t o t ake t he t able or part it ion of f line.
o Can be done in parallel.
Online Redef init ion Disadvant ages
o Addit ional st orage equal t o t he ent ire t able or part it ion and all LOB segment s must be available.
o Global indexes need t o be rebuilt .
Following is an example of how t o migrat e a t able using Online Redef init ion:
-- Grant privileges required for online redefinition.
GRANT EXECUTE ON DBMS_REDEFINITION TO pm;
GRANT ALTER ANY TABLE TO pm;
GRANT DROP ANY TABLE TO pm;
GRANT LOCK ANY TABLE TO pm;
GRANT CREATE ANY TABLE TO pm;
GRANT SELECT ANY TABLE TO pm;

-- Privileges required to perform cloning of dependent objects.
GRANT CREATE ANY TRIGGER TO pm;
GRANT CREATE ANY INDEX TO pm;

CONNECT pm

CREATE TABLE cust(c_id NUMBER PRIMARY KEY,
c_zip NUMBER,
c_name VARCHAR(30) DEFAULT NULL,
c_lob CLOB);
INSERT INTO cust VALUES(1, 94065, 'hhh', 'ttt');

-- Creating Interim Table
-- no need to specify constraints because they are copied over from the original table
CREATE TABLE cust_int(c_id NUMBER NOT NULL,
c_zip NUMBER,
c_name VARCHAR(30) DEFAULT NULL,
c_lob CLOB)
LOB(c) STORE AS SECUREFILE (...);

declare
col_mapping VARCHAR2(1000);
begin
Page 110 Oracle 11g New Features for Administrators - Summary Sheets

-- map all the columns in the interim table to the original table
col_mapping :='c_id c_id , '||'c_zip c_zip , '||'c_name c_name, '||'c_lob c_lob';
DBMS_REDEFINITION.START_REDEF_TABLE('pm', 'cust', 'cust_int', col_mapping);
end;

declare
error_count pls_integer := 0;
begin
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS('pm', 'cust', 'cust_int',
1, TRUE,TRUE,TRUE,FALSE, error_count);
DBMS_OUTPUT.PUT_LINE('errors := ' || TO_CHAR(error_count));
end;

exec DBMS_REDEFINITION.FINISH_REDEF_TABLE('pm', 'cust', 'cust_int');

-- Drop the interim table
DROP TABLE cust_int;
DESC cust;

-- to prove that the primary key on the c_id column is preserved after migration.
INSERT INTO cust VALUES(1, 94065, 'hhh', 'ttt');
SELECT * FROM cust;
When online redef init ion is applied on a t able, all t riggers are invalidat ed and are aut omat ically revalidat ed wit h
t he next DML execut ion on t he t able.
Par t i t i on Ch an ge Tr ack i n g ( PCT)
A group of dat a dict ionary views in Oracle 11g are improved t o provide inf ormat ion about ref reshing t he
mat erialized view part it ion. Following are t he relat ed modif icat ions:
• I n t he DBA_MVIEWS view, t he f ollowing columns added: NUM_PCT_TABLES, NUM_FRESH_PCT_REGIONS,
NUM_STALE_PCT_REGIONS.
• The view DBA_MVIEW_DETAIL_RELATIONS was added wit h t he f ollowing columns: DETAILOBJ_PCT,
NUM_FRESH_PCT_PARTITIONS, NUM_STALE_PCT_PARTITIONS.
• New t wo views are int roduced in Oracle 11g named as ALL_MVIEW_DETAIL_PARTITION and
ALL_MVIEW_DETAIL_SUBPARTITION. They provides f reshness inf ormat ion f or each PCT part it ion and sub-
part it ion.
Gen er at i n g SQL Cr osst ab Repo r t u si n g PI VOT Oper at o r
Oracle 11g SQL int roduces an excellent new SELECT st at ement operat or: PIVOT. This operat or enables you t o
easily generat e crosst ab report using SQL language.
The f ollowing example produces a report of t he maximum quart er sales amount f or every quart er where t he
quart ers are displayed as columns:
SELECT *
FROM
( SELECT PRODUCT_DESC, QUARTER_ID, QUARTER_AMT FROM PRODUCT_ROW )
PIVOT
(MAX(QUARTER_AMT) FOR QUARTER_ID IN (1, 2, 3, 4));


PRODUCT_DESC 1 2 3 4
-------------------- ---------- ---------- ---------- ----------
Sharpie 130 215 190 300
Pencils 2100 918 3280 1315
Not e: Unf ort unat ely, using t he synt ax above, you cannot use a sub- query in t he list of values provided f or t he
QUARTER_ID in t he pivot expression. Theref ore, you cannot dynamically provide t he possible values of t he
columns. This is only possible, if you want t o generat e t he report in XML f ormat .
Page 111 Oracle 11g New Features for Administrators - Summary Sheets

You can use column aliases in t he generat ed report as f ollows:
SELECT *
FROM
( SELECT PRODUCT_DESC, QUARTER_ID, QUARTER_AMT FROM PRODUCT_ROW )
PIVOT
(MAX(QUARTER_AMT) FOR QUARTER_ID IN (1 AS QTR1, 2 AS QTR2, 3 AS QTR3, 4 AS QTR4))

PRODUCT_DESC QTR1 QTR2 QTR3 QTR4
-------------------- ---------- ---------- ---------- ----------
Sharpie 130 215 190 300
Pencils 2100 918 3280 1315
Following is anot her example of pivot ing on mult iple columns:
SELECT *
FROM (SELECT video_name, month, quantity_rented, rental_type
FROM video_mstr_vw)
PIVOT (SUM(quantity_rented)
FOR (rental_type, month) IN (
(10000, '01') as SR_Jan,
(10001, '01') as IR_Jan,
(10000, '02') as SR_Feb,
(10001, '02') as IR_Feb )
)
ORDER BY SR_Jan, IR_Jan, SR_Feb, IR_Feb
The ot her new operat or UNPIVOT has an opposit e ef f ect . Suppose you have a spreadsheet wit h t he f ollowing
f ormat :
SQL> desc cust_matrix
Name Null? Type
----------------------------------------- -------- ---------------------------
PUCHASE FREQUENCY NUMBER(3)
NEW YORK NUMBER
CONN NUMBER
NEW JERSEY NUMBER
FLORIDA NUMBER
MISSOURI NUMBER

SQL> select * from cust_matrix;

PUCHASE FREQUENCY NEW YORK CONN NEW JERSEY FLORIDA MISSOURI
----------------- ---------- ---------- ---------- ---------- ----------
1 33048 165 0 0 0
2 33151 179 0 0 0
3 32978 173 0 0 0
4 33109 173 0 1 0
You can convert t he columns represent ing t he st at e int o rows as f ollows:
select *
from CUST_MATRIX
UNPIVOT
(
state_counts
for state_code in ("NEW YORK","CONN","NEW JERSEY","FLORIDA","MISSOURI"))
order by "Puchase Frequency", state_code ;

Puchase Frequency STATE_CODE STATE_COUNTS
----------------- ---------- ------------
1 Conn 165
1 Florida 0
1 Missouri 0
1 New Jersey 0
1 New York 33048
2 Conn 179
2 Florida 0
2 Missouri 0

Page 112 Oracle 11g New Features for Administrators - Summary Sheets

Par t i t i on i n g I m pr o vemen t s
Th e Par t i t i on Advi sor
Part it ioning advice is available wit hin t he SQL Access Advisor as part of t he Ent erprise Manager. SQL Access
Advisor can now recommend creat ing part it ions t o improve t he perf ormance.
I f t he advisor uses t he part it ioning as one of it s recommendat ions, you can review t he SQL script t hat convert s a
heap t able int o a part it ioned one.
Ref er en ce Par t i t i on s
Ref erence part it ioning allows t he part it ioning of t wo t ables relat ed t o one anot her by a ref erent ial const raint . The
part it ioning key is resolved and enf orced t hrough an exist ing parent - child relat ionship. Ref erence part it ions is
usef ul when you want t o part it ion a child t able in t he same f ashion as in t he parent t able but t he child t able does
not have t he same part it ioned columns.
When you creat e t he child t able, use t he clause PARTITION BY REFERENCE t o creat e a ref erence part it ion as in
t he f ollowing example:
CREATE TABLE parent_tab (
id NUMBER NOT NULL,
code VARCHAR2(10) NOT NULL,
description VARCHAR2(50),
created_date DATE,
CONSTRAINT parent_tab_pk PRIMARY KEY (id) )
PARTITION BY RANGE (created_date)
(
PARTITION part_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008','DD-MON-YYYY')),
PARTITION part_2008 VALUES LESS THAN (TO_DATE('01-JAN-2009','DD-MON-YYYY'))
);

CREATE TABLE child_tab (
id NUMBER NOT NULL,
parent_tab_id NUMBER NOT NULL, -- it must be NOT NULL for reference partition
code VARCHAR2(10),
description VARCHAR2(50),
created_date DATE,
CONSTRAINT child_tab_pk PRIMARY KEY (id),
CONSTRAINT child_parent_tab_fk FOREIGN KEY (parent_tab_id)
REFERENCES parent_tab (id) )
PARTITION BY REFERENCE (child_parent_tab_fk);
The column on which t he parent t able is part it ioned, CREATED_DATE, does not exist in t he child t able, yet t he
child t able is part it ioned on t hat column.
I f you issue t he f ollowing query, you will not ice t hat t he child t able will have part it ions creat ed wit h t he same
name as it s parent t able. Also, t he HIGH_VALUE is null, indicat ing t hat t he boundaries are derived f rom t he parent
t able.
SELECT TABLE_NAME, PARTITION_NAME, HIGH_VALUE, NUM_ROWS
FROM USER_TAB_PARTITIONS
ORDER BY TABLE_NAME, PARTITION_NAME;
Det ails of t he ref erence part it ions can be obt ained f rom t he f ollowing query:
SELECT TABLE_NAME, PARTITIONING_TYPE, REF_PTN_CONSTRAINT_NAME
FROM USER_PART_TABLES;
Ref erence part it ions will be physically locat ed in t he same t ablespace of t he parent t able if t he TABLESPACE
clause is not specif ied. The t ablespace f or t he ref erence part it ion can be overridden by using t he DEPENDENT
TABLES clause as in t he f ollowing example:
ALTER TABLE parent_tab
ADD PARTITION part_2006 VALUES LESS THAN (TO_DATE('01-JAN-2007','DD-MON-YYYY'))
TABLESPACE parent_tab
DEPENDENT TABLES
(child_tab (PARTITION part_2006 TABLESPACE child_tbs));
Page 113 Oracle 11g New Features for Administrators - Summary Sheets

The f ollowing rest rict ions apply t o ref erence part it ioning:
• The f oreign key columns ref erenced in const raint must be NOT NULL.
• The f oreign key const raint cannot use t he ON DELETE SET NULL clause.
• Ref erence part it ioning cannot be used f or index- organized t ables, ext ernal t ables, or domain index st orage
t ables.
• The ROW MOVEMENT set t ing f or bot h t ables must mat ch.
I n t er val Par t i t i on i n g
I nt erval part it ioning is an ext ension of range part it ioning which inst ruct s t he dat abase t o aut omat ically creat e
part it ions of a specif ied int erval when dat a insert ed int o t he t able exceeds all of t he exist ing range part it ions.
The PARTITION BY RANGE clause is used in t he normal way t o ident if y t he t ransit ion point f or t he part it ion, t hen
t he new INTERVAL clause used t o calculat e t he range f or new part it ions when t he values go beyond t he exist ing
t ransit ion point . Following is an example:
CREATE TABLE interval_tab (
id NUMBER,
code VARCHAR2(10),
description VARCHAR2(50),
created_date DATE
)
PARTITION BY RANGE (created_date)
INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
STORE IN (TBS1, TBS2, TBS3, TBS4) -- optional
( PARTITION part_01 VALUES LESS THAN (TO_DATE('01-NOV-2007','DD-MON-YYYY')) );
I f you want t o creat e a part it ion f or every quart er, change t he int erval command t o INTERVAL
(NUMTOYMINTERVAL(3,'MONTH')) making sure t hat t he f irst part it ion was creat ed at t he end of a given quart er.
The NUMTOYMINTERVAL f unct ion can be used t o creat e part it ions on a smaller scale like daily, hourly, per minut e,
or even down t o t he second.
I f you use t he STORE IN clause t o list a group of t ablespaces, Oracle will, in a round- robin f ashion, creat e
part it ions in t he t ablespaces list ed.
You can convert an exist ing non- int erval range part it ion t able int o an int erval part it ion using t he ALTER TABLE
command as in t he f ollowing example:
ALTER TABLE interval_tab SET INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
You can obt ain inf ormat ion about creat ed part it ions by using t he f ollowing query:
EXEC DBMS_STATS.GATHER_TABLE_STATS(USER, 'INTERVAL_TAB');

SELECT TABLE_NAME, PARTITION_NAME, HIGH_VALUE, NUM_ROWS
FROM USER_TAB_PARTITIONS
ORDER BY TABLE_NAME, PARTITION_NAME;
When using int erval part it ioning, consider t he f ollowing rest rict ions:
• You can only specif y one part it ioning key column, and it must be of NUMBER or DATE t ype.
• I nt erval part it ioning is not support ed f or index- organized t ables ( I OTs) .
• Aut omat ically creat ed part it ions are named by t he syst em using SYS_Pn f ormat . You can, however, use t he
ALTER TABLE .. RENAME PARTITION .. TO command t o rename t hem.
• I nt erval part it ioning does not support subpart it ions.
• A MAXVALUE part it ion cannot be def ined f or an int erval part it ioned t able.
• NULL values are not allowed in t he part it ion column.
Ex t en ded Composi t e Par t i t i on i n g
Prior t o Oracle Dat abase 11g, t he only composit e part it ioning schemes were range- list and range- hash
part it ioning. Oracle Dat abase 11g added t he f ollowing composit e part it ioning met hods:
• Composi t e Ran ge- Ran ge: This part it ioning met hod will part it ion dat a using t he range met hod. Then f or
each part it ion, subpart it ions are creat ed using t he range met hod.
• Composi t e Li st - Ran ge
• Composi t e Li st - Hash
• Composi t e Li st - Li st
Page 114 Oracle 11g New Features for Administrators - Summary Sheets

Following are examples of creat ing t ables wit h ext ended composit e part it ions:
-- Composite Range-Range Partitioning
CREATE TABLE Alerts_Range_Range
( alert_notification_id NUMBER,
subject VARCHAR2(2000),
message VARCHAR2(4000),
creation_date DATE DEFAULT SYSDATE,
closed_date DATE)
PARTITION BY RANGE (creation_date)
SUBPARTITION BY RANGE (closed_date)
( PARTITION p_Q1_07 VALUES LESS THAN (to_date('01-APR-2007','dd-MON-yyyy'))
( SUBPARTITION p_JAN07 VALUES LESS THAN (to_date('01-FEB-2007','dd-MON-yyyy')),
SUBPARTITION p_FEB07 VALUES LESS THAN (to_date('01-MAR-2007','dd-MON-yyyy')),
SUBPARTITION p_MAR07 VALUES LESS THAN (to_date('01-APR-2007','dd-MON-yyyy')),
SUBPARTITION p_PRE_Q107 VALUES LESS THAN (MAXVALUE) )
, PARTITION p_Q2_07 VALUES LESS THAN (to_date('01-JUL-2007','dd-MON-yyyy'))
( SUBPARTITION p_APR07 VALUES LESS THAN (to_date('01-MAY-2007','dd-MON-yyyy')),
SUBPARTITION p_MAY07 VALUES LESS THAN (to_date('01-JUN-2007','dd-MON-yyyy')),
SUBPARTITION p_JUN2007 VALUES LESS THAN (to_date('01-JUL-2007','dd-MON-yyyy')),
SUBPARTITION p_PRE_Q207 VALUES LESS THAN (MAXVALUE)));


-- Composite List-Range Partitioning
CREATE TABLE Docs_List_Rist
(document_id NUMBER,
document_category VARCHAR2(10),
organization_id NUMBER,
creation_date DATE)
PARTITION BY LIST (organization_id)
SUBPARTITION BY RANGE (creation_date)
( PARTITION org1 VALUES (1)
(SUBPARTITION p1_07q1 VALUES LESS THAN (to_date('01-APR-2007','dd-MON-yyyy')),
SUBPARTITION p1_07q2 VALUES LESS THAN (to_date('01-JUL-2007','dd-MON-yyyy')) ),
PARTITION org2 VALUES (2)
(SUBPARTITION p2_07q1 VALUES LESS THAN (to_date('01-APR-2007','dd-MON-yyyy')),
SUBPARTITION p2_07q2 VALUES LESS THAN (to_date('01-JUL-2007','dd-MON-yyyy')) )
);


-- Composite List-Hash Partitions
CREATE TABLE list_hash_tab (
id NUMBER,
code VARCHAR2(10),
description VARCHAR2(50),
created_date DATE
)
PARTITION BY LIST (code)
SUBPARTITION BY HASH (id)
(
PARTITION part_aa VALUES ('AA')
( SUBPARTITION part_aa_01 ,
SUBPARTITION part_aa_02 ),
PARTITION part_bb VALUES ('BB')
( SUBPARTITION part_bb_01 ,
SUBPARTITION part_bb_02 )
);

-- Composite List-List Partitions
CREATE TABLE Docs_List_List
( document_id NUMBER,
document_category VARCHAR2(10),
organization_id NUMBER,
creation_date DATE
)
PARTITION BY LIST (organization_id)
SUBPARTITION BY LIST (document_category)
( PARTITION org1 VALUES (1)
( SUBPARTITION p1_cat_dg VALUES ('DG'),
SUBPARTITION p1_cat_asm VALUES ('ASM'),
Page 115 Oracle 11g New Features for Administrators - Summary Sheets

SUBPARTITION p1_cat_sql VALUES ('SQL'),
SUBPARTITION p1_cat_plsql VALUES ('PLSQL'),
SUBPARTITION p1_cat_rac VALUES ('RAC'),
subpartition p1_cat_def VALUES (default) ),
PARTITION org2 VALUES (2)
( SUBPARTITION p2_cat_dg VALUES ('DG'),
SUBPARTITION p2_cat_asm VALUES ('ASM'),
SUBPARTITION p2_cat_sql VALUES ('SQL'),
SUBPARTITION p2_cat_plsql VALUES ('PLSQL'),
SUBPARTITION p2_cat_rac VALUES ('RAC'),
SUBPARTITION p2_cat_def VALUES (default) ) );
Vi r t u al Col u mn - Based Par t i t i on i n g
You can creat e a part it ion based on a virt ual column. Virt ual column- based part it ioning is support ed wit h all
basic part it ioning st rat egies, including int erval and int erval- * composit e part it ioning.
For inf ormat ion about virt ual columns, ref er t o t he "Virt ual Columns" sect ion.
Following is an example of creat ing virt ual column- based part it ions:
CREATE TABLE hr_employees
( employee_id NUMBER NOT NULL,
name VARCHAR2(55),
dept_id NUMBER,
total_package as (salary + bonus ) VIRTUAL )
PARTITION BY RANGE(total_package)
(partition p_10k values less than (10000),
partition p_10k_35k values less than (35000),
partition p_35k_50k values less than (50000),
...
partition p_1000k_5000k values less than (5000000),
partition p_other values less than (maxvalue));

Syst em Par t i t i on i n g
Wit h syst em part it ioning, a t able is physically divided int o part it ions but t he applicat ion decides t o which
part it ion t he rows should be st ored.
Syst em part it ions are creat ed using t he PARTITION BY SYSTEM clause. I nsert ing int o such a t able must be
part it ion aware. However, updat e and delet e operat ions can be perf ormed wit h or wit hout t he part it ion- aware
synt ax. Be aware t hat when you perf orm updat es and delet es wit hout t he part it ion- aware synt ax, Oracle scans
every part it ion on t he t able.
Following is an example:
CREATE TABLE docs
( id NUMBER,
name VARCHAR2(255),
desc VARCHAR2(1000))
PARTITION BY SYSTEM
( PARTITION docs_p1 TABLESPACE docs_d1,
PARTITION docs_p2 TABLESPACE docs_d2,
PARTITION docs_p3 TABLESPACE docs_d3,
PARTITION docs_p4 TABLESPACE docs_d4 );

-- PARTITION must be stated
INSERT INTO docs PARTITION (docs_p1)
VALUES (1, 'Oracle 11g New Features', 'New features in Oracle 11g Database.');
-- with DELETE command, PARTITION can be stated
DELETE FROM docs PARTITION (docs_p2) WHERE doc_id=1002;
DELETE FROM docs PARTITION (docs_p2);
-- PARTITION can be used in queries to target specific partitions
SELECT COUNT(*) FROM docs PARTITION (docs_p1)
Page 116 Oracle 11g New Features for Administrators - Summary Sheets

Wit h syst em part it ions, consider t he f ollowing rest rict ions:
o I f you specif y t he PARTITION BY SYSTEM clause wit hout def ining part it ions, a single part it ion is creat ed wit h
t he name in t he f ormat of "SYS_Pn".
o I f you specif y PARTITION BY SYSTEM PARTITIONS n clause, t he dat abase creat es "n" part it ions wit h t he
name in t he f ormat of "SYS_Pn". The range of allowable values f or "n" is f rom 1 t o 1024K- 1.
o Syst em part it ioning is not available f or index- organized t ables or a t able t hat is part of a clust er.
o Syst em part it ioning can play no part in composit e part it ioning.
o You cannot split a syst em part it ion.
o Syst em part it ioning cannot be specif ied in a CREATE TABLE ... AS SELECT st at ement .
o To insert dat a int o a syst em- part it ioned t able using an I NSERT I NTO . . . AS subquery st at ement , you must
use part it ion- ext ended synt ax t o specif y t he part it ion int o which t he values ret urned by t he subquery will be
insert ed.
o Unique local indexes cannot be creat ed on t he part it ion key.
o Tradit ional part it ion pruning and part it ion- wise j oins are not support ed on t he t ables wit h syst em part it ions.
Page 117 Oracle 11g New Features for Administrators - Summary Sheets

Appendi x I
Mappi ng Ex am 1Z0- 050 Obj ect i v es t o Document Topi cs
The exam 1Z0- 050 ( t i t led as Oracle Dat abase 11g: New Feat ures) i s t he required exam t o pass in order t o
upgrade your Oracle 10g OCP cert if icat e on Oracle DBA t o Oracel11g OCP cert if icat e. The t able below maps t he
exam obj ect ives t o t he document t opics. This will help you using t his document t o review your preparat ion f or
t he exam.
Be aware t hat t he obj ect ives ment ioned here are as of t ime of writ ing t his document and Oracle might change
t hem. To know t he lat est obj ect ives, ref er t o Oracle Educat i on websit e. Click t here on Cer t i f i cat i on link.

Obj ect i v e Sect i on / Su bsect i on
I n st al l at i on an d Upg r ade En h an cemen t s
I nst all Oracle Dat abase 11g I nst allat ion New Feat ures Support
Role and Privilege Changes
Deprecat ed Component s
New I nit ializat ion Paramet ers Af f ect ing Dat abase
Creat ion
DBCA Enhancement s
Upgrade your dat abase t o Oracle Dat abase 11g Upgrading t o Oracle Dat abase 11g
Oracle Direct NFS Oracle Direct NFS
Use online pat ching Pat ching in Oracle Dat abase Cont rol
St or age En h an cemen t s

Set up ASM f ast mirror resynch ASM Fast Mirror Resync
Underst and scalabil it y and perf ormance
enhancement s
Fast Rebalance
Miscellaneous ASM New Feat ures
Set up ASM disk group at t ribut es Diskgroup At t ribut es
Use various new manageabilit y opt ions N/ A
Use t he md_backup, md_rest ore, and ASMCMD
ext ensions
asmcmd Ut ilit y Commands
I n t el l i gen t I n f r ast r u ct u r e En h an cemen t s

Creat ing and using AWR baselines N/ A
Set t ing AWR Baseline Met ric Thresholds Set t ing Met ric Thresholds f or Baselines
Cont rol Aut omat ed Maint enance Tasks Aut omat ic Maint enance Tasks
Using Dat abase Resource Manager New Feat ures Enhancement s in Oracle Dat abase Resource Manager
Using new scheduler f eat ures Oracle Scheduler New Feat ures
Per f o r man ce En h an cemen t s

ADDM Enhancement s ADDM New Feat ures
Set up Aut omat ic Memory Management Aut omat ic Memory Management
Enhancement s in st at ist ics collect ion Changing St at ist ics Pref erences
Enhanced St at ist ics Maint enance
Part it ioning and St orage- Relat ed Enhancement s Part it ioning I mprovement s
I mplement t he new part it ioning met hods Part it ioning I mprovement s
Employ Dat a Compression Oracle Advanced Compression Opt ion
SQL Access Advisor Overview SQL Access Advisor Enhancement s
Page 118 Oracle 11g New Features for Administrators - Summary Sheets

Creat e SQL Access Advisor analysis session using
PL/ SQL
SQL Access Advisor Enhancement s
Usi n g RMAN En h an cemen t s

Managing Archive logs Conf iguring an Archived Redo Log Delet ion Policy
Duplicat ing a Dat abase Act ive Dat abase Duplicat ion
Back up large f iles in mult iple sect ions The Mult isect ion Backups
Perf orm Archival Backups Creat ing Archival Backups
Use t he md_backup, md_rest ore, and repair ASMCMD
ext ensions
asmcmd Ut ilit y Commands
Using Flashback and Logminer Oracle Flashback- Relat ed New Feat ures
Ov er vi ew of Fl ash back Dat a Ar ch i ve

Manage Flashback Dat a Archive Flashback Dat a Archive
Back- out t ransact ions using Flashback Transact ion Oracle_Flashback_Transact ion_Backout
Working wit h Logminer N/ A
Di agn osabi l i t y En h an cemen t s

Set up Aut omat ic Diagnost ic Reposit ory I nt roducing Aut omat ic Diagnost ic Reposit ory ( ADR)
Conf iguring t he ADR
Use Support Workbench Using The Support Workbench in t he OEM
Run healt h checks Dat abase Healt h Monit or
Use SQL Repair Advisor Using SQL Repair Advisor
Dat abase Repl ay

Overview of Workload Capt ure and Replay Dat abase Replay
Using Workload capt ure and replay Dat abase Replay
Using t he Dat a Recovery Advisor Dat a Recovery Advisor
Overview of Dat a Recovery Advisor Dat a Recovery Advisor
Repairing dat a f ailures using Dat a Recovery Advisor Dat a Recovery Advisor
Perf orm proact ive healt h check of t he dat abase Dat abase Healt h Monit or
Secu r i t y: New Feat u r es

Conf igure t he password f ile t o use case sensit ive
passwords
Case- Sensit ive Password Files
Encrypt a t ablespace Tablespace Encrypt ion
Conf igure f ined grained access t o net work services Fine- Grained Access Cont rol f or UTL_* Packages
Or acl e Secu r eFi l es

Use Secure File LOBS t o st ore document s wi t h
Compression, Encrypt ion, De- duplicat ion, Caching
SecureFiles
Use SQL and PL/ SQL API s t o access Secure File LOBS Accessing a LOB Using SQL and PL/ SQL
Miscellaneous New Feat ures N/ A
Descr ibe and use t he enhanced online t able
redef init ion
Online Redef init ion
Enhanced f iner grained dependency management Finer- grained Dependency Management
Page 119 Oracle 11g New Features for Administrators - Summary Sheets

Use Enhanced DDL - Apply t he improved t able lock
mechanism, Creat e invisible indexes
Explicit Locking of Tables
I nvisible I ndexes
Use Query Result Cache and PL/ SQL Result Cache Server Result Cache
Adapt ive Cursor Sharing Adapt ive Cursor Sharing
Temporary Tablespace Enhancement s Shrinking Temporary Tablespaces and Tempf iles
SQL Per f or man ce An al yzer

Overview of SQL Perf ormance Analyzer The SQL Perf ormance Analyzer
Using SQL Perf ormance Analyzer The SQL Perf ormance Analyzer
SQL Plan Management SQL Plan Management
SQL Plan Baseline Archit ect ure SQL Plan Management
Set up SQL Plan Baseline SQL Plan Management
Using SQL Plan Baseline SQL Plan Management
Au t omat i c SQL Tu n i n g

Set up and modif y Aut omat ic SQL Tuning SQL Tuning Aut omat ion
I nt erpret report s generat ed by Aut omat ic SQL Tuning N/ A
Page 120 Oracle 11g New Features for Administrators - Summary Sheets

Appendi x I I
Di spl ay i ng CLOB Cont ent s i n SQL Pl us
Many Oracle supplied packages used in dat abase administ rat ion have OUT paramet er of CLOB dat a t ype. The
f ollowing examples show how t o display CLOB dat a in SQL Pl us session:
/* Method 1 */
VAR report clob
begin
-- assign value to :report or pass it to the OUT parameter
...
end;
/

SET LONG 100000 LONGCHUNKSIZE 10000 LINESIZE 120
PRINT :report


/* Method 2 */
SET SERVEROUTPUT ON
SET LONG 100000 LONGCHUNKSIZE 10000 LINESIZE 120
declare
report clob;
begin
-- assign value to REPORT or pass it to the OUT parameter
...
dbms_output.put_line ('Report : ' || report);
end;
/

Usage Terms • Anyone is can copy this document to any means of storage and present it in any format to any individual or organization for non-commercial purpose free. • No individual or organization may use this document for commercial purpose without a written permission from the editor. • There is no warranty of any type for the code or information presented in this document. The editor is not responsible for any loses or damage resulted from using the information or executing the code in this document. • If any one wishes to correct a statement or a typing error or add a new piece of information, please send an email message to info@ahmedbaraka.com

Version History
Version Date Updates

1.0 1.1

23-Mar-2008 29-Apr-2008

Initial document. - Mapping exam objectives to the document topics - Fixing caught bugs in the code examples. - Fixing caught errata and mistakes in some statements. - Adding new topics.

1.15

12-Sep-2008 10-Oct-2008

- Further explanation on using the new PIVOT operator. - Adding minor details in some sections. - Adding the section "Adaptive Cursor Sharing" - Adding minor details in some sections. - Fixing caught errata and mistakes in some statements.

1.2

1.3 2.0

01-Mar-2010 23-Dec-2010

- Adding minor details in some sections. - Adding Oracle 11g Release 2 New Features - Removing the statement "that virtual column cannot be a part of partitioning key column". Thanks to Arshad Taqvi.

2.1

22-Jan-2010

- Removing the information about FIXED_DATE parameter as it is not a new feature. Thanks to Bhalla Ravinder.

Document Purpose
This document aims at briefly explaining Oracle Database 11g New Features with concentration on the practical code. It discusses new features related to database administration and application development. The document is edited so that it concentrates on the following: • Brief description of the concepts. This includes: o New terms and definitions. o Significant advantages and/or disadvantages o Concept limitations and precautions • Code examples

On the other hand, the document avoids the following: • • Detailed explanation of the concepts Details of using Oracle Grid Control in implementing the concepts.

Page 2

Oracle 11g New Features for Administrators - Summary Sheets

What is not covered?
The document discussed new features in Oracle 11g in only the topics as stated in the contents section. New features introduced in other areas are not covered. To mention some of them, this document does not cover the new features in the following areas: • • • • Oracle Streams Data Guard Oracle RAC Oracle XML DB

Prerequisite
To be able to get advantage of reading this document, you must have solid knowledge on Oracle database 10g administration.

Terms and Acronyms Used
Following are list of the terms and acronyms used in this document:
Term / Acronym Meaning

Oracle 11g

Whenever Oracle 11g is mentioned in this document, it is meant to be Oracle Database 11g. Automatic Diagnostic Repository Oracle Grid Control, Database Control or Oracle Enterprise Manager (OEM) are used interchangeably in this document.

ADR Oracle Grid Control

Conventions in the Document
When you are asked to click on several links in the Enterprise Manager, the term "follow the links" is used. For example, consider the following statement: To manage created SQL patches, follow the links Database Home page> Server tab> Query Optimizer section> SQL Plan Control> SQL Patch tab This statement means, in the Database Home page you click Server tab where you will see Query Optimizer section. Then you click on SQL Plan Control and then on the SQL Patch tab.

Resources
S/N Resource Type Resource Name

1 2 3

Book Book Oracle Official Documentation

Oracle Database 11g New Features for DBAs and Developers, by Sam R. Alapati and Charles Kim, Apress, ISBN: 978-1-59059-910-5 Oracle Database 11g New Features by Rober G. Freeman, Oracle Press • Oracle Database New Features Guide 11g Release 2 (11.2) E17128-03 • Oracle Database New Features Guide 11g Release 1 (11.1) B28279-02 • Oracle Database Administrator's Guide 11g Release 1 (11.1) B28310-03 • Oracle Database Performance Tuning Guide 11g Release 1 (11.1) B28274-01 • Oracle Database Backup and Recovery User's Guide 11g Release 1 (11.1) B28270-02 • Oracle Database PL/SQL Packages and Types Reference 11g Release 1 (11.1.) B28419-02 • Oracle Database High Availability Overview 11g Release 1 (11.1) B28281-01 • Oracle Database Storage Administrator's Guide 11g Release 1 (11.1) B31107-03 • Oracle Database PL/SQL Language Reference 11g Release 1 (11.1) B28370-02 • Oracle Database VLDB and Partitioning Guide 11g Release 1 (11.1) B32024-01 • Oracle Database SecureFiles and Large Objects Developer's Guide 11g Release 1

Page 3

Oracle 11g New Features for Administrators - Summary Sheets

(11.1) B28393-02 4 Oracle Metalink The following documents were referenced: • Note:453487.1 • Note:454631.1 • Note:445116.1 • Note:470199.1 • Note:444149.1 Title: 11g New Features : Top 5 Features In 11g Title: 11g DBCA New features / Enhancements Title: Using the workload capture and replay in 11G Title: 11g feature: Flashback Data Archive Guide Title: New Background Processes In 11g

• Note:432776.1 11g New Feature : Transparent Data Encryption at Tablespace Level 5 6 7 8 9 10 11 12 13 14 15 Web Site Web Site Web Site Web Site Web Site Web Site Articles by Arup Nanda Blog Site Blog Site Blog Site Blog Site www.oracle-base.com www.psoug.org www.orafaq.com http://technology.amis.nl http://decipherinfosys.wordpress.com/2007/12/03/oracle-11g-cross-tab-reportusing-pivot-and-unpivot-operator http://www.fadalti.com/oracle/database/oracle_database_11g_new_features.htm http://www.oracle.com/technology/pub/articles/oracle-database-11g-topfeatures/index.html http://bar-solutions.com/wordpress/ http://virag.sharma.googlepages.com/11g http://viveklsharma.blogspot.com http://antognini.ch/blog

Page 4

Oracle 11g New Features for Administrators - Summary Sheets

Contents

Installation, Database Upgrades and Change Management

9

Installation New Features Support ______________________________________________________ 9 Role and Privilege Changes ____________________________________________________________ 9 Deprecated Components _____________________________________________________________ 10 New Initialization Parameters Affecting Database Creation __________________________________ 10 DBCA Enhancements ________________________________________________________________ 11 Upgrading to Oracle Database 11g _____________________________________________________ 11 Database Replay ___________________________________________________________________ 13 The SQL Performance Analyzer ________________________________________________________ 17 Patching in Oracle Database Control ____________________________________________________ 21

Database Diagnosis and Repair_________ 22
Introducing Automatic Diagnostic Repository (ADR) ________________________________________ 22 Configuring the ADR ________________________________________________________________ 22 Using adrci Tool ____________________________________________________________________ 22 Using The Support Workbench in the OEM _______________________________________________ 24 Database Health Monitor _____________________________________________________________ 25 Data Recovery Advisor_______________________________________________________________ 26 SQL Test Case Builder _______________________________________________________________ 27 Data Block Corruption Parameters _____________________________________________________ 28

Database Administration _____________ 29
Automatic Memory Management _______________________________________________________ 29 Automatic Maintenance Tasks _________________________________________________________ 30 Oracle Flashback-Related New Features _________________________________________________ 32 LogMiner Interface in Oracle Enterprise Manager __________________________________________ 32 Oracle Flashback Transaction Backout __________________________________________________ 32 Flashback Data Archive ______________________________________________________________ 33 Virtual Columns ____________________________________________________________________ 35 New Data Partitioning Schemes________________________________________________________ 36 DDL Lock Timeout __________________________________________________________________ 36 Explicit Locking of Tables _____________________________________________________________ 36 Invisible Indexes ___________________________________________________________________ 36 Read-Only Tables ___________________________________________________________________ 37 Deferred Segment Creation ___________________________________________________________ 37 Shrinking Temporary Tablespaces and Tempfiles __________________________________________ 37 Creating an Initialization Parameter File from Memory ______________________________________ 38 Restore Point Enhancements __________________________________________________________ 38 Database Resident Connection Pooling __________________________________________________ 38 Comparing and Synchronizing Database Objects __________________________________________ 40 Page 5

Oracle 11g New Features for Administrators - Summary Sheets

SQL*Plus New Features ______________________________________________________________ 41 Online Application Maintenance ________________________________________________________ 42 Oracle Advanced Compression Option ___________________________________________________ 42 Oracle Scheduler New Features ________________________________________________________ 43 Lightweight Jobs ___________________________________________________________________ 44 Remote External Jobs _______________________________________________________________ 44 Monitoring Job State with Email Notifications _____________________________________________ 45 File Watcher _______________________________________________________________________ 47 Finer-grained Dependency Management _________________________________________________ 50 Enhancements in Oracle Database Resource Manager ______________________________________ 50 Enhanced TRUNCATE Statement _______________________________________________________ 51 Dropping Unused Object Storage ______________________________________________________ 52

Performance Tuning _________________ 53
PL/SQL Native Compilation ___________________________________________________________ 53 Server Result Cache_________________________________________________________________ 54 Client Side Result Cache _____________________________________________________________ 56 Enhanced Oracle Process Monitoring ____________________________________________________ 57 Subprogram Inlining ________________________________________________________________ 58 SQL Tuning Automation ______________________________________________________________ 58 SQL Access Advisor Enhancements _____________________________________________________ 59 Changing Statistics Preferences _______________________________________________________ 63 Enhanced Statistics Maintenance_______________________________________________________ 63 SQL Plan Management _______________________________________________________________ 66 ADDM New Features ________________________________________________________________ 69 AWR New Features _________________________________________________________________ 72 Setting Metric Thresholds for Baselines __________________________________________________ 74 Performance-Related Changes in Database Control ________________________________________ 74 Miscellaneous New Performance Tuning Features __________________________________________ 74 Real-Time SQL Monitoring ____________________________________________________________ 75 Adaptive Cursor Sharing _____________________________________________________________ 76

Database Security ___________________ 77
Stronger Password Hash Algorithm _____________________________________________________ 77 Security Out of the Box ______________________________________________________________ 77 Anti Network Attacks Parameters ______________________________________________________ 78 Tablespace Encryption _______________________________________________________________ 79 Fine-Grained Access Control for UTL_* Packages __________________________________________ 80 Further Security New Features ________________________________________________________ 81

Backup and Recovery New Features _____ 83
Enhanced Block Media Recovery _______________________________________________________ 83 RMAN Substitution Variables __________________________________________________________ 83

Page 6

Oracle 11g New Features for Administrators - Summary Sheets

Summary Sheets .New RMAN Configuration Parameters ___________________________________________________ 84 The Multisection Backups_____________________________________________________________ 84 Creating Archival Backups ____________________________________________________________ 85 VALIDATE Command ________________________________________________________________ 85 Configuring an Archived Redo Log Deletion Policy _________________________________________ 86 Active Database Duplication __________________________________________________________ 86 Importing and Moving Recovery Catalogs ________________________________________________ 88 Virtual Private Catalogs ______________________________________________________________ 89 Miscellaneous New Features in RMAN ___________________________________________________ 90 Data Pump Utilities __________________ 91 Compression Enhancement ___________________________________________________________ 91 Encryption Enhancements ____________________________________________________________ 91 Reusing a Dump File ________________________________________________________________ 92 Remapping Data ___________________________________________________________________ 92 Renaming Tables During Export or Import _______________________________________________ 92 Data Pump and Partitioned Tables______________________________________________________ 92 Ignoring Nondeferred Constraints ______________________________________________________ 93 External Tables Based on Data Pump Driver ______________________________________________ 93 Enhancement in the Transportable Parameter ____________________________________________ 93 Automatic Storage Management (ASM) __ 94 SYSASM Privilege and OSASM Group ___________________________________________________ 94 Upgrading ASM using DBUA __________________________________________________________ 94 Upgrading ASM Manually _____________________________________________________________ 94 ASM Restricted Mode ________________________________________________________________ 95 Diskgroup Attributes ________________________________________________________________ 95 Checking Diskgroup _________________________________________________________________ 97 asmcmd Utility Commands ___________________________________________________________ 98 Fast Rebalance _____________________________________________________________________ 99 The FORCE option with Drop Diskgroup Command _________________________________________ 99 Miscellaneous ASM New Features ______________________________________________________ 99 PL/SQL New Features _______________ 101 PL/SQL New Features ______________________________________________________________ 101 Data Warehousing _________________ 107 SecureFiles _______________________________________________________________________ 107 Accessing a LOB Using SQL and PL/SQL ________________________________________________ 108 Online Redefinition _________________________________________________________________ 109 Partition Change Tracking (PCT) ______________________________________________________ 110 Generating SQL Crosstab Report using PIVOT Operator ____________________________________ 110 Partitioning Improvements __________________________________________________________ 112 Page 7 Oracle 11g New Features for Administrators .

Summary Sheets .Appendix I Mapping Exam 1Z0-050 Objectives to Document Topics 117 Appendix II Displaying CLOB Contents in SQL Plus 120 Page 8 Oracle 11g New Features for Administrators .

Oracle recommends you choose the same ADR base for all Oracle products. Page 9 Oracle 11g New Features for Administrators . refer to the documentation "Oracle Database Backup and Recovery User's Guide" and Chapter 8 in "Oracle Database Platform Guide for Microsoft Windows" • Other Install Options o Oracle Data Mining option is selected by default with the Enterprise Edition installation and is automatically installed when you create a database. ADR location is controlled by the new initialization parameter DIAGNOSTIC_DEST. Role and Privilege Changes In Oracle 11g. Oracle recommends you grant ASM access only to members of the osasm group. • New Components Following are new components which are available when installing Oracle 11g: o Oracle Application Express (APEX): APEX is a rapid application development tool for developing database centric web-based applications. Also. you can create osasm OS group. In Oracle 11g. • Automatic Diagnostic Repository (ADR) ADR is a single directory location for all error and trace data in the database. o Oracle XML DB is now a mandatory component and thus its option is removed from the installation. in Oracle 11g for Unix/Linux operating systems. Database Upgrades and Change Management Installation New Features Support Following are the changes you will face when installing Oracle Database 11g: • Choosing Oracle Base location Oracle Base (set by the environment variable ORACLE_BASE) is the top-level directory for installing Oracle software. o Oracle Warehouse Builder: it is a business intelligence (BI) design tool and is automatically installed as part of the Oracle database software. In Oracle 10g. It replaces the traditional diagnostic directories such as bdump. It is automatically installed. Oracle Universal Installer now allows you to specify and edit Oracle base location. For further details about using this privilege. there is a new system privilege called SYSASM. For details on using VSS. This service is an infrastructure that enables the users to create snapshots called shadow copies. Be aware that if you upgrade existing database to version 11g. it is used to be saved under Oracle home directory. refer to the chapter "Automatic Storage Management". In Oracle 11g. a service named as Volume Shadow Copy Service (VSS) is installed. you must select the Custom installation option. This option includes two solutions to test the effect of the system changes on the real-world applications: Database Reply and SQL Performance Analyzer. If you install Oracle database 11g software with the option of creating a database and you do not specify a value to ORACLE_BASE. if you create a template-based database. and udump. • Datafile and Flash Recovery Area Locations By default.Installation. Datafiles and flash recovery area are located one level below the Oracle base location. CONNECT role has now only CREATE SESSION privilege. o Oracle Database Vault: Oracle Database Vault component enables you to secure business data even from DBAs. o Oracle Configuration Manager (OCM): OCM is an optional component and it collects information about software configuration in the Oracle home directories and uploads it to the Oracle configuration repository. the installation proceeds with the default value but a message will be logged in the alert log file. CONNECT role will be modified by the upgrade script to have only CREATE SESSION privilege. This privilege should be granted to users who need to perform ASM administrative tasks. it is a component available during installation and to install it. it is highly enhanced and available in the Oracle database CD. Oracle recommends you to specify the same Oracle base for multiple Oracle homes. o Oracle Real Application Testing: Oracle Real Application Testing option is automatically installed with the Enterprise Edition installation. cdump.Summary Sheets . Both of those solutions will be discussed in later sections. o Oracle Shadow Copy Service: When you install Oracle 11g on Windows 2003 servers. o Oracle SQL Developer: Oracle SQL Developer is a graphical tool for examining database objects and issuing SQL commands.

is introduced. You set it by the new parameter DIAGNOSTIC_DEST. • Memory Parameters In Oracle 11g. DB_BLOCK_CHECKSUM. the value of the DIAGNOSTIC_DEST parameter defaults to $ORACLE_HOME/log. • DDL Lock Timeout The new parameter DDL_LOCK_TIMEOUT controls length of time a DDL statement waits for a DML lock. Using this parameter will be discussed in DDL Lock Timeout section. It replaces USER_DUMP_DEST. RESULT_CACHE_MAX_SIZE.Summary Sheets . • Result Cache Parameters In Oracle 11g. BACKGROUND_DUMP_DEST and CORE_DUMP_DEST parameters. data and index medium typical full The effective value of the parameters will be as follows: Parameter Active Value DB_BLOCK_CHECKING DB_LOST_WRITE_PROTECT DB_BLOCK_CHECKSUM. This memory area stores results of frequently run queries. To enable this feature. Page 10 full typical full Oracle 11g New Features for Administrators . Both the system global area (SGA) and the program global area (PGA) will expand and shrink based on the instance demands. a new memory component. • Automatic Diagnostic Repository (ADR) ADR is a directory that points to all error data raised in the database. It also saves results of PL/SQL function results. named as result cache. RESULT_CACHE_REMOTE_EXPIRATION. this parameter sets the maximum value you can set for MEMORY_TARGET parameter. Using those parameters will be discussed in Server Result Cache and Client Side Result Cache sections. Notice that this section is not meant to list all the new initialization parameters. RESULT_CACHE_MAX_RESULT. • The DB_ULTRA_SAFE Parameter This parameter is used to set the effective values of the parameters: DB_BLOCK_CHECKING. The effective value of the parameters will be as follows: Parameter Active Value data only DB_BLOCK_CHECKING DB_LOST_WRITE_PROTECT DB_BLOCK_CHECKSUM. CLIENT_RESULT_CACHE_SIZE and CLIENT_RESULT_CACHE_LAG. you set the following new parameters: MEMORY_TARGET this parameter sets the system-wide usable memory that will be used by the instance for SGA and PGA. DB_LOST_WRITE_PROTECT. Parameters used to control result cache are: RESULT_CACHE_MODE. in Oracle 11g some new initialization parameters are introduced and some parameters are deprecated. DIAGNOSTIC_DEST defaults to the following value: $ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID If you haven’t set the ORACLE_BASE variable. MEMORY_MAX_TARGET Further details about using those parameters will be discussed in Automatic Memory Management section. This parameter takes one of the following values: off this value means any values you set for any of the three parameters will not be overridden. the automatic memory management feature is developed. Further details about using this parameter will be discussed in ADR section.Deprecated Components Following are the components deprecated in Oracle 11g: o iSQL*Plus o Oracle Workflow o Oracle Enterprise Manager Java Console o Oracle Data Mining Scoring Engine o Raw storage support (installer only) New Initialization Parameters Affecting Database Creation As with any new Oracle database version. In this section we will introduce those new parameters you may set while creating an Oracle 11g database.

6 -> 9. However.5 -> 8. 10.0.1 and 10.0.3.2.3 -> 7. The data mining schema are by default created when the catproc.2.4 -> 9.8 -> 11.1.sql script is run. if you upgrade to 11g and keep the COMPATIBLE parameter to 10.0. DBCA provides the Enterprise Manager Configuration plug-in.8 -> 11.04 or newer.1.7. Following is a list of new DBCA pages in Oracle 11g: • Security Settings In this page you can set the created database to use the new enhanced default security settings in Oracle 11g.3 (or lower) -> 9. Otherwise. 9i and 10g.Summary Sheets .1 8.0. • New Memory Management You can enable using the new automatic memory management feature by specifying amount of memory to be used by both SGA and PGA.• Security Parameters Oracle 11g introduces two important security parameters.0. DBCA asks you to create one with the Net Configuration Assistant tool. In other words. • Creating a Listener If you choose to configure the Enterprise Manager.7 -> 8.8 -> 11. password profiles and revoking grants from the public role.0.0. upgrade to Oracle 11g with a minimum value of the COMPATIBLE parameter of 10.0. Oracle drops the connection after the number of login attempts fail for any user.1. DBCA go through steps similar to the one in Oracle 10g. it supports direct upgrade to versions 9. DBCA will search for a listener configured in the Oracle home.2.3-> 9. you no longer see the Data Mining in the DBCA as an option to configure.0.2. you can configure the following options when using DBCA: a) Oracle Application Express b) Oracle Database Vault c) Oracle Warehouse Builder Also. only a small portion of the new features will be available.2.2. however.0.0. Page 11 Oracle 11g New Features for Administrators . Upgrading to Oracle Database 11g Upgrade path You can directly upgrade to Oracle 11g. Those settings are part of a database option named as Secure Configuration.1 9.2.4 -> 9. You can. • Configuring New Database Options In Oracle Database 11g. Following table illustrated those parameters and their usages: Parameter Description Default Value SEC_CASE_SENSITIVE_LOGON SEC_MAX_FAILED_LOGIN_ATTEMPTS to enable or disable password case-sensitivity.2.1 Oracle 11g client can access Oracle databases of versions 8i.0. • Switching a Database from Database Control to Grid Control Configuration With Oracle Database 11g.8 -> 11. • Network Configuration In Oracle 11g. DBCA allows you to select the listener(s) for which to register the new database. You can still configure the Secure Configuration option later by invoking the DBCA.3.8 -> 11. Those settings include audit settings.4 -> 9.1 9.0. the database will be created with the default security options as for Oracle Database 10g Release 2.2.1. Upgrade process and COMPATIBLE parameter The default compatibility value for Oracle 11g is 11. If no listener was found. If you choose to disable those security settings. which automates the process to switch configuration of a database from Database Control to Grid Control.0.1 8. if you current database is 9.4.1. you should follow one of the upgrade paths: 7.0. specified true 10 DBCA Enhancements In Oracle 11g.

Rum utlu111s.sql and utlu111x. and LD_LIBRARY_PATH so that they point to the new Oracle Database 11g directories. perform the following steps: a) b) c) Stop the Oracle database service. SQL>spool upgrade11g. 10. 13. perform the following steps: 1. When the upgrade script successfully finishes. oradim -NEW –SID <sidname> 8. restart the database in OPEN mode.ora SQL>spool upgrade11g. Invoke the Pre-Upgrade Information Tool in the database to upgrade. Start the database in upgrade mode and then run the upgrade script (it takes long time). This tool is simply the script $ORACLE_HOME/rdbms/admin/utlu111i.Manual Upgrade Procedure To manually upgrade a database from 10g to Oracle 11g. change to directory $ORACLE_HOME/rdbms/admin and then start the SQL*Plus 11. Usually errors are raised because of lack of shared memory or tablespace size. make sure no error occurred during the upgrade. After the upgrade script finishes. PATH. 9. Usually its name has the format OracleService<SID>. SQL>spool off 12. You can do so by issuing the following command: ALTER SYSTEM SET COMPATIBLE='11.1. oradim -delete –SID <sidname> Use oradim utility in the Oracle 11g home to create a new Oracle Database 11g release instance.log SQL>@utlu111i.sql script (referred to as Post-Upgrade Status tool) to view the results of the upgrade. In the Oracle 11g home.Summary Sheets .. You can use the oradim utility for this purpose. 14. Delete the service. you have to copy this script altogether with the scripts: utlu111s. 6.sql . As with previous versions. Set the COMPATIBLE parameter to 11.1. Modify the values of the initialization parameters and remove the obsolete parameters as recommended by the Pre-upgrade tool in the current initialization parameter file. Change the environment variables ORACLE_HOME. Oracle allows only SYSDBA connections and sets some initialization parameters to specific values that are required to run the upgrade script. When working in upgrade mode. If you see a component with invalid status. setting proper values to some parameters and adding space to key tablespaces. If the database is installed in a Windows system. Copy the initialization parameter file to the new Oracle 11g home..sql . Backup the database. This tool will view the installed components and their status.0' SCOPE=SPFILE. Of course.log SQL>@ catupgrd. move it to the new Oracle 11g home. fix its cause and restart the upgrade script.. Spool the output of running the script for later review. 7. If the database to upgrade is using a password file. 3. SQL>spool off 2. Shutdown cleanly the database.0. If there is any error. 4. 5. SQL>login sys/password as sysdba SQL>startup upgrade pfile=$ORACLE_HOME/dbs/initorcl. usually running the script in the next step will set it to valid. So. it should use the same SID. Page 12 Oracle 11g New Features for Administrators .sql to a staging directory in the database to upgrade. this tool will examine the target database and display the warnings and recommendations that you should consider before you start the upgrade process such as removing obsolete initialization parameters.sql..

These changes could be database upgrades. with this feature you can capture the actual workload on a production system and replay it in a test system. external tables. Upgrading with the DBUA Database Upgrade Assistance (DBUA) is a GUI utility that facilitates upgrade process. In manual method.15. SQL>@utlrp. practical step to implement those phases will be discussed. database links. In other words. Typically.sql to in parallel recompile any invalid PL/SQL program unit and Java code. you use a utility named as Workload Replay Client. you apply the changes on the test system. If the upgrade process fails. 16. 2. Analysis and Reporting: when the step above successfully finishes. This feature enables you to test the impact of applying changes on a production database. Oracle streams. Data Captured by Database Reply Following is a list of data changes captured by Database Reply: • • • • DML statements DDL statements Session control calls (such as ALTER SESSION) System control calls (such as ALTER SYSTEM) Data Not Captured by Database Reply The following data changes are not captured by Database Reply: • • • • • • Flashback queries Scheduled jobs Shared Server requests Non PL/SQL AQ Direct path load from external files using SQL*Loader. taking that tablespace offline may lead to degrading the database performance. Workload Preprocessing: this is to convert the captured workload into replay files. Then you start the Workload Replay process where you replay the production workload in the test database. operating system upgrades or storage system changes. type wrc in the command line. switching to RAC.sql SQL>SELECT COUNT(*) FROM DBA_INVALID_OBJECTS. Because the upgraded database disables all tablespace alerts by setting the threshold to null. you have to upgrade them separately. after the step above. It just now has a screen asking you to define the diagnostic directory. This way. Thus. set the thresholds for tablespace alert to the values you desire. Workload Capture: this is when you record the production database workload. you can analyze the condition of the production database without working on the actual production database. 3. Database Replay Database Replay (sometimes named as Workload Replay) feature in Oracle 11g allows you to reproduce the production database conditions in a testing environment. 4. Beside its simplicity. application upgrades. you generate report on the errors and performance influence. To invoke the utility. non-SQL-based object access and distributed transactions. Execute the script utlrp. Note The database upgrade process moves SQL profiles to SYSAUX tablespace. To interface with Workload Replay feature in the database. DBUA has an advantage of being able to upgrade both the database instance and the ASM instance simultaneously. restore the database from the backup. In the following sections. Distributed transactions Page 13 Oracle 11g New Features for Administrators .Summary Sheets . Using Database Replay consists of four phases: 1. DBUA works in 11g in a similar way to it in 10g.

Any transaction that is underway when you start capturing the workload may not be captured. To achieve this task. For a filter with the STATUS of USED. DIR => 'WORKLOAD_DIR'. FATTRIBUTE => 'USER'. If you want to capture all transactions. begin v_capture_id := DBMS_WORKLOAD_CAPTURE. issue the following command: exec DBMS_WORKLOAD_CAPTURE. STATUS. it means the filter is deleted. FORMAT => DBMS_WORKLOAD_CAPTURE. FVALUE => 'SYSTEM. : SELECT NAME.FINISH_CAPTURE. begin DBMS_WORKLOAD_CAPTURE. Use ADD_FILTER procedure to add any eliminating sessions based on USER.Summary Sheets . To stop the capture process before ending of duration period. MODULE.DBSNMP' ). -.TYPE_TEXT). The DBA_WORKLOAD_FILTERS view provides you information about existing filters.display contents of v_capture_rpt end. Data Pump utilities or a snapshot standby. Backup database data that you want to test. 2. -. you can issue query about workload captures using the following command: SELECT ID. Oracle Enterprise Manager sessions or any sessions created by third party clients. CREATE DIRECTORY workload_dir AS 'C:\Oracle\admin\ora11g\workload'. PROGRAM. b. start the capture process. perform the following steps: 1.duration in seconds end. It is recommended to record the time in the system just before issuing the command. 3. NAME. v_capture_rpt clob. SERVICE or INSTANCE_NUMBER: begin DBMS_WORKLOAD_CAPTURE. DURATION => 2400).REPORT( CAPTURE_ID => v_capture_id .GET_CAPTURE_INFO(DIR => 'WORKLOAD_DIR'). Use DELETE_FILTER procedure to delete any existing filter: => 'FILTER_DBA1'). Use either RMAN. Page 14 Oracle 11g New Features for Administrators . You may not need to capture DBA sessions. user-managed online backup.FINISH_CAPTURE. If you set the DURATION parameter to NULL. You can generate a report about the workload capture you have made: declare v_capture_id number. c. This backup will be used later to create a testing environment in a state similar to the production database for the replay process. v_capture_rpt := DBMS_WORKLOAD_CAPTURE. EXEC DBMS_WORKLOAD_CAPTURE. end.START_CAPTURE( NAME => '1JAN_WORKLOAD'. use DBMS_WORKLOAD_CAPTURE package as shown in the following steps: a. it means that workload capture will continue until the user executes DBMS_WORKLOAD_CAPTURE. ATTRIBUTE.ADD_FILTER( FNAME => 'FILTER_DBA1'. ERROR_MESSAGE FROM DBA_WORKLOAD_CAPTURES. 4. Decide whether some of the user sessions should not be captured.DELETE_FILTER( FNAME Capturing Workload Use START_CAPTURE procedure in DBMS_WORKLOAD_CAPTURE package to start capturing the workload. Create directory object for storing captured workload.format could also be TYPE_HTML -.Preparing for Capturing Workload Before you capture the workload. VALUE FROM DBA_WORKLOAD_FILTERS. then open the database for users. After capture process finishes. ACTION. you should restart the database in restricted mode.

SELECT DBMS_WORKLOAD_CAPTURE. query the view DBA_WORKLOAD_CONNECTION_MAP. external tables. If you want to take a new workload capture with the same name. name. this connection should be remapped in the test database so that it connects to the desired database.Alternatively. Remapping Connections: if any session in the production database during the workload capturing used a connection to access an external database. 3. The target is to make the same application become in the same state as it has been in the production database.INITIALIZE_REPLAY( REPLAY_NAME =>'1JAN_WORKLOAD'. Replaying Workload is done by performing of the following steps: 1. status FROM DBA_WORKLOAD_CAPTURES. Following are the three options (set by parameters) that can be configured with this procedure: a. you can use the following statements: SELECT id. To display the connection mapping information for a workload replay. Workload replay process will read from those tables when it operates.Summary Sheets . Use the PROCESS_CAPTURE procedure to process the workload data: exec DBMS_WORKLOAD_REPLAY. in the test database to the required connection strings. Page 15 Oracle 11g New Features for Administrators . 4. end. CAPTURE_CONN. Preprocessing includes the following steps: 1. Replaying the Workload Typically. If you want to delete from its data dictionary views. REPLAY_CONN FROM DBA_WORKLOAD_CONNECTION_MAP To remap connection string REMAP_CONNECTION procedure. Preprocessing Workload Capture Data To be able to replay a Workload Capture. However. It is recommended to set the time of the test system to the time when the workload was captured on the production system. If you know that transactions in your workload capture are independent. if any.REMAP_CONNECTION ( CONNECTION_ID =>1. this procedure does not delete the workload capture files in its directory. you should manually get rid of its files otherwise an error will be returned when you execute START_CAPTURE procedure. Preparing the Workload Replay: this is done with the procedure PREPARE_REPLAY. Restore the test database from the backup you made in the production database. you can set this parameter to FALSE. i. at this stage. SYNCHRONIZATION: (default TRUE) Ensure the replay observes the commit sequence of the capture. 2. CONN_ID. REPLAY_CONNECTION => 'myprod:1521/mydb' ). used the procedure DELETE_CAPTURE_INFO. Initializing the replay data is done by invoking the procedure INITIALIZE_REPLAY begin DBMS_WORKLOAD_REPLAY. This is to avoid any invalid time-based data or job-scheduling issues. Take steps to resolve. and URLs. you must preprocess its data. 4. -.REPORT(1.PROCESS_CAPTURE('REPLAY_DIR'). external references including: database links. Initialize the Replay Data: this process means metadata will be read from Workload Capture files and loaded into tables. 'HTML') FROM DUAL. you perform the changes you want to undertake on the system. Then you start the replay process. 2. 3. end. REPLAY_DIR =>'REPLAY_DIR').e. 5. any work is run only after dependent commits in the replay are completed. practically it is done in a test database. directory objects. you use begin DBMS_WORKLOAD_REPLAY. SELECT REPLAY_ID. CREATE DIRECTORY replay_dir AS 'c:\oracle\admin\ora11g\replay'. Create a directory object in the test database to hold the workload capture data files.directory name should always be in upper case. Move the workload data files from the production database to the created directory in the test system. Although it is possible to preprocess in the production database.

issuing the following code: declare v_cap_id v_rep_id v_rpt begin v_cap_id NUMBER. o You can obtain information about the workload replays. Page 16 Oracle 11g New Features for Administrators . use CANCEL_REPLAY procedure. HTML end. for any reason. Below is a code example: exec DBMS_WORKLOAD_REPLAY. which will attempt to connect all sessions as captured. o After workload replay finishes.b. THINK_TIME_SCALE: (default 100) think time is the elapsed time while the user waits between issuing calls. /* Get the latest replay */ SELECT MAX(ID) INTO v_rep_id FROM DBA_WORKLOAD_REPLAYS WHERE CAPTURE_ID=v_cap_id. you want to cancel the replay process before it finishes. The PREPARE_REPLAY procedure puts the database server in PREPARE mode.START_REPLAY(). run the wrc in the calibrate mode as shown below: wrc system/<password> mode=calibrate replaydir=C:\Oracle\admin\ora11g\replay Then. CONNECT_TIME_SCALE: (default 100) this parameter uses the elapsed time between the time when the workload capture began and when sessions connect. := DBMS_WORKLOAD_REPLAY. This will make the replay client shorten the think time between calls.or XML. You may need to run more wrc from more than one host. if the workload capture has data of 400 sessions and a single host can handle only 150 sessions. For example. run wrc in replay mode (the default) on the client host(s): wrc system/<password> mode=replay replaydir=C:\Oracle\admin\ora11g\replay 7. If user calls are being executed slower during replay than during capture. 6. If. you can query V$WORKLOAD_REPLAY_THREAD view to list information about all sessions from the replay clients.PREPARE_REPLAY ( SYNCHRONIZATION => FALSE ). use the THINK_TIME_SCALE parameter to scale user think time during replay.TYPE_TEXT). You can use this option to manipulate the session connect time during replay with a given percentage value. v_rpt := DBMS_WORKLOAD_REPLAY. To know how many hosts and wrc clients you need to operate for your workload capture. NUMBER. by querying the view DBA_WORKLOAD_REPLAYS. c. o Exported snapshots can be imported into the AWR schema owned by SYS user using IMPORT_AWR procedure. all AWR snapshots related to the replay time period is automatically exported. so that the overall elapsed time of the replay will more closely match the captured elapsed time. CLOB. you start generating a report about it.GET_REPLAY_INFO(DIR=>'REPLAY_DIR').Summary Sheets . Starting Replay Client(s): replay client (represented by the executable wrc) controls the replay of the workload data. This depends on the maximum number of sessions that a single wrc thread can handle and the total number of sessions captured by the workload capture. notice the following: o While the workload is replaying. FORMAT => DBMS_WORKLOAD_REPLAY. Setting this parameter to 0 will attempt to connect all sessions immediately. after they finish. The default value is 100. -. in this case you need three hosts with wrc installed and run on each. Start the replay process using START_REPLAY procedure (notice that wrc client(s) were previously started): exec DBMS_WORKLOAD_REPLAY. For the workload replay. To generate the report.REPORT( REPLAY_ID => v_rep_id. Analyzing Workload Replay Report After the workload finishes. The report is the desired output of the whole process and will assist you on measuring the difference between the production and test systems or catching any errors during the workload replay. To control replay speed. you can make the database replay attempt to catch up by setting the THINK_TIME_AUTO_CORRECT parameter to TRUE (the default). This can also be done manually using EXPORT_AWR procedure.

The following example illustrates how to load UPGRADE_STS from an AWR baseline called peak baseline. 5. including the cursor cache. NULL. Create STS using the following code: begin DBMS_SQLTUNE. The SQL Performance Analyzer The SQL Performance Analyzer (SPA) aims at measuring the impact of applying any change on the database on the performance of the SQL statements execution. SPA can be invoked from OEM or using DBMS_SQLPA package. Measure the performance of the workload before the change. -. you perform the following phases: 1. declare baseline_cur DBMS_SQLTUNE. Following are the steps to do so: 1. SQL text and execution frequency.LOAD_SQLSET( SQLSET_NAME=>'UPGRADE_STS'. It is recommended to make an identical copy of the production database.Summary Sheets . NULL. 3. begin -. Automatic Workload Repository (AWR). Note If you plan to use SPA on a test database. -. STS contains information about the captured statements such as execution context.SELECT_WORKLOAD_REPOSITORY( 'peak baseline'. follow the links: Software and Support page> Real Application Testing> Database Replay> in the Go to Task column. POPULATE_CURSOR=>baseline_cur). Using this tool is explained here because you may consider using it to study the effect of upgrading an Oracle database 10g release 2 to 11g.Next the statements and their statistics are loaded into the STS DBMS_SQLTUNE.current user is the default end. apply the change on the test database then use SPA on the test database to measure the influence of the applied changes. 2. The data has been filtered to select only the top 30 SQL statements ordered by elapsed time. Make a change. and existing SQL Tuning Sets. DESCRIPTION =>'To test upgrade to 11g'. click the Replay Workload task icon.SQLSET_CURSOR. it is highly recommended to make the test database resemble the production database as closely as possible. Compare performance. Using OEM. Capturing the Production System SQL Workload You capture the SQL Workload that you intend to analyze and store its statements into a SQL tuning set (STS). end. To use SPA. 4.CREATE_SQLSET( SQLSET_NAME => 'upgrade_sts'. NULL. You can load SQL statements into a STS from different sources. it provides you recommendations on how to improve their performance. NULL. 2. Measure the performance of the workload after the change. You can use the RMAN duplicate command for this purpose. If it finds out performance degradation in one or more SQL statements. Steps that should be followed to perform those phases are explained in the following sections. SQLSET_OWNER =>'SYS'). Capture the SQL workload. Page 17 Oracle 11g New Features for Administrators . 'elapsed_time'. This is very useful for a DBA to analyze how a change on the database (including database upgrade) may affect the execution efficiency of SQL statements.Replaying a Database Workload Using Enterprise Manager To replay a database workload using Enterprise Manager.a ref cursor is opened to select from the specified baseline OPEN baseline_cur FOR SELECT VALUE(p) FROM TABLE (DBMS_SQLTUNE.NULL.30 )) p. you can also monitor an active workload replay and view a completed workload replay.

STAGING_TABLE_NAME =>'sts_table'). NULL.LOAD_SQLSET( SQLSET_NAME=>'UPGRADE_STS'. ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='10. NULL. begin -. Export the staging table from the production database and import it to the test database using Data Pump export and import utilities.4.2. end. end. REPLACE => TRUE. NULL.The following example loads UPGRADE_STS with SQL statements that are not owned by SYS and their elapsed time is greater than 20. This enables you to make SPA generate statistics for 10g database. Actually. Import the STS data from the staging table to the test database as shown in the example below: begin DBMS_SQLTUNE.2. NULL.0' Page 18 Oracle 11g New Features for Administrators .1. Note We are using SPA in this scenario to analyze SQL involved in a STS. begin v_task := DBMS_SQLPA. If you are using a test database. If you are using SPA to examine the influence of upgrading a 10g database to 11g. Create a tuning task for the created STS as show in the example code below: declare v_task varchar2(100). 4.Summary Sheets . you can also use it to analyze a given single SQL statement.CREATE_STGTAB_SQLSET( TABLE_NAME =>'sts_table'). -. end. a statement in the cursor cache or SQL statements in a workload repository in a given a range of snapshot identifiers 5. declare sql_cur DBMS_SQLTUNE. POPULATE_CURSOR=>sql_cur). 3.NULL.0.UNPACK_STGTAB_SQLSET( SQLSET_NAME => '%'.1. 3. end. This can be done by performing the following steps: 3. 3.2.a ref cursor is opened to select the required SQL statments OPEN sql_cur FOR SELECT VALUE(p) FROM TABLE (DBMS_SQLTUNE.CREATE_ANALYSIS_TASK( SQLSET_NAME => 'UPGRADE_STS'. you should transport the STS created in the previous step to the test system. Create a staging table to hold the STS from the production database.PACK_STGTAB_SQLSET( SQLSET_NAME => 'UPGRADE_STS'.3. TASK_NAME =>'spa_upgrade_task').SQLSET_CURSOR. Export STS data into the staging table as shown in the following code: begin DBMS_SQLTUNE. 3. 'ALL')) p. set the parameter OPTIMIZER_FEATURES_ENABLE in the test database to 10. Following is an example code to do that: exec DBMS_SQLTUNE. STAGING_TABLE_NAME =>'sts_table').the statements are loaded into the STS DBMS_SQLTUNE.LOAD_SQLSET( 'parsing_schema_name <> ''SYS'' and elapsed_time > 2000000'.000 seconds.

The following code compares the SQL performance data analyzed by the SPA before and after the change for the task spa_upgrade_task. The second value will generate explain plans for the SQL Statements without executing the statements.ARGLIST('COMPARISION_METRIC'. The third value is only used to compare two versions of SQL Performance data.or EXPLAIN PLAN EXECUTION_NAME =>'before_change').6' After applying the change.EXECUTE_ANALYSIS_TASK ( TASK_NAME => 'spa_upgrade_task'. OPTIMIZER_COST. end. EXECUTION_TYPE=> 'TEST EXECUTE'. The first value will lead to execute all the SQL Statements in the STS. end. EXECUTION_TYPE => 'COMPARE PERFORMANCE'. EXPLAIN PLAN or COMPARE PERFORMANCE. Page 19 Oracle 11g New Features for Administrators . EXECUTION_TYPE => 'COMPARE PERFORMANCE'. begin DBMS_SQLPA. 'COMPARISON_METRIC'. This procedure has the parameter EXECUTION_TYPE which should take one of three possible values: TEST EXECUTE. DIRECT_WRITE. and BUFFER_GETS.ARGLIST('EXECUTION_NAME1'. it will measure the performance impact of the change on the disk reads. Comparing the SQL Performance To compare the SQL performance data before and after the change.or EXPLAIN PLAN EXECUTION_NAME =>'after_change').Summary Sheets .EXECUTE_ANALYSIS_TASK ( TASK_NAME => 'spa_upgrade_task'. the procedure EXECUTE_ANALYSIS_TASK compares the last two task executions. -.EXECUTE_ANALYSIS_TASK ( TASK_NAME => 'spa_upgrade_task'. end. apply the change on the database. This is done by using the procedure EXECUTE_ANALYSIS_TASK. By setting the parameter COMPARISION_METRIC to DISK_READS. After the code above is successfully executed. 'after_change'.'DISK_READS')).0.'DISK_READS')). EXECUTION_PARAMS => DBMS_ADVISOR. 'before_change'. 'EXECUTION_NAME2'.1.Measuring the Performance Before the Change Start analyzing the SQL workload before applying the change. PARSE_TIME. Measuring the Performance After the Change If the change was upgrading the database to 11g.EXECUTE_ANALYSIS_TASK ( TASK_NAME => 'spa_upgrade_task'. EXECUTION_TYPE=> 'TEST EXECUTE'. Other possible values include: ELAPSED_TIME. -. By default. begin DBMS_SQLPA. do not forget to set the parameter OPTIMIZER_FEATURES_ENABLE to the 11g value after the upgrade finishes: ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='11. you still use the procedure EXECUTE_ANALYSIS_TASK but this time you set the parameter EXECUTION_TYPE to COMPARE PERFORMANCE. EXECUTION_PARAMS => 'DBMS_ADVISOR. You can set the names of the executions before and after the system change was made as follows: begin DBMS_SQLPA. end. you collect SQL performance data by running EXECUTE_ANALYSIS_TASK again. begin DBMS_SQLPA.

-. Result Summary and Result Details. -. It summarizes the results of the SQL Performance Analyzer task. -. Use this subsection to determine whether the workload performance will improve or degrade after making the system change. listing its information and execution details.REGRESSED.to display information about task executions SELECT TASK_NAME. MORE_INFO FROM DBA_ADVISOR_FINDINGS WHERE upper(TASK_NAME)= upper ('spa_test'). TYPE => 'TEXT'. and INFORMATION SELECT TASK_NAME. XML LEVEL =>'TYPICAL'.Summary Sheets .BASIC.or HTML. ERROR.to display descriptive information about the created SQL Performance Analyzer tasks SELECT TASK_ID. IMPACT "Impact Value". It summarizes the SQL statement. EXECUTION_NAME. Result Summary Overall Performance Statistics Performance Statistics of SQL Statements Errors Result Details SQL Statement Details Single Execution Statistics Execution Plans SQL Performance Analyzer Views You can use the following queries to monitor SQL Performance Analyzer and view its analysis results: -. PROGRESS_METRIC. SQL Performance Analyzer Report The report is divided into the sections: General Information. It compares execution statistics of the SQL statement from the pre-change and post-change executions and then summarizes the findings. -. STATUS.UNCHANGED. -.ALL. -. FINDING_NAME. EXECUTION_TYPE.Then you can generate a report to show the result of performance comparison. It represents a drill-down into the performance of SQL statements that appears in the Result Summary section of the report. Page 20 Oracle 11g New Features for Administrators . Section/ Subsection Description General Information It contains basic information and metadata about the SQL Performance Analyzer task.to display the SQL Performance Analyzer findings -. IMPACT_TYPE. MESSAGE. PCT_COMPLETION_TIME.or SECTION_ALL end. the SQL Tuning Set used. It highlights the SQL statements that are the most impacted by the system change. and the pre-change and post-change executions. begin report := DBMS_SQLPA. Following table illustrates description of the report's section and subsections.ERRORS SECTION =>'SUMMARY'). STATUS FROM DBA_ADVISOR_EXECUTIONS WHERE ADVISOR_NAME='SQL Performance Analyzer'.REPORT_ANALYSIS_TASK ( TASK_NAME => 'spa_upgrade_task'. TYPE. It displays the pre-change and post-change execution plans for the SQL statement.UNCHANGED_PLANS. SYMPTOM. EXECUTION_NAME.CHANGED_PLANS.CHANGED.TYPE possible values: PROBLEM. It displays statistics about the overall performance of the entire SQL workload. It reports all errors that occurred during an execution. RECOMMENDATION_COUNT FROM DBA_ADVISOR_TASKS WHERE ADVISOR_NAME='SQL Performance Analyzer'. This can be done using REPORT_ANALYSIS_TASK function as shown in the code below: declare report clob.IMPROVED. TASK_NAME.

Summary Sheets . Even if you did not download any patch. This page lets you select an update from Metalink or Software Library to apply. Also it can detect conflicts between two online patches. In UNIX systems. Cached patches can be then applied to multiple destinations.Patching in Oracle Database Control New Features in Database Control for Patching Patching through Database Control is enhanced in Oracle 11g. It has two sections: o Critical Security Patches o Patch Recommendations by Feature View Patch Cache Patch Prerequisites Stage Patch Apply Patch Online Patching This page displays all the patches downloaded from Metalink. online patching consumes more memory than the conventional method. This page enables you to search the patches on Metalink based on your criteria and then select them. you can stage the software updates from Metalink or Software Library to a staging location and run prerequisite checks on those updates. click Software and Support to reach the Database Software Patching page. With this page. With Oracle 11g online patching (or called hot patching). you use the script $ORACLE_HOME/OPatch/opatch to invoke the online patching. On the other hand. you can apply or roll back a database patch while the instance is running. Page 21 Oracle 11g New Features for Administrators . On the Database Control home page. OEM by default automatically downloads necessary patches from Metalink when the patch job runs. The page has the following links: Link Description Patch Advisor The advisor will connect to Metalink and display the available patches applicable to your software installation.

you only have to define its root directory by setting the value of the initialization parameter DIAGNOSTIC_DEST. an incident metadata is purged from the ADR after one year and its files are retained for one month. Each problem has a problem key. log in as the Oracle software owner and type adrci in the command line. SQL test cases and Data repair records. VALUE FROM V$DIAG_INFO. Incident packages. type the following command in the adrci command line: adrci>help Page 22 Oracle 11g New Features for Administrators . is available even when the database is down. Related data will be stored in the ADR directory. The first time a problem occurs. ADR is developed to provide the following advantages: • • • Diagnosis data. Using adrci Tool Oracle 11g introduces adrci tool. All those tools refer to the ADR in their operation. Query the view V$DIAG_INFO to display all the ADR-related locations (also number of active problems and incidents): SELECT NAME. It is easier to provide Oracle support with diagnosis data when a problem occurs in the database. It has troubleshooting data for other Oracle components such as ASM and CRS. Configuring the ADR To configure the ADR.Database Diagnosis and Repair Introducing Automatic Diagnostic Repository (ADR) The Automatic Diagnostic Repository (ADR) is a file system repository to store diagnostic data source such as alter log. which will be discussed in a later section. user and background dump files. ADR has diagnosis data not only for the database instance. The problem key consists of the Oracle error number and error argument. To invoke the tool. you may have multiple incidents for a one problem. When an incident occurs. An entry will be added in the alert log file. Thus. trace files. Contents of the xml-formatted file can be examined using adrci tool. When the same problem takes place again. SELECT VALUE FROM V$PARAMETER WHERE NAME ='diagnostic_dest'. Here is an example: ORA 600 [4899]. Also the xml-formatted alert log is saved in the ADR and specifically in the directory $ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID/alert Problems and Incidents Problem is a critical error occurred in the database. there is a new framework (named as fault diagnosability infrastructure) consisting of many tools for diagnosing and repairing the errors in the database. This root directory is named as ADR base. To list the tool command line commands. type the following: adrci –help To display the tool commands. This tool is used to examine contents of ADR repository and also to package information related to a specific problem into a compressed (zip) file to send it to Oracle support. Oracle performs the following: • • • An alert will be issued. another incident will be generated for the same problem. and also new types of troubleshooting files such as Health Monitor reports. ALTER SYSTEM SET DIAGNOSTIC_DEST ='C:\ORACLE\diag'. For each database instance two alert log files are generated: one as text file and one with xml format.Summary Sheets . because it is stored in file system. Note By default. an incident is also created. In Oracle 11g.

To obtain guiding information about specific command.Summary Sheets . all the homes will be handled by the tool. To display the ADR base directory the tool is handling. Page 23 Oracle 11g New Features for Administrators . If you want to specify which home should be handled by the tool. issue the following command: adrci>show homes To display the current ADR homepath. issue the following command: adrci>show alert To see only the last 30 messages in the alert. adrci>spool off Using adrci to View the Alert Log By default.. you must specify the current homepath. issue the command with –p (predicate string) option: adrci>show incident –mode detail –p "incident_id=112564" You can use many fields in the predicate options. However.exe To display contents of the alert log file (xml tags will be excluded).. issue the following command: adrci>show homepath To set the current ADR home. adrci>set editor notepad. You can use the SET EDITOR command to change your default editor. In this case. issue the following command: adrci>set homepath diag\rdbms\ora11g\ora11g Note You can specify multiple homes as current homepaths. modify the command as follows: adrci>show alert –tail 30 To display messages containing ORA-600 errors.txt adrci> . Any text output from adrci can be captured and saved in an external text file using spool command: adrci>spool /u01/myfiles/myadrci. If you do not specify the current homepath. issue the command describe incident. type the following: adrci>help show incident adrci commands will run on the ADR root (known when dealing with this tool as ADR base). issue the following command: adrci>show alert –p "MESSAGE TEXT LIKE '%ORA-600%'* Using adrci to List Trace Files Trace files can be listed in adrci using the following command: adrci>show tracefile Using adrci to View Incidents Use the following command to obtain a report about all the incidents in the current homepath(s): adrci>show incident If you want to obtain further details about an incident. type the following in the adrci command: adrci>show base adrci tool can deal with all the Oracle homes under the ADR base. adrci tool will deal with all the specified current homepaths. not all adrci commands can work with multiple current homepaths. To list all available fields. adrci displays the alert log in your default editor. To display homes under the ADR root.

With custom package. Page 24 Oracle 11g New Features for Administrators . Generate the physical package. Follow the instructions till you finish with submitting the package. you use special commands called IPS as shown in the following steps: 1. adrci>ips create package 2. 3. Of course. Using The Support Workbench in the OEM The Support Workbench is a new OEM facility that has similar task to the command line utility adrci. Following are those command formats: o ips create package problem o o o ips create package problem key ips create package incident ips create package time 3. In OEM home page. Adding comments to the problem activity log. you must install Oracle Configuration Manager. open incidents are closed after 30 days. 4. The files related to the incident will be collected in a ZIP file. examine the critical error alerts in the Alerts section table. To do so. You can disable this automatic behavior in the Incident Details page. you can package all the diagnostic files related to specific problems into a ZIP file to submit it to Oracle support. You have the option to create a Quick Package or Custom Package. Click the incident you want to close and click Close. 5. you can do so by generating an incremental ZIP file. Quick package does not give you this level of control. In order to use the option of uploading incident packages to Oracle. click on Quick Package. 7. 6. Click on Go to Metalink to create a service request. The following example shows the command to perform this task: adrci>ips generate package 1 in /u01/myfiles/incidents If you decide to add or change any diagnostic data later. Click the error link provided in the Message column. It aims at examining and reporting critical errors occurring in the database. Resolving a Critical Error A critical error can be resolved with the Support Workbench by performing the following steps: 1. To display those configuration options. You can then revise the Problem Details page to perform the following: o o o Adding an Oracle bug number to the problem information.Summary Sheets . you close the incident. Create a logical package: use ips create package command to create an empty logical package as shown in the example below. In the Investigate and Resolve section of the Problem Details page. Running the related Oracle advisors. By default. there are formats of the ips create package command which enables you to perform the steps 1 and 2 in one command. ips commands behavior is controlled by various configuration options. Modify the command as follows to achieve that: adrci>ips generate package 1 in /u01/myfiles/incidents incremental You will notice that the generated file has the phase INC in its name indicating that it is an incremental ZIP file. you will be asked to provide your Oracle Metalink account credentials. Add diagnostic data to the logical package: this is done by ips add incident command as shown below: adrci>ips add incident 112564 package 1 Actually. you can edit diagnostic data before uploading to data.Using adrci to Package Incidents With adrci tool. use the command ips show configuration. The facility is accessed by the link Database Home Page>Software and Support>Support Workbench. Once the problem is resolved. Follow the link Support Workbench home>View Problem Details. The package will be given a serially generated number. 2.

To retrieve the list of checks that can be run manually by users. -. INPUT_PARAMS => 'TXN_ID=7. Checks run in two ways: o o Reactive: If the fault diagnosability infrastructure catches a critical error.RUN_CHECK ( CHECK_NAME => ' Transaction Integrity Check'. follow the links Database Home page> Server tab> Query Optimizer section> SQL Plan Control> SQL Patch tab Database Health Monitor Oracle 11g introduced a new monitoring framework named as the Health Monitor.NAME PARAMETER_NAME. P. The patch causes the query optimizer to choose an alternate execution plan for future executions. issue the following query: SELECT NAME. end.DEFAULT_VALUE. DESCRIPTION. P. Manual (or proactive): A DBA may invoke the checks manually using DBMS_HM or the OEM. Oracle automatically runs a diagnostic operation (called check) to examine any database corruption or error. exec DBMS_HM.33.DESCRIPTION from V$HM_CHECK_PARAM P. You can view parameter names and descriptions with the V$HM_CHECK_PARAM view. P. The following example illustrates how to pass the transaction ID as a parameter to the Transaction Integrity Check: begin DBMS_HM.Using SQL Repair Advisor If a SQL statements fails because of a problem in its execution plan (caused for example by a bug). issue the following query: SELECT NAME FROM V$HM_CHECK WHERE INTERNAL_CHECK = 'N'.passed value is case sensitive RUN_NAME => 'MY_RUN'.Summary Sheets . you may want the optimizer to make it running using another successful execution plan. Note Health Monitor framework provides several types of database health checks.CHECK_ID = C.). Input parameters are passed to the INPUT_PARAMS argument of the RUN_CHECK procedure as name/value pairs separated by semicolons (.NAME CHECK_NAME. Use the procedure RUN_CHECK to perform a database health check. The OFFLINE_CAPABLE column defines whether you can perform the check when the database is offline or not. The following query displays parameter information for all health checks: select C.INTERNAL_CHECK = 'N' order by C. Most health checks accept input parameters. Some parameters are mandatory while others are optional. RUN_NAME=>'HM01'). To run the advisor. Page 25 Oracle 11g New Features for Administrators . OFFLINE_CAPABLE FROM V$HM_CHECK.TYPE. With Health Monitor. follow the link Support Workbench home> Problem Details of the failed statement> Investigate and Resolve section> Self Service tab> Resolve heading> SQL Repair Advisor.NAME. P. Following are the checks undertaken by the Health Monitor: • DB Structure Check • Data Block Integrity Check • Redo Integrity Check • Undo Segment Integrity Check • Transaction Integrity Check • Dictionary Integrity Check To display list of the check that can be performed. To manage created SQL patches.ID and C.2'). SQL Repair Advisor analyzes failed SQL statements with critical errors and provides recommendations to apply a patch. Running Health Checks Using the DBMS_HM A DBA can use DBMS_HM to manually invoke the database check. Its first parameter CHECKNAME is mandatory and it takes one of the returned names by the query above.RUN_CHECK(CHECK_NAME=>'DB Structure Integrity Check'. Oracle recommends to frequently invoke the Health checks on the database when it is under low usage to catch any corruption or error that may cause damage in the future. V$HM_CHECK C where P. it automatically runs health checks to search for any further failures related to the caught failure.

Running Health Checks Using the Enterprise Manager After connecting as SYSDBA. Physical corruptions such as block checksum failures and invalid block header Field values Inconsistent datafiles (online and offline) I/O failures The advisor however doe not recover from failures on standby databases or RAC environment. and executes repairs at the user's request.Database Health checks executions are stored in ADR and can be viewed by either querying the V$HM_RUN: SELECT * FROM V$HM_RUN. under the Advisor Central page. Data Recovery Advisor can diagnose failures such as the following: • • • • • Inaccessible components like datafiles and control files. RMAN>ADVISE FAILURE. If a failure is detected. then RMAN logs it into the ADR. 3. List failures by running the LIST FAILURE command. end.Summary Sheets . This advisor can be used through RMAN or the Enterprise Manager. DETAIL to list details of an individual failure. Data Recovery Advisor Data Recovery Advisor is an Oracle Database 11g tool that automatically diagnoses data failures. if any. Determine repair options by running the ADVISE FAILURE command. Optionally.. Page 26 Oracle 11g New Features for Administrators . Using Data Recovery Advisor with RMAN Following are the RMAN commands to use Data Recovery Advisor: 1. Another option is to run the adrci command show hm_run: adrci>show hm_run You can view a report of a particular Health check by using the following adrci command: adrci>show report hm_run HM01 Alternatively. Following are variations of using the command: RMAN>LIST FAILURE. you can DBMS_HM package as shown in the following code example: declare v_rpt clob. RMAN>LIST FAILURE 105 DETAIL. Findings. RMAN>LIST OPEN. 2. you will see Checkers link which can be used to manually invoke any Health check. If you suspect that failures exist that have not been automatically diagnosed by the database. detected by the checks can be obtained from V$HM_FINDING and recommendations from V$HM_RECOMMENDATION. determines and presents appropriate repair options.GET_RUN_REPORT('HM01'). begin v_rpt := DBMS_HM. then run VALIDATE DATABASE to check for corrupt blocks and missing files. 4. where it can be accessed by the Data Recovery Advisor. RMAN>LIST CLOSED.. execute LIST FAILURE .

and initialization parameter settings. You can repair the failures manually or run the REPAIR FAILURE command to fix them automatically.5. TIMELIMIT =>0.EXPORT_SQL_TESTCASE ( DIRECTORY =>'SQL_TES_DIR'. SAMPLINGPERCENT =>100. Be aware that the previous command must be issued before using REPAIR FAILURE command.Summary Sheets . CTRLOPTIONS =>NULL. The following form of the command informs you how RMAN plans to repair the failure: RMAN>REPAIR FAILURE PREVIEW 6. along with the exact environment under which the problem occurred. but this can be prevented using the NOPROMPT keyword.generated scripts prefix TESTCASE =>V_TESTCASE). so that the problem can be reproduced and tested on a separate Oracle database instance. Choose a repair option. EXPORTMETADATA =>TRUE. SQL Id (taken from V$SQL) or an incident id. CREATE DIRECTORY sql_tes_dir AS 'C:\Oracle\TestCase'. if it does not represent a problem to you. or even manually close it. SQL_TEXT =>V_SQL. You may wish to change the priority of a failure (to HIGH or LOW). Once the test case is ready. END. The SQL Test Case Builder can be accessed using the interface package DBMS_SQLDIAG or the Enterprise Manager. you can upload the problem to Oracle Support to enable support personnel to reproduce and troubleshoot the problem. the REPAIR FAILURE command prompts the user to confirm the repair. By default. procedures. EXPORTENVIRONMENT =>TRUE. optimizer statistics. BEGIN DBMS_SQLDIAG. Following steps should be followed: 1. Following is an example using a passed SQL statement. PL/SQL functions. EXPORTDATA =>TRUE. table and index definitions (but not the actual data). This can be done by the CHANGE FAILURE command: RMAN> CHANGE FAILURE 202 PRIORITY LOW. Execute the proper form of EXPORT_SQL_TESTCASE procedure. The output of the SQL Test Case Builder is a SQL script that contains the commands required to recreate all the necessary objects and the environment. The information gathered by SQL Test Case Builder includes the query being executed. Using Data Recovery Advisor with the Enterprise Manager Access the Data Recovery Advisor in the Enterprise Manager by following the links: Availability> Manage> Perform Recovery> Perform Automated Repair. V_TESTCASE CLOB. But in general. corruptions of this type require help from Oracle Support Services. Page 27 Oracle 11g New Features for Administrators . DECLARE V_SQL CLOB := 'SELECT * FROM HR. SQL Test Case Builder The SQL Test Case Builder aims at capturing the information pertaining to a SQL-related problem.NAMES WHERE ID BETWEEN 100 AND 1000'. USER_NAME =>'HR'. and packages. Accessing SQL Test Case Builder Using DBMS_SQLDIAG The DBMS_SQLDIAG has a procedure named EXPORT_SQL_TESTCASE which is used to generate a SQL test case for a given SQL statement. 2. BIND_LIST =>NULL. -. TESTCASE_NAME =>'RETURN_NAMES'. Note Data Recovery Advisor may detect or handle some logical corruptions. Create directory to hold the SQL test case files.

Summary Sheets . the SQL Test Case Builder is accessible only when a SQL incident occurs. SQL-related problem is referred to as a SQL incident. follow the links the Support Workbench page> Click on an incident ID> Investigate and Resolve section> Oracle Support> Generate Additional Dumps and Test Cases> click on the icon in the Go To Task. To access the SQL Test Case Builder. such as requiring ASM to perform sequential mirror writes.Accessing SQL Test Case Builder Using the Enterprise Manager From Enterprise Manager. Using this parameter is discussed in the section New Initialization Parameters Affecting Database Creation. Also this parameter controls other data protection behavior in the Oracle Database. Data Block Corruption Parameters The new initialization parameter DB_ULTRA_SAFE sets the default values for other parameters that control protection levels. Page 28 Oracle 11g New Features for Administrators .

if you receive the following error after setting the MEMORY_TARGET parameter. When this parameter is set.Database Administration Automatic Memory Management In Oracle 11g. you must restart the database after setting the parameter. the SGA and the PGA memory sizes are automatically determined by the instance based on the database workload. JAVA POOL. ROUND(MIN_SIZE/1024/1024) MIN. COMPONENT. ROUND(CURRENT_SIZE/1024/1024) CURRENT_SIZE . SHARED POOL. STATUS. LARGE POOL and STREAMS POOL. Oracle will consider the values as the minimum values for SGA and PGA. However. When MEMORY_TARGET is configured. When the instance starts. If you do not set a value for this parameter. most likely the reason is that the /dev/shm is allocated a size (can be known by issuing the command df k) less than SGA_MAX_SIZE: ORA-00845: MEMORY_TARGET not supported on this system. you should take into consideration the following: • • • • The parameter STATISTICS_LEVEL must be set to TYPICAL The parameter MEMORY_MAX_SIZE controls the maximum value you can set for MEMORY_TARGET. When you configure the database to use MEMORY_TARGET. To know how Oracle has modified the memory area sizes by time. OPER_TYPE. query the view V$MEMORY_TARGET_ADVICE. PARAMETER. TARGET_SIZE/1024/1024 TARGET_SIZE_MB. FINAL_SIZE/1024/1024 FINAL_SIZE_MB from V$MEMORY_RESIZE_OPS order by START_TIME. it assigns 60 percent to SGA and 40 percent to the PGA. If you do not set the parameters SGA_TARGET and PGA_TARGET (or set them to zero). if the database is not configured to use this parameter and you want to use it. no minimum value is considered by Oracle for the SGA and PGA. • To set a proper value to the parameter MEMORY_TARGET. If you set the parameters SGA_TARGET and PGA_TARGET. END_TIME. ROUND(MAX_SIZE/1024/1024) MAX FROM V$MEMORY_DYNAMIC_COMPONENTS. use the following query: SELECT COMPONENT. follow the links Database home page> Server tab> Database configuration section> Memory Advisors To display current status of the memory components. END_TIME Note On Linux systems. This parameter is dynamic and can be alter using the ALTER SYSTEM command as shown below: ALTER SYSTEM SET MEMORY_TARGET = 1024M . OPER_MODE. INITIAL_SIZE/1024/1024 INITIAL_SIZE_MB. Resolving the issue can be done by the following OS commands: #umount /dev/shm #mount -t tmpfs shmfs -o *size=><xx>m* /dev/shm Page 29 Oracle 11g New Features for Administrators . a new parameter named as MEMORY_TARGET is added to automate memory allocation for both the SGA and PGA. the following components are auto tuned: DB BUFFER CACHE. SELECT * FROM V$MEMORY_TARGET_ADVICE. In the Enterprise Manager.Summary Sheets . issue the following query: select START_TIME. it defaults to MEMORY_TARGET.

The Automated Maintenance Tasks are managed by the AutoTask Background Process (ABP). New Maintenance Windows In Oracle database 11g.m. Their names derived from MONDAY_WINDOW to SUNDAY_WINDOW. WINDOW_NAME => NULL). and close at 2:00 a. By passing a value to the WINDOW_NAME parameter.Automatic Maintenance Tasks New Automatic Maintenance Task When you install Oracle database 11g. START_TIME DESC. the following predefined automatic maintenance tasks will be created in the scheduler: • The Automatic Optimizer Statistics Collection task (predefined in Oracle 10g as well) • The Automatic Segment Advisor task (predefined in Oracle 10g as well) • The Automatic SQL Tuning Advisor (introduced in Oracle 11g). Similarly.Summary Sheets . The weekend windows (Saturday and Sunday) open at 6:00 a. STATUS FROM DBA_AUTOTASK_TASK. All those windows are assigned to a resource plan. The process is spawned by the MMON background process at the start of the maintenance window.all windows will be affected end.DISABLE. which is enabled automatically when the maintenance windows are opened. you specify to which maintenance window the task is to be disabled. For example. there are seven predefined maintenance windows. To disable a particular automated maintenance tasks for all maintenance windows. To disable all automatic tasks in all maintenance windows.m. issue the following command: Begin DBMS_AUTO_TASK_ADMIN. ENABLE procedure is used to enable the automatic tasks in the maintenance windows. • It determines the jobs that need to be created for each maintenance task window. -. The SQL Tuning Automation section has a brief description about using this tool. The later task issues the Automatic SQL Tuning Advisor which examines SQL statements performance and makes SQL profile recommendations to improve them.ENABLE. and close in 20 hours. OPERATION_NAME. Detail about using this advisor will be discussed in Performance Management New Features chapter.as found in DBA_AUTOTASK_CLIENT OPERATION => NULL. This plan prioritizes SYS_GROUP operations and allocates the remaining 5% to diagnostic operations and 25% to automated maintenance operations. -. issue the following command: exec DBMS_AUTO_TASK_ADMIN. To display list of the automatic tasks in the database. • It stores task execution history in the SYSAUX tablespace. Following are the process functionalities: • It converts automatic tasks into Scheduler jobs.CONSUMER_GROUP LIKE 'ORA$AUTO%' Enabling and Disabling Maintenance Tasks The DBMS_AUTO_TASK_ADMIN package can be to manage the automatic tasks.m (4 hours). Page 30 Oracle 11g New Features for Administrators . issue the following query: SELECT WINDOW_NAME. issue the following query: SELECT TASK_NAME.DISABLE( CLIENT_NAME => 'sql tuning advisor'. The DEFAULT_MAINTENANCE_PLAN resource plan has a number of consumer groups assigned to it named as ORA$AUTOTASK_*_GROUP. To display list schedule of the predefined maintenance windows in the next 32 days. Weekdays windows open at 10:00 p. DEFAULT_MAINTENANCE_PLAN. issue the following command: exec DBMS_AUTO_TASK_ADMIN.'DD-Mon-RR hh24:mi') START_TIME. DURATION FROM DBA_AUTOTASK_SCHEDULE ORDER BY WINDOW_NAME. to enable all automatic tasks in all the maintenance windows. To display the predefined consumer groups assigned to the automatic maintenance windows: SELECT * FROM DBA_RSRC_CONSUMER_GROUPS G WHERE G. It does not execute the maintenance tasks. to_char(START_TIME.

DBMS_SCHEDULER.BYHOUR=5. For example. ATTRIBUTE => 'DURATION'. The DBA_AUTOTASK_CLIENT view displays statistical data for each automated maintenance task (client) over 7day and 30-day periods. begin DBMS_SCHEDULER.DISABLE( NAME => 'SATURDAY_WINDOW'). JOBS_CREATED. Below is a list of queries from some of them. JOBS_STARTED. end. Page 31 Oracle 11g New Features for Administrators . RESOURCE_PLAN => 'DEFAULT_MAINTENANCE_PLAN'. select CLIENT_NAME. remove it from the MAINTENANCE_WINDOW_GROUP window group. JOBS_COMPLETED FROM DBA_AUTOTASK_CLIENT_HISTORY WHERE CLIENT_NAME = 'auto optimizer stats collection'. JOB_NAME. WINDOW_LIST => 'EARLY_MORNING_WINDOW'). The window continues to exist but no longer runs automated maintenance tasks. JOB_SCHEDULER_STATUS "Job status". Automatic Maintenance Task Dictionary Views Oracle Database 11g has removed the old jobs from the DBA_SCHEDULER_* views. WINDOW_NAME. The DBA_AUTOTASK_CLIENT_HISTORY view displays per-window history of job execution counts for each automated maintenance task. SELECT * FROM DBA_AUTOTASK_CLIENT ORDER BY CLIENT_NAME. SELECT CLIENT_NAME. Note that you must disable the window before making changes to it.Summary Sheets . you must create a Scheduler window and then add it to the window group MAINTENANCE_WINDOW_GROUP as in the following example: begin DBMS_SCHEDULER. Creating a New Maintenance Window To create a maintenance window.CREATE_WINDOW( WINDOW_NAME => 'EARLY_MORNING_WINDOW'. WINDOW_LIST => 'EARLY_MORNING_WINDOW'). If you change a window when it is currently open.BYSECOND=0').Modifying a Maintenance Window The DBMS_SCHEDULER package includes a SET_ATTRIBUTE procedure for modifying the attributes of a window. the following script changes the duration of the maintenance window SATURDAY_WINDOW to 4 hours: begin DBMS_SCHEDULER.REMOVE_WINDOW_GROUP_MEMBER( GROUP_NAME => 'MAINTENANCE_WINDOW_GROUP'. The DBA_AUTOTASK_CLIENT_JOB view displays information about currently running scheduler jobs created for automated maintenance tasks. Managing Automatic Maintenance Tasks in the Enterprise Manager Follow the link Database Home page> Scheduler Central at the bottom of the page. regular scheduler jobs. 'hour'). 'hour')).ADD_WINDOW_GROUP_MEMBER( GROUP_NAME => 'MAINTENANCE_WINDOW_GROUP'.SET_ATTRIBUTE( NAME => 'SATURDAY_WINDOW'. Removing a Maintenance Window To remove an existing maintenance window. VALUE => numtodsinterval(4.BYMINUTE=0. DBMS_SCHEDULER. or Enterprise Manager jobs. end. Any other Scheduler jobs assigned to this window continue to run as usual. From the scheduler home page you can see both automated maintenance tasks running via AutoTask.ENABLE( NAME => 'SATURDAY_WINDOW'). REPEAT_INTERVAL=> 'FREQ=DAILY. and moved them to DBA_AUTOTASK_* views. DURATION => numtodsinterval(1. DBMS_SCHEDULER. the change does not take effect until the next time the window opens. end.

TASK_OPERATION from DBA_AUTOTASK_CLIENT_JOB order by CLIENT_NAME. In Oracle 11g. The DBA_AUTOTASK_JOB_HISTORY view displays the history of automated maintenance task job runs. grant SELECT ANY TRANSACTION to the user who will be performing the Flashback Transaction Backout. To invoke the LogMiner from OEM.% in the TABLE field and "DBMS_LOGMNR. 2. TASK_PRIORITY. Oracle Flashback-Related New Features Oracle Database 11g introduces the following new Flashback-related features: • • • LogMiner Interface in Oracle Enterprise Manager Oracle Flashback Transaction Backout Oracle Flashback Data Archives Those features will be discussed in the following sections LogMiner Interface in Oracle Enterprise Manager Before Oracle Database 11g. TASK_TARGET_TYPE. For example.SQL_TEXT. Executing a Flashback Transaction Backout in OEM Follow the links Database home page> Schema tab in OEM> Database Objects section> Tables link> select a table> select the Flashback Transaction action for the table you have selected. Setting Up for Flashback Transaction Backout 1. V$TRANSACTION B. you can enter additional filtering conditions in the Advanced Query field under Query Filter. SELECT CLIENT_NAME. Executing a Flashback Transaction Backout Manually Following are the steps to manually perform the backout: 1. you needed to use the DBMS_LOGMNR package to perform command-line-driven log mining. Oracle will use the LogMiner to mine all the transactions on the table over the given period of time or SCN. JOB_STATUS. select A. Also.XID from V$OPEN_CURSOR A.LOC')= 'BOSTON'" in the Additional LogMiner Columns field.'SCOTT.TASK_NAME. Optionally you could use Log Miner to find the candidate transaction IDs. Oracle Flashback Transaction Backout This feature allows a DBA to back-out a committed transaction and all dependent transactions while the database is still online. JOB_START_TIME. You need to know the transaction ID. follow the links Database Homepage-> Availability-> View and Manage Transactions You can then retrieve the required transactions based on an entered range of time periods or SCNs. the Enterprise Manager has a graphical interface to extract transaction from the redo logs using LogMiner. ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS. B.Summary Sheets . Finally. Enable supplemental logging with primary key logging as seen in this example: ALTER DATABASE ADD SUPPLEMENTAL LOG DATA. to find transactions applied on the record where location = 'BOSTON' in the DEPT table in SCOTT schema. V$SESSION C Page 32 Oracle 11g New Features for Administrators . in order to use the LogMiner to examine and rollback transactions. The V$TRANSACTION view provides this for you with the XID column if you are in the middle of a transaction.DEPT. Grant EXECUTE on DBMS_FLASHBACK to the user who will be performing the Flashback Transaction Backout. JOB_DURATION FROM DBA_AUTOTASK_JOB_HISTORY WHERE CLIENT_NAME = 'auto optimizer stats collection'. enter SCOTT. 3.COLMN_PRESENT(UNDO_VALUE. which is much easier to use. TASK_TARGET_NAME "Name of the target".

If no constraints break. -.where and A. Create FDA object.TADDR=B. The tablespace in which the FDA is created must be managed with Automatic Segment Space Management (ASSM). The OPTIONS parameter can also accept the value DBMS_FLASHBACK. Flashback Data Archive A flashback data archive (FDA) is a new object that holds historical data for one or several tables.T.TRANSACTION_BACKOUT( NUMTXNS => 1. begin V_XID := SYS.SQL_TEXT LIKE '%delete%'. Data Flashback Archive Requirements To set up the DFA in a database.TRANSACTION_BACKOUT procedure to back out the transaction. You can find the internally assigned names of the history tables by querying the *_FLASHBACK_ARCHIVE_TABLES view.CASCADE). declare V_XID SYS. Note FDA is part of the "Oracle Total Recall" option in Oracle database 11g. undo data marked for archiving are not re-used by the database until it is stored by the FBDA into the history table.P RETENTION 24 MONTH. Historical data is stored in compressed form to minimize storage requirements and it is completely transparent to applications.mandatory (in YEAR.mandatory (and it must be with ASSM) QUOTA 5G -. DBMS_FLASHBACK. Use the DBMS_FLASHBACK.SID AND C. You can define its tablespace. With this option. FDA mechanism operates as follows: • • Once the FDA is enabled for a table.G. an internal history table is created for that table. A new background process named as FBDA wakes up at system-determined intervals (default five minutes) and copies the undo data for the marked transactions to the history table(s).Summary Sheets . the following conditions must apply: • • Automatic undo management must be enabled in the database.XID_ARRAY('03001800BC0D0000'). Setting up the Data Flashback Archive Following are the steps you should carry out to set up the DFA: 1. The RDBMS executes the UNDO SQL for the given transactions in reverse order of their commit times. To define a system-level DFA. OPTIONS=>DBMS_FLASHBACK. issue the following query: SELECT * FROM DBA_SYS_PRIVS WHERE PRIVILEGE LIKE '%FLASHBACK ARC%' 2. • DBA_FLASHBACK_TXN_REPORT provides information about the compensating status of all transactions in the database. and the result is satisfactory.optional in M.ADDR A. CREATE FLASHBACK ARCHIVE hr_hist TABLESPACE fda_archives -. XIDS=>V_XID. end. the user forcibly backs out the given transactions without considering the dependent transactions.XID_ARRAY. the user can either COMMIT the changes or else ROLL BACK Obtaining Information about Flashback Transaction Backouts Information about transaction Backouts can be obtained from the following views: • DBA_FLASHBACK_TXN_STATE any transaction shown in this view is backed out.SID=C. Thus. History tables are compressed and internally partitioned.NOCASCADE_FORCE. DBA role or the system privilege FLASHBACK ARCHIVE ADMINISTER must be granted. MONTH. DAY) Page 33 Oracle 11g New Features for Administrators . To display users or roles which granted this privilege. retention period and quota size. 2.

For the command above, note the following: o If QUOTA keyword is omitted, the flashback archive will take up all available space in the tablespace. o Data exceeding the retention period will be automatically purged after one day of the retention expiry period. o You can use the DEFAULT keyword (CREATE FLASHBACK ARCHIVE DEFAULT) to designate this flashback data archive as the default flashback data archive for the database. Using this keyword requires SYSDBA privilege.

Note

At time of writing this document, the statement in the example above may return ORA-55603: Invalid Flashback Archive command error, if you try to create a flashback archive in a non-empty tablespace. I figured out a workaround which is to put the tablespace name between double quotations.

3. Enable Flashback Data Archiving for existing or new tables. A user who wants to do that should be granted either the SYSDBA privilege, the system privilege FLASHBACK ARCHIVE ADMINISTER, or the object privilege FLASHBACK ARCHIVE on the created flashback archive. Following is an example of granting the object privilege: GRANT FLASHBACK ARCHIVE ON hr_hist TO scott; Commands used to enable FDA on tables are illustrated in the examples blow: -- Create the table, using the default archive location. CREATE TABLE my_table(..) FLASHBACK ARCHIVE; -- Modify a table to use the default archive location -- Note: if there is not default flashback archive, an error will be raised ALTER TABLE my_table FLASHBACK ARCHIVE; -- Create a table to use a non-default archivelocation CREATE TABLE my_table (..) FLASHBACK ARCHIVE hr_arc; -- Modify a table to use a non-default archive location. ALTER TABLE my_table FLASHBACK ARCHIVE hr_arc; -- Modify a table to stop (disable) archiving. ALTER TABLE my_table NO FLASHBACK ARCHIVE;

Note

Disabling flashback archiving for a table or dropping its flashback archive object will result in all the historical data for that table being lost. It also requires SYSDBA or FLASHBACK ARCHIVE ADMINISTER privilege.

Altering Flashback Archives Use ALTER FLASBACK command to alter a flashback archive object. Below are examples of using this command: -- make myflash the default flashback archive (as SYSDBA) ALTER FLASHBACK ARCHIVE myflash SET DEFAULT; -- add space to the flashback archive ALTER FLASHBACK ARCHIVE myflash ADD TABLESPACE mytbs; -- remove the tablespace from use by the flashback archive -- (assign it to another tablespace first) ALTER FLASHBACK ARCHIVE myflash REMOVE TABLESPACE mytbs; -- change the quota for the archive ALTER FLASHBACK ARCHIVE myflash MODIFY TABLESPACE mytbs QUOTA 10G; -- undefined quota (make the space unlimited) ALTER FLASHBACK ARCHIVE myflash MODIFY TABLESPACE mytbs; -- change the archive retention time ALTER FLASHBACK ARCHIVE myflash MODIFY RETENTION 2 YEAR; -- purge all archived data ALTER FLASHBACK ARCHIVE myflash PURGE ALL; -- purge data older than 2 days ALTER FLASHBACK ARCHIVE MYFLASH PURGE BEFORE TIMESTAMP( SYSTIMESTAMP – INTERVAL '2' DAY);

Page 34

Oracle 11g New Features for Administrators - Summary Sheets

Using Oracle Flashback Data Archives The normal flashback query and Flashback Versions Query can now use the Flash Archive data to retrieve old data. Following are illustrating examples: SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES AS OF TIMESTAMP TO_TIMESTAMP ('2008-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'); SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '6' MONTH); SELECT LAST_NAME, SALARY FROM HR.EMPLOYEES VERSIONS BETWEEN TIMESTAMP TO_TIMESTAMP ('2008-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS') -- or MINVALUE AND TO_TIMESTAMP ('2008-01-01 15:00:00','YYYY-MM-DD HH24:MI:SS') -- or MAXVALUE WHERE EMPLOYEE_ID = 200; Furthermore, flashback table takes advantage of the Flashback Archive. Following is an example: FLASHBACK TABLE employees TO TIMESTAMP (SYSTIMESTAMP – INTERVAL '6' MONTH); Flashback Data Archive Limitations For a table with Flashback Archiving enabled, you cannot issue the following DDL commands: ALTER TABLE (except adding a column), DROP TABLE, RENAME TABLE and TRUNCATE TABLE. Obtaining Information about Flashback Data Archive DBA_FLASHBACK_ARCHIVE provides information on all flashback archives contained in the database. SELECT * FROM DBA_FLASHBACK_ARCHIVE; DBA_FLASHBACK_ARCHIVE_TS provides information on all tablespaces containing flashback archives. SELECT * FROM DBA_FLASHBACK_ARCHIVE_TS; DBA_FLASHBACK_ARCHIVE_TABLES indicates which flashback archive a given table is assigned to. SELECT TABLE_NAME, OWNER_NAME, FLASHBACK_ARCHIVE_NAME FROM DBA_FLASHBACK_ARCHIVE_TABLES;

Virtual Columns
In Oracle 11g, you can define a column in a table that contains derived data. You can use virtual columns in you queries, create indexes on them, and even collect statistics on them. There are a few restrictions including: • • • You cannot write to a virtual column. There is no support for index-organized, external, object, cluster, or temporary tables. There is no support for Oracle-supplied datatypes, user-defined types, LOBs, or LONG RAWs.

Creating Tables with Virtual Columns Following is the syntax you use to create a virtual column as part of the CREATE TABLE or ALTER TABLE statements: column [datatype] [GENERATED ALWAYS] AS ( <column_expression> ) [VIRTUAL] [( inline_constraint [,...] )] Note the following: • GENERATED ALWAYS and VIRTUAL are optional and are just used to clarify that the data is not stored on disk. • COLUMN_EXPRESSION defines the content of the virtual column. It has the following restrictions: o o o The expression cannot reference another virtual column. All columns referenced in the expression must exist in the same table. The output of the column expression must be a scalar value.

Following is a code example for creating a virtual column: CREATE TABLE EMPLOYEES ( empno number PRIMARY KEY, sal NUMBER (8,2) NOT NULL, annual_sal AS (sal*12), CONSTRAINT MaxAnSal CHECK (annual_sal BETWEEN 0 AND 2000000) );

Page 35

Oracle 11g New Features for Administrators - Summary Sheets

SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT FROM DBA_TAB_COLUMNS WHERE TABLE_NAME='EMPLOYEES' AND COLUMN_NAME='ANNUAL_SAL';

New Data Partitioning Schemes
New partitioning features introduced in Oracle Database 11g including the following: o o o o o Interval partitioning Extended composite partitioning Reference partitioning System partitioning System-managed domain indexes

Refer to the Partitioning Improvements section in the Data Warehousing chapter for more details.

DDL Lock Timeout
In Oracle 11g, the new initialization parameter DDL_LOCK_TIMEOUT controls the duration (in seconds) for which a DDL statement will wait for a DML lock. The default value of zero indicates a status of NOWAIT. The maximum value of 1,000,000 seconds will result in the DDL statement waiting forever to acquire a DML lock. ALTER SYSTEM SET DDL_LOCK_TIMEOUT = 60 ; ALTER SESSION SET DDL_LOCK_TIMEOUT = 60 ;

Explicit Locking of Tables
The LOCK TABLE command has a new keyword named as WAIT which lets you specify the maximum time a statement should wait to obtain a DML lock on table. LOCK TABLE .. IN <lockmode> MODE [ NOWAIT | WAIT n ] For the provided syntax, note the following: • n is an integer value in seconds • If you do not specify either WIAT nor NOWAIT, Oracle will wait until the lock is available and acquired. LOCK TABLE mytab IN EXCLUSIVE MODE WAIT 60; LOCK TABLE mytab IN SHARE MODE NOWAIT;

Invisible Indexes
Invisible index is an index that is not considered by the optimizer when creating the execution plans. This can be used to test the effect of adding an index to a table on a query (using index hint) without actually being used by the other queries. Following are the commands to create an invisible index, change visibility of an existing index and obtaining information about invisible indexes: CREATE INDEX name_indx ON employees(emp_name) INVISIBLE; SELECT /*+ index (EMP_NAME NAME_INDEX) */ ... ALTER INDEX name_indx VISIBLE; ALTER INDEX name_indx INVISIBLE; SELECT INDEX_NAME, VISIBILITY FROM DBA_INDEXES WHERE INDEX_NAME='NAME_INDX'; When using invisible indexes, consider the following: • • If you rebuild an invisible index, the resulting operation will make the index visible. If you want the optimizer to consider the invisible indexes in its operation, you can set the new initialization parameter OPTIMIZER_USE_INVISIBLE_INDEXES to TRUE (the default is FALSE). You can set the parameter in the system and session levels.

Page 36

Oracle 11g New Features for Administrators - Summary Sheets

specific partition begin DBMS_SPACE_ADMIN..SEGMENT CREATION DEFERRED is set without waiting for -.inserting any rows: -. partition_name=>'PAR01'). -. ) SEGMENT CREATION DEFERRED partition by .all the objects in a schema: conn / as sysdba begin DBMS_SPACE_ADMIN. . Deferred segment table do not initially appear in *_segments -.MATERIALIZE_DEFERRED_SEGMENTS ( schema_name =>'SA'. i. the database defers table segment creation until the first row is inserted.the KEEP keyword is optional. ) SEGMENT CREATION IMMEDIATE .dbf'. end.table level create table test ( . -. end.e.Summary Sheets . table_name=>'EMP'). users can only query from the table but no DML statement is allowed on the table.2) If you want to create the segments for objects where -.. Shrinking Temporary Tablespaces and Tempfiles In Oracle 11g.specific table: begin DBMS_SPACE_ADMIN. create table test ( . SELECT TABLE_NAME. table_name=>'EMP'.2.0. ALTER TABLESPACE temp SHRINK TEMPFILE '/u01/app/oracle/oradata/ora11g/temp01. -. -.. -.(11. you can set a table to be read only. Following are the commands to achieve that: ALTER TABLESPACE temp SHRINK SPACE KEEP 100M.db level: show parameter DEFERRED_SEGMENT_CREATION alter system set deferred_segment_creation=true scope=both . when you create heap or partitioned tables in a locally managed tablespace. ALTER TABLE employees READ WRITE. READ_ONLY FROM USER_TABLES WHERE TABLE_NAME='EMPLOYEES'. you can shrink temporary tablespaces and tempfiles.MATERIALIZE_DEFERRED_SEGMENTS ( schema_name =>'SA').to obtain information about temporary space usage SELECT * FROM DBA_TEMP_FREE_SPACE Page 37 Oracle 11g New Features for Administrators . -.Read-Only Tables In Oracle 11g. This feature saves disk space in applications that create hundreds or thousands of tables upon installation.MATERIALIZE_DEFERRED_SEGMENTS ( schema_name =>'SA'. Following are the commands to achieve this: ALTER TABLE employees READ ONLY. many of which might never be populated. end. Deferred Segment Creation Beginning with Oracle Database 11g Release 2.

C++ and PHP. the connection broker will assign the client connection to one of the pooled servers. you can create a pfile or spfile from the current values of the initialization parameters (active in the instance). Preserving Restore Points In Oracle database 10g. the connection broker will create a new pooled server. 2. If no pooled server is free.'DD-MM-YYYY HH24:MI'). the client connection will go into a wait queue till one of the pooled servers becomes free. Using Restore Points with Creating Archival Backups Restore points can be used during the implementation of archival backups. Page 38 Oracle 11g New Features for Administrators . When the client sends a request. CREATE RESTORE POINT res_jun08 AS OF SCN 2340009.Creating an Initialization Parameter File from Memory In Oracle 11g. The client connection releases the pooled server back to the connection pool once its request is serviced by the database. How it works 1. such as PHP and Apache servers. If number of the existing pooled servers reaches to the maximum. DRCP can be used by clients that use OCI driver including C. Following is the code example to do so: CREATE PFILE FROM MEMORY. Restore Point Enhancements Creating Restore Point "as of" an SCN or a Timestamp With Oracle 11g. • The pool of readily available servers also reduces the cost of re-creating client connections. • DRCP boosts the scalability of both the database server and the middle-tier. • DRCP enables a significant reduction (compared to the dedicated server mechanism) in key database resources (specially the memory) that are required to support a large number of client connections. the connection is established between the client and the connection broker (it is a new background process named as connection monitor CMON) in Oracle database. Details of this type of backup are explained in Archival Backups section. CREATE RESTORE POINT myrp PRESERVE. DRCP Advantages DRCP provides the following advantages: • DRCP is especially useful for architectures with multi-process. CREATE SPFILE FROM MEMORY. 3. The generated file will contain all the initialization parameters used by the instance whether exactly set by the DBA or taken as default values. Oracle may reach to situations where it deletes restore points (but not the guaranteed restore points). you can create a restore point for a specific SCN in the past or a past point in time. you can create a restore point with PRESERVE option to prevent Oracle from deleting it.Summary Sheets . CREATE RESTORE POINT res_jun08 AS OF TIMESTAMP to_date('01-04-2008 07:30'. that cannot do middle-tier connection pooling. When a client process or thread connects to the database. single-threaded application servers. if available. The database must be able to flashback to the time point you select to create the restore point. In Oracle 11g. Database Resident Connection Pooling Database Resident Connection Pooling (DRCP) is a pool of dedicated servers in the database for typical Web application usage scenarios.

the client will be forced to relinquish control of the pooled server and will get an error.ALTER_PARAM( PARAM_NAME =>'INACTIVITY_TIMEOUT'.Summary Sheets . The following subsection illustrates how to enable it.company. use the following data dictionary views: V$_CPOOL_INFO V$CPOOL_STATS V$CPOOL_CC_STATS Shows the status of the connection pool and its configuration information. Monitoring DRCP To monitor DRCP in a database. DBMS_CONNECTION_POOL Note If you start the DRCP and then the instance is restarted. Oracle extended the OCISessionPool APIs so that they work with DRCP. the configuration should be as follows: MYDB = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=hostname.company. The freed up server may or may not be returned to the pool. pool would increment by this number of pooled server when pooled server are unavailable at application request time.company. after connecting as SYSDBA use START_POOL procedure in the package as show in the example below: exec DBMS_CONNECTION_POOL.STOP_POOL(). see the documentation Oracle Call Interface Programmer's Guide. This is an existing initialization parameter MAX_THINK_TIME SESSION_CACHED_CURSORS To modify value of any of the parameters above. maximum time of inactivity by the client after getting a server from the pool. If the client does not issue a database call after grabbing a server from the pool. maximum number of times a connection can be taken and released to the pool. use ALTER_PARAM procedure in DBMS_CONNECTION_POOL package as show in the example below: begin DBMS_CONNECTION_POOL. DRCP is specified in the following way: hostname. Client Connection Configuration If the client is using easy Connect string. DRCP is controlled by the following configuration parameters: INACTIVITY_TIMEOUT MAX_LIFETIME_SESSION MAX_USE_SESSION MAX_SIZE and INCRSIZE MIN_SZIE maximum idle time for a pooled server before it is terminated. To restore all the connection pool configuration parameters to their default values. To obtain information about the DRCP configuration. For further details on that. time to live TTL duration for a pooled session. Enabling DRCP To enable the DRCP. Page 39 Oracle 11g New Features for Administrators .com:POOLED If the client is using tnsnames. use the code below: exec DBMS_CONNECTION_POOL.com) (SERVER=POOLED))) Also. end.RESTORE_DEFAULTS(). the pool is automatically started. PARAM_VALUE=>'3600'). the maximum and minimum number of pooled servers in the connections pool.START_POOL(). turn on SESSION_CACHED_CURSORS for all connections in the pool.ora file. Shows details about the connection class-level statistics.Configuring DRCP DRCP is automatically created with any Oracle 11g database but it is disabled by default. Disabling DRCP can be done with the code below: exec DBMS_CONNECTION_POOL. Shows statistics about the pool.com:1521/mydb. you can query the view DB_CPOOL_INFO.

OWNER AND SCAN_ID = 45. You can invoke the function later at any time to re-compare the objects.'). NUM_BUSY_SERVERS. 3. OBJECT_NAME =>'EMPLOYEES'.Following are some queries on the views above: SELECT STATUS. NUM_WAITS.OBJECT_NAME. C. REMOTE_SCHEMA_NAME=>'HR'. C. HISTORIC_MAX FROM V$CPOOL_STATS. Run the COMPARE function. you can create a database link connecting to the same local database.MINSIZE. end. synchronize data between them. This column is used to uniquely identify the rows in both tables and known as index column. DBA_COMPARISON_SCAN_SUMMARY S WHERE C.COMPARISON_TYPE. NUM_REQUESTS. END IF.'). IF V_CONSISTEN THEN DBMS_OUTPUT. SELECT NUM_OPEN_SERVERS.INCRSIZE. if you wish. simple views or materialized views (or of course synonyms for them).COMPARISON_NAME = S.COMPARE( COMPARISON_NAME => 'Compare_Emp'. C. 2. DBMS_OUTPUT. begin V_CONSISTEN := DBMS_COMPARISON.PUT_LINE('Scan ID: ' || V_SCAN_INFO. query the following data dictionary views: DBA_COMPARISON_SCAN USER_COMPARISON_SCAN DBA_COMPARISON_SCAN_SUMMARY DBA_COMPARISON_SCAN_VALUES DBA_COMPARISON_ROW_DIF USER_COMPARISON_SCAN_SUMMARY USER_COMPARISON_SCAN_VALUES USER_COMPARISON_ROW_DIF Following is an example code of using those views to view number of rows that were found different in the two tables: SELECT C. NUM_HITS NUM_MISSES. NUM_PURGED.SESSION_CACHED_CURSORS.PUT_LINE('Data are synchronized. The package allows you to compare tables.COMPARISON_NAME. Run the CREATE_COMPARE procedure in this package to create a comparison. Page 40 Oracle 11g New Features for Administrators . If you want to examine the comparison results. declare V_CONSISTEN BOOLEAN.PUT_LINE('Data are out of synchronization.COMPARISON_NAME AND C.OWNER = S. This is practically useful when you have two objects in replicated databases (shared database objects) out of synchronization.SCAN_ID).Summary Sheets .CURRENT_DIFF_COUNT FROM DBA_COMPARISON C. begin DBMS_COMPARISON. the DBMS_COMPARISON package is developed to use it when you want to compare two database objects in replicated databases and. PERFORM_ROW_DIF =>TRUE ). end. Comparing and Synchronizing Database Objects In Oracle 11g.SCHEMA_NAME. V_SCAN_INFO DBMS_COMPARISON. SCAN_INFO => V_SCAN_INFO. Note If you want to compare two objects in the same database. S.CREATE_COMPARISON( COMPARISON_NAME =>'Compare_EMP'. To use DBMS_COMPARISON package.OWNER. as a workaround. REMOTE_OBJECT_NAME=>'EMP2' ). SCHEMA_NAME =>'HR'. Following are example of using the DBMS_COMPARISON package in comparing two tables in different databases: 1.INACTIVITY_TIMEOUT FROM DBA_CPOOL_INFO. This function populates data dictionary views with comparison results. ELSE DBMS_OUTPUT. the two objects must have a column with an index of primary key or non-null unique constraint.MAXSIZE. DBLINK_NAME =>'REMOTE_DB'.

INDEX_VALUE 4.LOCAL_ROWID is null then 'No' else 'Yes' end LOCAL_ROWID .SCAN_ID AND s. DBMS_OUTPUT. case when r. If there are differences. USER_COMPARISON_SCAN s WHERE c. the user at the remote database to which the comparison owner connects through a database link. PL/SQL and SQL*Plus commands in special error logging table (by default it is SPERRORLOG). SCAN_INFO => V_SCAN_INFO. The CONVERGE procedure also requires additional privileges for one of these users at the database where it makes changes to the shared database object. The option CMP_CONVERGE_LOCAL_WINS indicates that the column values at the local database replace the column values at the remote database when these column values are different. r.PUT_LINE('Local Rows Deleted:' || V_SCAN_INFO. and you want to synchronize the database objects at the two databases. and DELETE privileges on the shared database object at this database.CONVERGE( COMPARISON_NAME => 'Compare_Emp'.COMPARISON_NAME = r. the following users must have SELECT privilege on each copy of the shared database object: o The comparison owner at the local database. DBMS_OUTPUT.LOC_ROWS_MERGED).PUT_LINE('Remote Rows Merged:'|| V_SCAN_INFO.Summary Sheets . o When a database link is used.COMPARISON_NAME = 'COMPARE_EMP_AND_CLONE' AND r.PUT_LINE('Remote Rows Deleted:' || V_SCAN_INFO. Note To run the COMPARE function or CONVERGE procedure. Following are the commands to enable and disable error logging in SQL*Plus: SQL>SHOW ERRORLOGGING SQL>SET ERRORLOGGIN ON SQL>SET ERRORLOGGIN OFF Page 41 Oracle 11g New Features for Administrators .SCAN_ID = s. begin DBMS_COMPARISON.Following is a query to find the rowid or index values of the rows that either exist only in one of the two data sets or have differences in their data values. the new command SET ERRORLOGGIN can be used to store all errors resulting from executed SQL. UPDATE.PUT_LINE('Local Rows Merged:' || V_SCAN_INFO. The user must have INSERT. SQL*Plus New Features 47B SQL*Plus Error Logging In Oracle 11g SQL*Plus. USER_COMPARISON_ROW_DIF r. case when r.LOC_ROWS_DELETED).REMOTE_ROWID is null then 'No' else 'Yes' end REMOTE_ROWID FROM USER_COMPARISON_COLUMNS c. SCAN_ID =>45.alternatively use CMP_CONVERGE_REMOTE_WINS DBMS_OUTPUT. This constant can be specified as 'LOCAL'.RMT_ROWS_DELETED).CMP_CONVERGE_LOCAL_WINS).COMPARISON_TYPE. CONVERGE_OPTIONS=>DBMS_COMPARISON. DBMS_OUTPUT.COLUMN_NAME.last_update_time > systimestamp – (1/24/15) AND r.RMT_ROWS_MERGED). -.COMPARISON_NAME ORDER BY r.STATUS = 'DIF' AND c. declare V_SCAN_INFO DBMS_COMPARISON. Merged rows in this context mean they were replaced. then run the CONVERGE procedure in this package as shown in the following code example: SET SERVEROUTPUT ON.INDEX_COLUMN = 'Y' AND c. SELECT c.INDEX_VALUE . end.

This new enhancement applies in the following statements: o o o Create index online Rebuild index online Create materialized view log Enhanced ADD COLUMN Functionality Before Oracle 11g. Note Using Advanced Compression Option in Oracle 11g requires a separate license from Oracle. New SQL*Plus Connection Syntax The CONNECT command in Oracle 11g SQL*Plus is enhanced to allow connecting as ASM administrator. rebuilding an index acquire shared exclusive lock (SX) on the table allowing DML to go on uninterrupted. MESSAGE FROM SPERRORLOG. the view and the procedure are not invalidated. if you modify a column in the table and that column is referenced by the view or the procedure. (Previous versions had compression option for tables that are mostly read only). In Oracle 11g. To view the error stored in the table. In Oracle 11g. STATEMENT. CONN[ECT] [{logon | / } [AS {SYSOPER | SYSDBA | SYSASM}]] Online Application Maintenance Enhanced Online Index Creation and Rebuild Before Oracle 11g. o Compression of unstructured data in SecureFiles. For example. This will save space (for large tables) and significantly reduce time to execute the modification statement. they will be invalidated. Page 42 Oracle 11g New Features for Administrators . Finer Grained Dependencies Invalidation of dependent objects resulted from modifying structure of the independent object is defused in Oracle 11g. o Compression of redo data transmitted to a standby database during redo gap resolution (when data guard is configured). rebuilding an index online on a table with extensive DML leads to unpredictable results because table exclusive lock (X) is required by rebuilding process. if a view or a PL/SQL procedure references a table and you added a column to the table. Oracle Advanced Compression Option Oracle Database 11g has new option named as Oracle Advanced Table Compression option which aims at reducing space occupied by data for both OLTP and warehouse databases.The SET ERRORLOGGIN ON command creates the error log table. o Compression of RMAN backups. o Compression in Data Pump Export files. However. This option provides the following types of compression: o Compression of data tables even for OLTP environment.Summary Sheets . the default value will be stored in the data dictionary instead of the table itself. use a query like the following: SELECT USERNAME. adding new columns with DEFAULT values and NOT NULL constraint requires an exclusive lock on the table and the default value to be stored in all existing records.

Table Compression Table compression has the advantages of saving storage space, increased I/O performance and reduction in buffer cache memory. On the other hand, it incurs a CPU overhead. The compression can be specified at the tablespace, table or partition level with the following options: o NOCOMPRESS - The table or partition is not compressed. This is the default. o COMPRESS - This option is considered suitable for data warehouse systems. Compression is enabled on the table or partition during direct-path inserts only. o COMPRESS FOR DIRECT_LOAD OPERATIONS - This option has the same affect as the simple COMPRESS keyword (as with Oracle 10g). o COMPRESS FOR ALL OPERATIONS - This option is considered suitable for OLTP systems. As the name implies, this option enables compression for all operations, including regular DML statements. This option requires the COMPATIBLE initialization parameter to be set to 11.1.0 or higher. Following are examples to use the COMPRESS clauses: CREATE TABLE ... COMPRESS FOR ALL OPERATIONS; CREATE TABLE mytab ( .. created_date DATE NOT NULL ) PARTITION BY RANGE (created_date) ( PARTITION mytab_q1 VALUES LESS THAN (to_date('01/01/2008', 'DD/MM/YYYY')) COMPRESS, PARTITION mytab_q2 VALUES LESS THAN (to_date('01/04/2008', 'DD/MM/YYYY')) COMPRESS FOR DIRECT_LOAD OPERATIONS, PARTITION mytab_q3 VALUES LESS THAN (to_date('01/07/2008', 'DD/MM/YYYY')) COMPRESS FOR ALL CREATE TABLESPACE mytbs .. DEFAULT COMPRESS FOR ALL OPERATIONS; The table compression has the following restrictions: o You can add or drop columns to a compressed table, only if the COMPRESS FOR ALL OPERATIONS option was used. o Compressed tables cannot have more than 255 columns. o Compression is not applied to LOB segments. o The compression clause cannot be applied to hash or hash-list partitions. Instead, they must inherit their compression settings from the tablespace, table or partition settings. o Table compression cannot be specified for external, clustered or index organized tables. Compression in SecureFiles The Oracle SecureFiles feature is an alternative solution to LOB to store unstructured data such as XML files, datasheets and word processor documents. With this feature, compression is implemented by eliminating redundant copies of the same document. In this case, all the copies will point to the same document image. For further details about SecureFiles, see the section SecureFiles. Compression in RMAN Backups The Oracle Advanced Compression option reduces the compression ratio in RMAN backup (by 20%) and increases the backup performance (by 40%) than it does in Oracle 10g. Compression in Data Pump Export Files In Oracle 11g, you can compress the export data files in a Data Pump export job (in Oracle 10g, only metadata can be compressed). For further details about using the compression in Data Pump export files, see the section Compression Enhancement in Data Pump. Compression of Transmitted Redo Data With the Oracle Advanced Compression option, data transmitted during redo gab resolution when Oracle guard is implemented is compressed. This results in increasing the throughput of the process and finishing it in a shorter time (about two times faster).

Oracle Scheduler New Features
Lightweight Jobs and Remote External Jobs are two enhancements included in the scheduler. Those enhancements are discussed in the following sections.

Page 43

Oracle 11g New Features for Administrators - Summary Sheets

Lightweight Jobs
In Oracle 11g, Schedule jobs are divided into two types: regular and lightweight jobs. Regular jobs are created and dropped after each execution. They do not cause re-creating overhead and are faster to create. Use lightweight jobs when you need to create and drop hundreds or thousands of jobs per second. Lightweight jobs must be based on job templates. A job template is a database object that provides the necessary metadata needed for running a job (other than a schedule) and provides a privilege infrastructure that can be inherited by any lightweight job. Typically, a job template is a program object with an object type of 'PLSQL_BLOCK' or 'STORED_PROCEDURE'. The following example creates a lightweight job using a program as a template: DBMS_SCHEDULER.CREATE_JOB ( JOB_NAME =>'Light_Job1', PROGRAM_NAME =>'My_Prog', -- an existing scheduler program object REPEAT_INTERVAL =>'freq=daily;by_hour=9', ENABLED =>FALSE, -- default AUTO_DROP =>TRUE, -- default COMMENTS JOB_STYLE =>'Lightweight Job', => 'LIGHTWEIGHT'); -- or REGULAR

The following example creates a set of lightweight jobs in one transaction: declare NEWJOB SYS.JOB; NEWJOBARR SYS.JOB_ARRAY; begin NEWJOBARR := SYS.JOB_ARRAY(); NEWJOBARR.EXTEND(5); FOR I IN 1..5 LOOP NEWJOB := SYS.JOB(JOB_NAME => 'LWJOB_' || TO_CHAR(I), JOB_STYLE => 'LIGHTWEIGHT', JOB_TEMPLATE => 'My_Prog', -- not PROGRAM_NAME REPEAT_INTERVAL => 'FREQ=MINUTELY;INTERVAL=15', START_DATE => SYSTIMESTAMP + INTERVAL '10' SECOND, ENABLED => TRUE ); NEWJOBARR(I) := NEWJOB; END LOOP; -- create multiple jobs in a single call DBMS_SCHEDULER.CREATE_JOBS(NEWJOBARR, 'TRANSACTIONAL'); end;

Remote External Jobs
Configuring Remote External Jobs Functionality In Oracle 11g, you can create in scheduler an external job that runs on a remote host. This type of job is called remote external job. To be able to create a remote external job, the following conditions apply: o o Oracle Scheduler agent (not the database) should be installed on the remote host. Register the scheduler agent with the database that needs to run external jobs in the remote host.

To install the scheduler agent, perform the following steps: 1. 2. 3. 4. Run the Oracle Universal Installer from the Oracle Database Gateway software. Select the Oracle Scheduler Agent as the software to install. Specify the hostname and port number. After installation is finished, run root.sh as a root user.

To register a database in the scheduler agent, perform the following steps: 1. In the database you want to register, issue the following command as a SYS user: SQL>@ ORACLE_HOME/rdbms/admin/prvtrsch.plb

Page 44

Oracle 11g New Features for Administrators - Summary Sheets

2. Set a registration password for the scheduler agent using the following command: exec DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('mypassword'); 3. Register the scheduler agent with the database using the following command: $schagent –registerdatabase database_host database_xmldb_http_port To find out the value of the http port, issue the following command: SQL>select dbms_xdb.gethttpport from dual; 4. Start the scheduler agent with the following command: $schagent –start 5. The scheduler agent can be stopped with the following command: $schagent –stop Creating a Remote External Job To create a remote external job, the following steps should be carried out: 1. Create a credential for running the remote external job using the following command: exec DBMS_SCHEDULER.CREATE_CREDENTIAL('HostNameCredential', 'OSusername','mypassword'); Information about the credentials DBA_SCHEDULER_CREDENTIALS. 2. in the database can be obtained by querying the view

Grant the object privilege EXECUTE on the created credential to the required database user: GRANT EXECUTE ON HostNameCredential TO scott;

3.

Use the following code to create the external job: begin -- create the job DBMS_SCHEDULER.CREATE_JOB( JOB_NAME => 'EXT_JOB1', JOB_TYPE => 'EXECUTABLE', JOB_ACTION => '/u01/app/oracle/sendfiles', REPEAT_INTERVAL =>'freq=daily;by_hour=9', ENABLED =>FALSE); -- define its credential DBMS_SCHEDULER.SET_ATTRIBUTE ( NAME =>'EXT_JOB1', ATTRIBUTE =>'CREDENTIAL_NAME', VALUE =>'HostNameCredential' ); -- define its destination DBMS_SCHEDULER.SET_ATTRIBUTE ( NAME =>'EXT_JOB1', ATTRIBUTE =>'DESTINATION', VALUE =>'rhostname:12345' ); -- hostname and port number listened to by the agent -- enable the job DBMS_SCHEDULER.ENABLE ('EXT_JOB1'); end;

To know the port number the scheduler agent is listening to, view the file schagent.conf in the scheduler agent home directory.

Monitoring Job State with Email Notifications
You can configure a job to send e-mail notifications when it changes state. /* Configuration */ CONN / AS SYSDBA BEGIN -- define the SMTP server DBMS_SCHEDULER.set_scheduler_attribute('email_server', 'smtp.mydomain.com:25'); Page 45

Oracle 11g New Features for Administrators - Summary Sheets

com'.2) -.is used if the sender parameter is not specified DBMS_SCHEDULER.0.'SSL_TLS') -. recipients => 'info@ahmedbaraka. recipients => 'info@ahmedbaraka.create_credential('hrcredential'. events => 'job_started.com'. events => 'JOB_OVER_MAX_DUR'). %error_message%'. / -.for a different event BEGIN DBMS_SCHEDULER. JOB_SCH_LIM_REACHED'). events => 'job_failed'.If the SMTP server requires authentication.to enable/disable encryption is for the SMTP server connection -. recipients => 'info@ahmedbaraka.using the default subject and body BEGIN DBMS_SCHEDULER.%job_name%-%event_type%'. /* Removing Email Notification */ Page 46 Oracle 11g New Features for Administrators .-.optionally define default sender address. END. END.You call ADD_JOB_EMAIL_NOTIFICATION once for each different set of notifications -. filter_condition => ':event.com'.'hr'.2. END. -. alissa@mydomain. body => '%event_type% occurred at %event_timestamp%. subject => 'Scheduler Job Notification-%job_owner%.set_scheduler_attribute('email_server_encryption'.ADD_JOB_EMAIL_NOTIFICATION ( job_name => 'email_notification_job'.add_job_email_notification ( job_name => 'email_notification_job'. JOB_BROKEN.The notification fires only if a job fails with "600" "700" error codes BEGIN DBMS_SCHEDULER.default NULL exec dbms_scheduler. END. -.set_scheduler_attribute('email_server_credential'.possible values: NONE. then the Scheduler uses the -. SSL_TLS.'hrcredential') /* Using Email Notification */ -.com').error_code=700'). -.add_job_email_notification ( job_name => 'email_notification_job'.ADD_JOB_EMAIL_NOTIFICATION ( job_name => 'email_notification_job'.error_code=600 or :event.that you want to configure for a job.user name and password stored in the specified credential object -.associate an email notification with the job -.set_scheduler_attribute('email_sender'. 'info@mydomain.only (11.configures an additional e-mail notification for the same job -.Authentication -.subject and body specified: BEGIN DBMS_SCHEDULER. events => 'JOB_FAILED.com'. exec DBMS_SCHEDULER.Summary Sheets . -. which -.com'. sender => 'do_not_reply@example. STARTTLS exec DBMS_SCHEDULER. job_succeeded'). JOB_DISABLED. recipients => 'info@ahmedbaraka.com. END.'hrpassword').

remove the notification from all recipients and events BEGIN DBMS_SCHEDULER. event. events => 'job_succeeded').-. END. recipients => 'info@ahmedbaraka. password => 'oracle').Grant EXECUTE on the credential to the schema that owns the -. /* Obtain Info about FW */ SELECT file_watcher_name. begin DBMS_SCHEDULER. v). To change this: CONN / AS SYSDBA set serveroutput on declare v varchar2(1000).remove the notification from specified recipient/event BEGIN DBMS_SCHEDULER.set_attribute( 'file_watcher_schedule'. END. File watchers can be defined to monitor locations on the local server and remote servers. interval=5').create OS credential: BEGIN DBMS_SCHEDULER. file_name.event-based job that the file watcher will start: Page 47 Oracle 11g New Features for Administrators . end. username => 'oracle'. 'freq=minutely. credential_name FROM user_scheduler_file_watchers.com'.remove_job_email_notification ( job_name => 'email_notification_job'. 'repeat_interval'.GET_ATTRIBUTE ( 'FILE_WATCHER_SCHEDULE'.create_credential( credential_name => 'fw_credential'.remove_job_email_notification ( job_name => 'email_notification_job'). provided they have an agent installed on them.'REPEAT_INTERVAL'. filter_condition.by default.PUT_LINE(V). File Watcher A file watcher is a new scheduler object that enables a new type of even-based job that is triggered by the arrival of a file in a specified location. -. / -. destination. / /* Creating File Watcher */ -.Summary Sheets . END. recipient. directory_path. a destination is checked every 10 mins. END. / BEGIN DBMS_SCHEDULER. /* Configuration */ -. body FROM user_scheduler_notifications. DBMS_OUTPUT. /* Obtain Info about Email Notifications */ SELECT job_name. subject.

SCHEDULER_FILEWATCHER_RESULT) AS v_message received_files. END. END. -. sysdate). / -.create_file_watcher( file_watcher_name => 'data_fw'. -. CREATE OR REPLACE PROCEDURE import_data_proc (p_sfwr SYS. -. / || p_sfwr.'tab. program_type => 'stored_procedure'. number_of_arguments => 1.Grant EXECUTE on the file watcher to any schema that owns an event-based job -.directory_path || '/' p_sfwr. BEGIN v_message := p_sfwr. argument_position => 1).file watcher name Page 48 Oracle 11g New Features for Administrators . directory_path => '/tmp/test'.create_program( program_name => 'import_data_prog'.the metadata contains info about the file. GRANT EXECUTE ON data_fw to DSSUSER. -.NULL=local server enabled => FALSE).It must accept an argument of the SCHEDULER_FILEWATCHER_RESULT type CREATE TABLE received_files ( fileinfo VARCHAR2(4000).Summary Sheets . END.create a program raised by the file watcher BEGIN DBMS_SCHEDULER.create the defined procedure: -.user_data.dat'. INSERT INTO received_files VALUES (v_message. -.GRANT EXECUTE ON fw_credential to DSSUSER. -.create_job( job_name => 'import_data_job'. enabled => FALSE).if '?' = ORACLE_HOME file_name => '*.wildcard supported credential_name => 'fw_credential'. rdate date ).file_size < 1024' queue_spec => 'data_fw'. program_action => 'import_data_proc'. metadata_attribute => 'event_message'. -.file_size || ')'. program_name => 'import_data_prog'. such as its name: BEGIN DBMS_SCHEDULER.actual_file_name || ' (' || -. / -.that references the file watcher.create the job: BEGIN DBMS_SCHEDULER. destination => NULL.create file watcher: BEGIN DBMS_SCHEDULER. / -. COMMIT. END.fileinfo%type.define_metadata_argument( program_name => 'import_data_prog'. event_condition => NULL.define the metadata argument using the event_message attribute -.

value =>'*.will then be run as a lightweight job: BEGIN DBMS_SCHEDULER.'parallel_instances'.disable('data_fw') .set_attribute('import_data_job'.dat select * from received_files order by rdate desc.txt' ) . attribute =>'credential_name'.enable/disable EXEC DBMS_SCHEDULER.SET_ATTRIBUTE ( name => 'data_fw'. / begin DBMS_SCHEDULER.to test: echo "This is a test" > /tmp/test/f1. -.By default.change an attribute: begin DBMS_SCHEDULER.enable('data_fw. -.dat echo "This is a test too" > /tmp/test/f2. / begin DBMS_SCHEDULER. / -.auto_drop enabled END. set the PARALLEL_INSTANCES attribute for the job to true. / -. EXEC DBMS_SCHEDULER. regardless of whether the job is already -.DROP_FILE_WATCHER('data_fw').SET_ATTRIBUTE ( name => 'data_fw'. the arrival of new files will be ignored if the job is already running.TRUE). end. Page 49 Oracle 11g New Features for Administrators . end.to drop a file watchers: DBMS_SCHEDULER. -. attribute =>'directory_path'.Enable all the objects: EXEC DBMS_SCHEDULER.running or not. -.dat echo "Yes another test" > /tmp/test/f3.import_data_job').SET_ATTRIBUTE ( name => 'data_fw'. / => FALSE.If you need the job to fire for each new arrival. The job -.import_data_prog. value =>'fw_credential2' ) . value =>'/home/oracle/receivedfiles' ) . end. /* Managing File Watchers */ -.enable('data_fw') .Summary Sheets . => FALSE). attribute =>'file_name'. END.

you should perform a complete refresh on them. only those columns are involved in the dependency.put_line ('Max MB ps = ' || l_max_mbps).500 Megabytes of data transferred. To calculate the latency time. show parameter FILESYSTEMIO_OPTIONS alter system set FILESYSTEMIO_OPTIONS=SETALL SCOPE=SPFILE.put_line ('Actual Latency = ' || l_actual_latency). the dependent object is invalidated. The following example creates a resource plan directive for the OLTP group that temporarily switches any session in that group to the LOW_GROUP consumer group.CREATE_PLAN_DIRECTIVE ( PLAN => 'DAYTIME'. they will be invalidated for a redefined table. SWITCH_IO_MEGABYTES => 2500. DBMS_OUTPUT. If a single-table view selects only a subset of columns in a table. otherwise ORA-56708 is raised. max_mbps => l_max_mbps.Finer-grained Dependency Management Invalidation of dependent schema objects in response to changes in the objects they depend upon is greatly reduced in Oracle Database 11g. actual_latency => l_actual_latency). begin DBMS_RESOURCE_MANAGER. the dependent object remains valid. I/O Calibration The DBMS_RESOURCE_MANAGER package has a new procedure named as CALIBRATE_IO which assess the I/O performance of the database server storage system by performing an I/O intensive read-only workload. For each dependent of an object. end. you can configure the Database Resource Manager so that sessions that exceed I/O resource consumption limits can be automatically switched to another consumer group. DBMS_OUTPUT. end. Asynchronous I/O is enabled by setting the FILESYSTEMIO_OPTIONS parameter to ASYNC or SETALL. Conversely. GROUP_OR_SUBPLAN => 'OLTP'. max_latency => 20.put_line ('Max IO ps = ' || l_max_iops). SWITCH_IO_REQS => 10000. MGMT_P1 => 75. the maximum MB per second and the actual latency. the procedure requires TIMED_STATISTICS parameter is set to TRUE. for triggers. -. Enhancements in Oracle Database Resource Manager Per-Session I/O Limits In Oracle 11g. COMMENT => 'Auto Conditional Switch from OLTP group to Low_Group'.Summary Sheets . if changes are made only to definitions of elements that are not involved in the dependency. l_actual_latency PLS_INTEGER. On completion. SWITCH_FOR_CALL => TRUE). This should only be run during off-peak times when there is no workload on the database.resource allocation value for level 1 (replaces CPU_P1) SWITCH_GROUP => 'LOW_GROUP'. if a change is made to the definition of any element involved in the dependency (including dropping the element). max_iops => l_max_iops. l_max_mbps PLS_INTEGER. it returns the maximum I/O requests per second. For materialized views that depend on the modified table. it requires the I/O asynchronous disabled. SET SERVEROUTPUT ON declare l_max_iops PLS_INTEGER. shutdown immediate startup The CALIBRATE_IO procedure accepts two parameters to specify the number of physical disks (default 1) and the maximum tolerable latency (default 20ms). even if it is not affected by the table modification. begin DBMS_RESOURCE_MANAGER. However. DBMS_OUTPUT. if the session exceeds 10. To successfully run the procedure.000 I/O requests or exceeds 2.calibrate_io ( num_physical_disks => 1. Page 50 Oracle 11g New Features for Administrators .

that prioritizes interactive operations over batch operations. cumulative amount of time waiting for CPU. Out-Of-The-Box Mixed Workload Resource Plan Oracle Database includes a predefined resource plan. and cumulative number of CPU waits by all sessions in each consumer group. displays a history of when a resource plan was enabled. You can use this predefined plan.CREATE_PLAN_DIRECTIVE ( PLAN => 'APPS_PLAN'. because INTERACTIVE_GROUP is intended for short transactions. displays Resource Manager statistics per session. DROP ALL STORAGE also applies to the ALTER TABLE TRUNCATE (SUB)PARTITION statement. MAX_UTILIZATION_LIMIT => 40).Summary Sheets . V$RSRC_SESSION_INFO V$RSRC_PLAN_HISTORY V$RSRC_CONS_GROUP_HIST ORY Maximum CPU Utilization Limit Use the MAX_UTILIZATION_LIMIT attribute to impose an absolute upper limit on CPU utilization for a resource consumer group. MIXED_WORKLOAD_PLAN. It drops the whole segment. The plan is defined as follows: CPU Resource Allocation Group or Subplan Level 1 Level 2 Level 3 Automatic Consumer Group Switching Max Degree of Parallelism BATCH_GROUP INTERACTIVE_GROUP 85% 100% switch to group: BATCH_GROUP switch time: 60 seconds switch for call: TRUE 1 ORA$AUTOTASK_SUB_PLAN ORA$DIAGNOSTICS OTHER_GROUPS SYS_GROUP 100% 5% 5% 5% In this plan. GROUP_OR_SUBPLAN => 'APP1_GROUP'. TRUNCATE TABLE emp DROP ALL STORAGE. In addition to the TRUNCATE TABLE statement. New Resource Manager Performance views Following are the new dynamic performance views in Oracle 11g to monitor the results of the Resource Manager settings: V$RSRC_PLAN V$RSRC_CONSUMER_GROUP displays the names of all currently active resource plans. displays a history of consumer group statistics for each entry in V$RSRC_PLAN_HISTORY that has a non-NULL plan. which is intended for longer batch operations. COMMENT => 'Limit CPU for application #1 to 40%'. or modified on the instance. without specifying level limits. This absolute limit overrides any redistribution of CPU within a plan. Page 51 Oracle 11g New Features for Administrators . if it is appropriate for your environment. and includes the required subplans and consumer groups recommended by Oracle. Enhanced TRUNCATE Statement 57B DROP ALL STORAGE is a new option added to TRUNCATE statement in Oracle 11g R2. DBMS_RESOURCE_MANAGER. displays data related to currently active resource consumer groups such as the cumulative amount of CPU time consumed. You can also use the MAX_UTILIZATION_LIMIT attribute as the sole means of limiting CPU utilization for consumer groups. any call that lasts longer than 60 seconds is automatically switched to BATCH_GROUP.Information about calibration runs can be obtained from the DBA_RSRC_IO_CALIBRATE view: select * from DBA_RSRC_IO_CALIBRATE. disabled.

EMPLOYEES table -.Dropping Unused Object Storage In Oracle Database 11g release 2 (11. -. Page 52 Oracle 11g New Features for Administrators . the DBMS_SPACE_ADMIN. END.2.0. END.Summary Sheets . table_name => 'EMPLOYEES').2).DROP_EMPTY_SEGMENTS procedure enables you to drop segments for empty tables and partitions that have been migrated from previous releases.to drop empty segments from the HR.including dependent objects BEGIN DBMS_SPACE_ADMIN.DROP_EMPTY_SEGMENTS( schema_name => 'HR'.to drop empty segments from every table in the database: BEGIN DBMS_SPACE_ADMIN.DROP_EMPTY_SEGMENTS(). -.

as in Oracle 10g. Note If you want to recompile the PL/SQL program units back using the interpreted compilation. 5. without first staging the unit through a . Faster in compilation (Oracle claims by two-and-a-half times). perform the following steps: 1. Faster in execution (by 20 times). ALTER PROCEDURE MY_PROC COMPILE PLSQL_CODE_TYPE=NATIVE. stores the code in the database catalog. SHOW PARAMETER PLSQL_OPTIMIZER_LEVEL ALTER SYSTEM SET PLSQL_OPTIMIZER_LEVEL=2 SCOPE=SPFILE. Cleanly shutdown the database 4. It will affect the newly compiled program units. The parameter can be modified in the system or session level.sql. the Oracle executable loads the code directly from the catalog into memory. 3.sql 6. Recompiling Database PL/SQL Program Units Using PL/SQL Native Compilation To recompile all program units in a database using the native PL/SQL compilation and make the native compilation as the default. Set the parameter PLSQL_CODE_TYPE as follows: ALTER SYSTEM SET PLSQL_CODE_TYPE=NATIVE SCOPE=SPFILE. 2. Page 53 Oracle 11g New Features for Administrators . The parameter takes on of two values: INTERPRETED COMPILED PL/SQL program units will be compiled into PL/SQL bytecode format and the PL/SQL interpreter engine will execute them.. perform the same steps above except setting the PLSQL_CODE_TYPE parameter to INTERPRETED and replacing the scrip dbmsupgnv.so file. When a unit is needed. The PL/SQL compiler may now generate processor-specific native code directly from the PL/SQL source code without needing to use a third-party C compiler and.sql with dbmsupin. In Oracle 11g. Note Configuring the Database or Session to Automatic PL/SQL Native Compilation The new dynamic parameter PLSQL_CODE_TYPE is used to make any newly compiled PL/SQL program unit use native PL/SQL compilation. Make sure the PLSQL_OPTIMIZER_LEVEL parameter value is at least 2. PL/SQL program units will be compiled to machine code and executed natively. COMPILE command as illustrated in the following example: select PLSQL_CODE_TYPE from ALL_PLSQL_OBJECT_SETTINGS where name='MY_PROC'. Note that this feature may not be available on all platforms in the first release of Oracle 11g. Start the database in upgrade mode.Summary Sheets . This leads to the following advantages: • • • No third-party C compiler. Using PL/SQL Native Compilation in the Program Unit Level You can recompile a program unit in the native mode using the ALTER .Performance Tuning PL/SQL Native Compilation PL/SQL Native Compilation was introduced in Oracle 9i.DLL or . Restart the database. Execute the following script will recompile all existing PL/SQL units using native compilation: @ORACLE_HOME/rdbms/admin/dbmsupgnv.

Of course. Queries with bind variables can reuse a cached result only for identical variable values. As clear from its concept. you can increase value of the RESULT_CACHE_MAX_SIZE parameter but in all cases Oracle does not allocate more than 75 percent of shared pool memory to result cache. NCLOB. Page 54 Oracle 11g New Features for Administrators . ALTER SYSTEM SET RESULT_CACHE_MODE =FORCE. Results of the queries retrieving non current version of data are not cached in the result cache. OBJECTS. the target is to obtain high response time. Results of the flashback queries are not cached. if that is possible. Result Cache Restrictions Following are some restrictions with regards to the SQL result cache: • • • • • Queries against data dictionary objects and temporary tables are not supported. However.Summary Sheets . NCLOB. which is used cache SQL query and PL/SQL function results. The database serves the results for the executed SQL queries and PL/SQL functions from the cache instead of re-executing the actual query. The function cannot return a BLOB. CLOB. only if you use the RESULT_CACHE hint in the SQL query. This parameter specifies the maximum amount of SGA memory (in bytes) that can be used by the Result Cache. if the statement contains a NO_RESULT_CACHE hint. collections. REF CURSOR. SYSDATE and SYS_TIMESTAMP are not supported. Controlling Result Cache Behavior The RESULT_CACHE_MODE initialization parameter determines the SQL query result cache mode. The parameter specifies when a ResultCache operator is spliced into a query's execution plan.Server Result Cache In Oracle 11g. CLOB.5% 1% Of course. Queries that use the following SQL functions: CURRENT_DATE. The function cannot have any OUT or IN OUT parameters. Note RESULT_CACHE_MAX_SIZE cannot be dynamically changed if its value is set to 0 during database startup. Memory allocated for the result cache is taken from the shared pool. LOCAL_TIMESTAMP. ALTER SYSTEM SET RESULT_CACHE_MAX_SIZE =128M. or records. then the hint takes precedence over the parameter setting. The cached results stored become invalid when data in the dependent database objects is modified. The function cannot be used in an anonymous block. ALTER SESSION SET RESULT_CACHE_MODE =FORCE. or records. The default value of RESULT_CACHE_MAX_SIZE parameter is derived from values of other parameters and as shown in the following table: Parameter Default Percentage of Shared Pool to Result Cache MEMORY_TARGET SGA_TARGET SHARED_POOL_SIZE 0. then the feature is disabled. there is a new SGA component called result cache. result cache is mostly useful in for frequently executed queries with rare changes on the retrieved data. The parameter accepts the following values: MANUAL FORCE The ResultCache operator is added. The parameter can be modified in the system or session level. Configuring Result Cache You can enable and disable result cache in the database server using the parameter RESULT_CACHE_MAX_SIZE. SYS_GUID. Restrictions on PL/SQL Function Result Cache include: • • • • • The function cannot be defined in a module using invoker’s rights. objects.25% 0. It can return a collection as long as the collection does not contain one of these types. REF CURSOR. The function cannot have IN parameters that are BLOB. If the value of this parameter is 0. The ResultCache operator is added to the root of all SELECT statements. CURRENT_TIMESTAMP. USERENV/SYS_CONTEXT.

DEPARTMENT_ID FROM HR. In this case. it implies that cached results are no longer used and that no new results are saved in the cache. begin DBMS_RESULT_CACHE. Resume use of the result cache.Package specification CREATE OR REPLACE PACKAGE department_pks IS -. If there is a dependent table in a function and that table was modified.. END department_pks. Setting this parameter to a non-zero value can produce stale answers. 3.DEPARTMENT_ID GROUP BY E. PL/SQL Function Result Cache When PL/SQL function result cache is enabled. PL/SQL Cached functions works across sessions. by turning off the cache bypass mode. Following is an example: CREATE OR REPLACE FUNCTION get_name (id NUMBER) RETURN VARCHAR2 RESULT_CACHE RELIES_ON(emp) IS . its result cache will also be used when executing the same function and arguments by other sessions. DBMS_RESULT_CACHE.. SELECT /*+ result_cache */ AVG(SALARY).BYPASS(TRUE). E. Page 55 Oracle 11g New Features for Administrators . The same will also occur if you recompile the function. If you need to apply a hot patch PL/SQL code in a running system to a PL/SQL module on which a result cached function directly or transitively depends. end. -. HR.DEPARTMENTS D WHERE E. Setting this parameter to 0 (the default) implies that results using remote objects should not be cached. CREATE OR REPLACE PACKAGE BODY department_pks AS -. In the optional RELIES_ON clause. Caution When a session reads from a PL/SQL function result cache. then the result cache will be invalidated (cache miss). the function body is not executed.Following is an example of using the RESULT_CACHE hint. Oracle will check the result cache to see if a previous call to the function exists (using the same parameter passed values) and if so it will return the cached result instead of executing the function. and flush existing result.EMPLOYEES E.DEPARTMENT_ID = D.FLUSH. A PL/SQL function can take advantage of the PL/SQL Function Result Cache by adding the RESULT_CACHE clause to the function definition.Function declaration FUNCTION get_dept_info (dept_id NUMBER) RETURN dept_info_record RESULT_CACHE. Place the result cache in bypass mode. This means. if the function is cached by a session.DEPARTMENT_ID.Summary Sheets . ALTER SYSTEM SET RESULT_CACHE_MAX_RESULT =25. When bypass mode is turned on. 2.. this code will not actually be executed.BYPASS(FALSE).Function definition FUNCTION get_dept_info (dept_id NUMBER) RETURN dept_info_record RESULT_CACHE RELIES_ON (EMPLOYEES) IS BEGIN . The parameter RESULT_CACHE_REMOTE_EXPIRATION specifies the number of minutes that a result using a remote object is allowed to remain valid.. if the function includes any IO or auditing code. exec DBMS_RESULT_CACHE. the function will be re-executed when called. Its default value is five. The parameter RESULT_CACHE_MAX_RESULT specifies the percentage of RESULT_CACHE_MAX_SIZE that any single result can use. Apply the PL/SQL code patches. This means. then the cached results associated with the result cache function are not automatically flushed. the following steps must be undertaken: 1. In this case. specify any tables or views on which the function results depend.

JDBC-OCI and Oracle precompilers.Note: this is the reliable method to know whether result cache is enabled or not SQL>select DBMS_RESULT_CACHE. Below are some examples of using it: -. you will notice the ResultCache operator. VALUE from V$RESULT_CACHE_STATISTICS The NAME column possible values are as follows: Block Size Block Count Block Count Result Size Create Count Create Count Find Count Invalidation Delete Count Delete Count (Bytes) size of each memory block Maximum number of memory blocks allowed Current Number of memory blocks currently allocated Maximum (Blocks) Maximum number of blocks allowed for a single result Success Number of cache results successfully created Failure Number of cache results that failed to create Number of cached results that were successfully found Count Total number of invalidations Invalid Number of invalid cached results deleted Valid Number of valid cached results deleted The V$RESULT_CACHE_MEMORY view displays all the memory blocks and their status. you must use Oracle 11g client libraries and connect to an Oracle 11g database. NAME. number of rows in this view increases as the result cache is enlarged by its usage. select ID. STATUS.display report on result cache memory SQL>set serveroutput on SQL>exec DBMS_RESULT_CACHE. Client cache is suitable for frequently executed queries to static data. You can use the CACHE_ID value provided in the explain plan to find details about the cached query results using the V$RESULT_CACHE_OBJECTS view.'HH12:MI AM') CREATE_TIME from V$RESULT_CACHE_OBJECTS where CACHE_ID='ctpgzz1qb222tfqw61j203h01b'.BYPASS (TRUE).NET. NAMESPACE. Client cache can be configured in a host that runs any application that uses Oracle Database 11g OCI client like: ODBC. -.turn bypass mode on and off SQL>exec DBMS_RESULT_CACHE. you can configure the client process to cache its query results in the client memory (or in the server).MEMORY_REPORT -. to_char(CREATION_TIMESTAMP.Summary Sheets . Following are the possible values for the STATUS column and their descriptions: NEW PUBLISHED BYPASS EXPIRED INVALID Result Result Result Result Result is still under construction is available for use will be bypassed from use has exceeded expiration time is no longer available for use V$RESULT_CACHE_STATISTICS view provides information and statistics on cache settings and memory usage. When dealing with the client cache. ROW_COUNT.check the status of the Result Cache -. -. consider the following: • • • To take advantage of client cache. Monitoring and Managing Result Cache with DBMS_RESULT_CACHE Beside the dictionary views. BLOCK_COUNT. The V$RESULT_CACHE_DEPENDENCY view displays the depends-on relationship between the cached results objects.FLUSH Client Side Result Cache 61B In Oracle 11g. PHP. Of course. the package DBMS_RESULT_CACHE can also be used to monitor and manage result cache usage.Monitoring Result Cache If you display the explain plan for any query with a RESULT_CACHE hint. as shown in the following example: select NAME. Page 56 Oracle 11g New Features for Administrators . ODB.to flush the result cache SQL>exec DBMS_RESULT_CACHE.STATUS from dual.

CLIENT_RESULT_CACHE_ LAG Client Side Configuration You can use an optional client configuration file (or make the settings part of the sqlnet. The following columns are added in the V$SYSTEM_EVENT view: TOTAL_WAITS_FG TOTAL_TIMEOUTS_FG Total number of waits that a foreground/background session waited for the event. retrieved rows are cached on the client side saving network round trips and the server CPU overhead. TIME_WAITED_MICRO_FG TWMF FROM V$SYSTEM_EVENT WHERE TIME_WAITED_MICRO_FG > 1000000 AND WAIT_CLASS !='Idle'. The AWR-related view DBA_HIST_SYSTEM_EVENT provides the following similar new columns: TOTAL_WAITS_FG TOTAL_TIMEOUTS_FG TIME_WAITED_MICRO_FG Total number of waits for an event. Client settings will override client cache settings in the server. If it is set to zero (default). It represents the combined size of caches in all clients. This parameter specifies the maximum number of rows a single query result in the client cache for a process. from a foreground session. Enhanced Oracle Process Monitoring Monitoring background processes is enhanced in Oracle 11g so that more detailed statistics can be obtained about their operations. Total number of timeouts for an event that a foreground/background session waited.Server Side Configuration To configure client cache in the database server.ora file on the client). before which the OCI client query execute makes a round trip to get any database changes related to the queries cached on the client. Total time in microseconds that a foreground session spent waiting on an event. Page 57 Oracle 11g New Features for Administrators . After implementing this configuration. TIME_WAITED_FG TWF. set the following parameters: CLIENT_RESULT_CACHE_ SIZE This static parameter specifies the maximum size of the client per-process result set cache (in bytes). TOTAL_TIMEOUTS_FG TTF. Average wait time that a foreground/background process waited for the event in centaseconds. As a result. all cumulative waits of more than one second that occurred on TIME_WAITED_FG AVERAGE_WAIT_FG TIME_WAITED_MICRO_FG The following query is to find foreground/background processes: SELECT EVENT. issue the following queries: select * from CLIENT_RESULT_CACHE_STAT$. AVERAGE_WAIT_FG AWF. TOTAL_WAITS_FG TWG. The following parameters can be set in the client: OCI_RESULT_CACHE_MAX _SIZE OCI_RESULT_CAHCE_MAX _RSET_SIZE OCI_RESULT_CAHCE_MAX _RSET_ROWS This parameter specifies the maximum size of the client per-process result set cache (in bytes). simply the SELECT statement passed by the application to Oracle server should only use the hint /*+ result_cache */. This static parameter specifies the maximum time (in milliseconds) since the last round trip to the server. Total number of timeouts for an event. Total time in microseconds that a foreground session spent waiting on an event. See Oracle Call Interface Programmer's Guide documentation for more information about the client query cache. select * from V$CLIENT_RESULT_CACHE_STATS. To see the clients that used client cache. from a foreground session. the client cache is disabled. Amount of time that a foreground/background session waited for the event in centaseconds.Summary Sheets . This parameter specifies the maximum size of a single query result in the client cache for a process (in bytes).

BEGIN retVal := dbms_auto_sqltune. Details about this feature are discussed in Subprogram Inlinin g section. type => 'TEXT'. VALUE=>' FALSE').1)" page 17-10.put_line(retVal). exec DBMS_AUTO_SQLTUNE. 90).EXECUTE_AUTO_TUNING_TASK. It then automatically creates SQL profile for any poor SQL statement. is a new feature in Oracle 11g that when used appropriately which result in higher PL/SQL execution performance. To use the DBMS_AUTO_SQLTUNE package. the advisor catches the SQL statements from AWR that are candidate for tuning (they are called buckets) during four different time periods.set_auto_tuning_task_parameter('DAYS_TO_EXPIRE'. The only exception is the EXECUTE_AUTO_TUNING_TASK procedure.REPORT_AUTO_TUNING_TASK( begin_exec => NULL. are not automatically implemented by the advisor.Summary Sheets . END. To view the automatic SQL tuning report: VARIABLE my_rept CLOB. To manually execute the automatic execution task : Manually execute the automatic execution task : -. issue the following code: exec DBMS_SQLTUNE. On Oracle 11g Release 2 (11.Subprogram Inlining Subprogram inlining. if that helps. These actions.function format set serveroutput on DECLARE retVal VARCHAR2(1000). a new package named as DBMS_AUTO_SQLTUNE should be used instead of the DBMS_SQLTUNE package.To set the number of days until the task is deleted: exec dbms_auto_sqltune. or Intra Unit Inlining. dbms_output. however.2. The advisor also may recommend actions like creating new indexes. level => 'TYPICAL'. Basically.Only SYS can call this API. Tuned plans are automatically added to the SQL plan baselines by the automatic SQL tuning task. Examples of using this package can be found in the section "The SQL Performance Analyzer".SET_TUNING_TASK_PARAMETER(TASK_NAME PARAMETER=>'ACCEPT_SQL_PROFILES'. set serveroutput on -.2). SQL Tuning Automation The SQL Tuning Advisor is run by default every night during the automated maintenance window.procedure format: exec dbms_auto_sqltune. Follow the links Home Page> Server page> Oracle Scheduler section> Automatic Maintenance Tasks link> Automatic SQL Tuning link> Task status section> Configure button. -. / -. The new package provides more restrictive access to the Automatic SQL Tuning feature. refreshing statistics or re-writing the statement. Page 58 Oracle 11g New Features for Administrators . => 'SYS_AUTO_SQL_TUNING_TASK'. or have EXECUTE privileges granted by an administrator. you must have the DBA role. DBMS_SQLTUNE package is the PL/SQL interface to invoke SQL Tuning Advisor. BEGIN :my_rept :=DBMS_AUTO_SQLTUNE. Further details on using it can be obtained from the documentation "Oracle Database Performance Tuning Guide 11g Release 1 (11.SET_AUTO_TUNING_TASK_PARAMETER( parameter => 'ACCEPT_SQL_PROFILES'.0. If you want the Automatic SQL Tuning process to stop accepting and implementing the recommended SQL profiles automatically.EXECUTE_AUTO_TUNING_TASK. The best method to Manage Automatic SQL Tuning is by using OEM. end_exec => NULL. value => 'TRUE'). which can only be run by SYS.

its input could be SQL cache or a STS. provided that the statement has some predicates and joins on the columns of the NUMBER or DATE data types and the tables have at least 10.CREATE_SQLWKLD(WORKLOAD_NAME => l_wkld_name). ERRORS and ALL (default). Creating a task linked to a workload. l_saved_rows NUMBER := 0. Expected gain can be estimated by the advisor.Summary Sheets . INFORMATION.000 rows. l_task_desc VARCHAR2(128) := 'Test SQL Access'. Quick tune for a single SQL statement. select COUNT(*) into l_num_found from DBA_ADVISOR_TASKS where TASK_NAME = l_taskname . SQL Access Advisor Enhancements SQL Access Advisor is enhanced in Oracle 11g with the following improvements: • The advisor can now recommend creating partitions on tables. -.Method 1: to invoke SQL Access Advisor task linked to a workload declare l_taskname VARCHAR2(30) := 'sql_access_test_task'. -. object_id => NULL. • • To access the tool in OEM.REPORT_AUTO_TUNING_TASK. BEGIN -. When creating a workload. 3. IF l_num_found = 0 THEN DBMS_ADVISOR. -. l_num_found NUMBER. SELECT COUNT(*) INTO l_num_found FROM USER_ADVISOR_SQLW_SUM WHERE WORKLOAD_NAME = l_wkld_name. A task can be broken up into parts called publish points or intermediate results. Those intermediate results can be checked while the advisor is executing. Creating a task linked to a STS. follow the links Database Home page> Advisor Central> SQL Advisors> SQL Access Advisor The following examples show three methods for invoking the tool in PL/SQL using DBMS_ADVISOR package: 1. The true possible values for the parameter SECTION are: SUMMARY. END. result_limit => NULL).reset the task ( remove all recommendations. PLANS. l_failed_rows NUMBER := 0. END IF.SQLACCESS_ADVISOR. END IF. / PRINT :my_rept Note There are some typing errors in the documentation about the function DBMS_AUTO_SQLTUNE. FINDINGS. 2. TASK_NAME => l_taskname.create a workload. l_wkld_name VARCHAR2(30) := 'test_work_load'. IF l_num_found = 0 THEN DBMS_ADVISOR.CREATE_TASK ( ADVISOR_NAME => DBMS_ADVISOR..section => 'ALL'.create an SQL Access Advisor task.RESET_TASK(TASK_NAME => l_taskname). -. and intermediate data from the task) DBMS_ADVISOR.link the workload to the task SELECT count(*) Page 59 Oracle 11g New Features for Administrators . TASK_DESC => l_task_desc).

'REPLACE'.execute_task(task_name => l_taskname). 'VALID_TABLE_LIST'.SET_SQLWKLD_PARAMETER(l_wkld_name. DBMS_ADVISOR. 'STORAGE_CHANGE'. l_failed_rows NUMBER := 0.OPTIMIZER_COST').Summary Sheets .create an SQL Access Advisor task. END. '_MARK_IMPLEMENTATION'.SET_TASK_PARAMETER(l_taskname.ADVISOR_UNUSED). 'TRUE').ADVISOR_UNUSED). 'FALSE'). l_saved_rows NUMBER := 0. 'DEF_MVIEW_OWNER'.SET_TASK_PARAMETER(l_taskname.ADVISOR_UNUSED). DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname.SET_SQLWKLD_PARAMETER(l_wkld_name. DBMS_ADVISOR. l_num_found NUMBER. if it doesn’t exist select COUNT(*) into l_num_found Page 60 Oracle 11g New Features for Administrators .ADVISOR_UNUSED). 'ACTION_LIST'.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR.INTO FROM WHERE AND l_num_found USER_ADVISOR_SQLA_WK_MAP TASK_NAME = l_taskname WORKLOAD_NAME = l_wkld_name. END IF. 'SOURCE_STS_Name'.SET_TASK_PARAMETER(l_taskname.import the current contents of the server's SQL cache DBMS_ADVISOR.ADVISOR_UNUSED). 'EXECUTION_TYPE'. BEGIN -. 'ORDER_LIST'. 'WORKLOAD_SCOPE'. 'PARTIAL'). DBMS_ADVISOR. DBMS_ADVISOR. 2.ADVISOR_UNUSED). DBMS_ADVISOR. DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name.2. 'USERNAME_LIST'.ADVISOR_UNLIMITED).SET_SQLWKLD_PARAMETER(l_wkld_name.Set workload parameters. DBMS_ADVISOR. -. 'REPLACE'. */ -. 'MODULE_LIST'.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR.SET_SQLWKLD_PARAMETER(l_wkld_name. 'DEF_INDEX_OWNER'. l_wkld_name VARCHAR2(30) := 'test_work_load'. 'INDEX_ONLY').OPTIMIZER_COST').IMPORT_SQLWKLD_SQLCACHE(l_wkld_name.Set task parameters. DBMS_ADVISOR. 'SQL_LIMIT'.ADVISOR_UNUSED). 'ORDER_LIST'. DBMS_ADVISOR. l_failed_rows).SET_SQLWKLD_PARAMETER(l_wkld_name. l_saved_rows.SET_TASK_PARAMETER(l_taskname. -. l_sts_name VARCHAR2(30) := 'test_sts'. DBMS_ADVISOR. -.ADD_SQLWKLD_REF( TASK_NAME => l_taskname. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. l_failed_rows).ADVISOR_UNLIMITED). WORKLOAD_NAME => l_wkld_name). 'DEF_MVIEW_TABLESPACE'. DBMS_ADVISOR. 'DEF_INDEX_TABLESPACE'. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR. l_saved_rows. 'PRIORITY. DBMS_ADVISOR. DBMS_ADVISOR. DBMS_ADVISOR. IF l_num_found = 0 THEN DBMS_ADVISOR. / -. 'MODE'.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR. DBMS_ADVISOR. DBMS_ADVISOR. DBMS_ADVISOR.Execute the task: control will not return till the execution finishes DBMS_ADVISOR. DBMS_ADVISOR.Method 2: to invoke SQL Access Advisor linked to a specific STS declare l_taskname VARCHAR2(30) := 'sql_access_test_task2'. -. 'PRIORITY. 'COMPREHENSIVE').load a SQL workload from an existing SQL Tuning Set DBMS_ADVISOR.ADVISOR_UNUSED).unmark the required option /* -. 'DML_VOLATILITY'.IMPORT_SQLWKLD_STS (l_wkld_name. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR. l_task_desc VARCHAR2(128) := 'Test SQL Access for a STS'.

DBMS_ADVISOR. END IF. -. 'REPLACE').a ref cursor is opened to select the required SQL statments OPEN sql_cur FOR SELECT VALUE(p) FROM TABLE (DBMS_SQLTUNE.CREATE_TASK ( ADVISOR_NAME => DBMS_ADVISOR. */ -. DBMS_ADVISOR. DBMS_ADVISOR.NULL.1.(Option 2) Load l_sts_name with SQL statements that are not owned by SYS and -. null. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname.SET_TASK_PARAMETER(l_taskname.SET_TASK_PARAMETER(l_taskname.CREATE_SQLSET(SQLSET_NAME => l_sts_name. declare baseline_cur DBMS_SQLTUNE. 'INDEX_ONLY'). 'EXECUTION_TYPE'.ADD_STS_REF (l_taskname.Next the statements and their statistics are loaded into the STS DBMS_SQLTUNE. NULL.check the example above for creating a workload DBMS_ADVISOR. 'TRUE'). -. -. IF l_num_found = 0 THEN DBMS_ADVISOR. NULL. declare sql_cur DBMS_SQLTUNE.their elapsed time is greater than 20. -. -. l_sts_name). POPULATE_CURSOR=>sql_cur).RESET_TASK(TASK_NAME => l_taskname).Set task parameters. begin -. end. TASK_DESC => l_task_desc). 'DML_VOLATILITY'. -. begin -.SET_TASK_PARAMETER(l_taskname.The data has been filtered to select only the top 30 SQL statements ordered by elapsed time.(Option 1) Load l_sts_name from an AWR baseline. 'STORAGE_CHANGE'. -.Summary Sheets . end. NULL. 'MODE'.LOAD_SQLSET( SQLSET_NAME=>l_sts_name. 'ALL')) p.30 )) p.check if STS already exists select count(*) into l_num_found from DBA_SQLSET where upper(NAME) = upper(l_sts_name) . NULL.SQLSET_CURSOR. NULL. END IF. and intermediate data from the task) DBMS_ADVISOR.COPY_SQLWKLD_TO_STS ('My_WorkLoad'.(Option 3) Copy the contents of a SQL workload object to a SQL Tuning Set -.ADVISOR_UNLIMITED).the statements are loaded into the STS DBMS_SQLTUNE.create STS DBMS_SQLTUNE.from DBA_ADVISOR_TASKS where TASK_NAME = l_taskname . DBMS_ADVISOR.SELECT_WORKLOAD_REPOSITORY( 'peak baseline'.SQLSET_CURSOR. -. l_sts_name.a ref cursor is opened to select from the specified baseline OPEN baseline_cur FOR SELECT VALUE(p) FROM TABLE (DBMS_SQLTUNE.DROP_SQLSET ( sqlset_name => l_sts_name). 'COMPREHENSIVE'). NULL. DESCRIPTION =>'To test Access Advisor').NULL.link the STS to the task DBMS_ADVISOR. POPULATE_CURSOR=>baseline_cur).LOAD_SQLSET( SQLSET_NAME=>l_sts_name. 'elapsed_time'. NULL. -.SELECT_CURSOR_CACHE('parsing_schema_name <> ''SYS'' and elapsed_time > 2000000'.000 seconds.reset the task ( remove all recommendations.SQLACCESS_ADVISOR. 'FALSE').SET_TASK_PARAMETER(l_taskname. Oracle 11g New Features for Administrators . NULL. TASK_NAME => l_taskname. /* unmark the required option -. IF l_num_found <> 0 THEN DBMS_SQLTUNE. DBMS_ADVISOR. Page 61 '_MARK_IMPLEMENTATION'.

-.Display the resulting script ( method 2) CREATE DIRECTORY ADVISOR_RESULTS AS 'C:\TEMP\'. PCT_COMPLETION_TIME. SUBSTR(COMMAND.SET_TASK_PARAMETER(l_taskname. DBMS_ADVISOR. RANK.Summary Sheets . -. (PRECOST-POSTCOST)*100/PRECOST AS PERCENT_BENEFIT from USER_ADVISOR_SQLA_WK_STMTS where TASK_NAME = 'sql_access_test_task' AND workload_name = 'test_work_load'. SET PAGESIZE 24 -.30) AS COMMAND from USER_ADVISOR_ACTIONS where TASK_NAME = 'sql_access_test_task' ORDER BY rec_id.ADVISOR_UNUSED).DBMS_ADVISOR. you can monitor it using the following query: select TASK_NAME. 'PRIORITY. Page 62 Oracle 11g New Features for Administrators . 'DEF_MVIEW_OWNER'. 'ADVISOR_RESULTS'.EXECUTE_TASK(task_name => l_taskname). -. TASK_NAME => 'names_quick_tune'.names n WHERE id = 100').to delete a given task exec DBMS_ADVISOR.1. TYPE "Recommendation Type" from DBA_ADVISOR_RECOMMENDATIONS where TASK_NAME = 'sql_access_test_task' order by RANK.Execute the task: control will not return till the execution finishes DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. 'PARTIAL').CANCEL_TASK(TASK_NAME =>'sql_access_test_task'). END. REC_ID. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. -. BENEFIT.SQLACCESS_ADVISOR.display processed statements in the workload select SQL_ID. end.ADVISOR_UNUSED).while the task is being executed. POSTCOST. / Following are examples of how to manage the task and obtain information about the advisor’s output repot. use the following queries -.alternatively.a task and a workload will be created then the task will be executed DBMS_ADVISOR.sql'). ATTR1 => 'SELECT id FROM hr.OPTIMIZER_COST').CREATE_FILE(DBMS_ADVISOR. DBMS_ADVISOR. PRECOST.if you need to terminate the executing task (may be time consuming) exec DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. -.Display the resulting script ( method 1) SET LONG 100000 SET PAGESIZE 50000 SELECT DBMS_ADVISOR. ACTION_ID. exec DBMS_ADVISOR.benefit is the total improvement in execution cost of all the queries select REC_ID.Method 3: Quick Tune for a single given statement begin -. DBMS_ADVISOR.see the actions for each recommendations select REC_ID. ERROR_MESSAGE from DBA_ADVISOR_LOG where TASK_NAME ='sql_access_test_task'. 'ORDER_LIST'.DELETE_TASK('sql_access_test_task').ADVISOR_UNUSED).ADVISOR_UNUSED). STATUS.'advscript.SET_TASK_PARAMETER(l_taskname. -.GET_TASK_SCRIPT('sql_access_test_task'). DBMS_ADVISOR.QUICK_TUNE( ADVISOR_NAME => DBMS_ADVISOR. DBMS_ADVISOR.GET_TASK_SCRIPT('sql_access_test_task') AS script FROM dual. -. action_id. / -. 'DEF_INDEX_OWNER'. DBMS_ADVISOR. DBMS_ADVISOR. -. 'DEF_MVIEW_TABLESPACE'. DBMS_ADVISOR.SET_TASK_PARAMETER(l_taskname. 'WORKLOAD_SCOPE'. 'DEF_INDEX_TABLESPACE'.

METHOD_OPT. Following is an example: begin DBMS_STATS. the function returns the preference as specified for the table. 'PUBLISH'. Following is an example: begin DBMS_STATS. Saving the new statistics as pending allows you to validate the new statistics and publish them only if they are satisfactory. You can change the PUBLISH setting at either the schema or table level. SET_SCHEMA_PREFS.GET_PREFS ( PNAME =>'STALE_PERCENT'.Schema containing stattab (if other than ownname) end. GRANULARITY.identifier to associate with these statistics STATOWN =>'HR').SET_SCHEMA_PREFS('HR'. Regarding the GET_PREFS function. end. schema or table levels respectively. Similarly. -. • SET_GLOBAL_PREFS. PVALUE =>'75'). SET_DATABASE_PREFS. -. end. TABNAME =>'EMPLOYEES'). when gathering statistics. If the OWNNAME and TABNAME are provided and a preference has been entered for the table.EXPORT_DATABASE_PREFS( STATTAB =>'mytable'. 'FALSE'). EXPORT_*_PREFS and IMPORT_*_PREFS procedures are used to export and import statistics preferences. INCREMENTAL and STALE_PERCENT. Enhanced Statistics Maintenance Pending and Published Statistics Starting with Oracle 11g.setting PUBLISH at schema level exec DBMS_STATS. NO_INVALIDATE. SET_TABLE_PREFS procedures are used to set the statistics preferences for the global.GET_PREFS('PUBLISH') PUBLISH FROM DUAL.'EMPLOYEES'.Summary Sheets . DBMS_OUPTPUT.table name to where statistics should be exported STATID =>'prod_prefs'.GET_PARAM is used to in Oracle 10g to return the default values of parameters of the DBMS_STATS package. ESTIMATE_PERCENT. -. or to have the new statistics saved as pending.SET_TABLE_PREFS('HR'. begin v_value := DBMS_STATS. -. This function is now obsolete in Oracle 11g and replaced with GET_PREFS procedure. In all other cases it returns the global preference if it has been specified. consider the following: • PNAME parameter indicates the preference name and can take one of the following values: CASCADE.SET_GLOBAL_PREFS ( PNAME =>'ESTIMATE_PERCENT'. database. PUBLISH. DEGREE. otherwise the default value is returned. the procedures DELETE_*_PREFS are used to delete current statistics preferences.setting PUBLISH at table level exec DBMS_STATS. Following is an example: SET SERVEROUTPUT ON declare v_value varchar2(100).Changing Statistics Preferences The function DBMS_STATS. Page 63 Oracle 11g New Features for Administrators . OWNNAME =>'HR'. 'FALSE'). 'PUBLISH'.PUT_LINE(v_value). Following are examples to do so: -. you have the option to automatically publish the statistics at the end of the gather operation (default behavior). You can check whether or not the statistics will be automatically published checking the value of the PUBLISH attribute using the DBMS_STATS package as in the following example: SELECT DBMS_STATS.

BLOCKS.ALTER_STATS_HISTORY_RETENTION ( 120 ).list available versions of statistics SELECT * FROM DBA_OPTSTAT_OPERATIONS. end.RESTORE_SCHEMA_STATS( OWNNAME => 'HR'.477333 AM -06:00'). Pending statistics are stored in views such as DBA_TAB_PENDING_STATISTICS and DBA_IND_PENDING_STATISTICS. If you want the optimizer to use the newly collected pending statistics. To adjust this retention. LAST_ANALYZED from DBA_TAB_PENDING_STATISTICS where OWNER='HR' AND TABLE_NAME ='EMPLOYEES'. RESTORE_SYSTEM_STATS. By default.DELETE_PENDING_STATS('HR'. the optimizer uses the published statistics stored in the data dictionary views.publishing specific database object pending statistics exec DBMS_STATS. In Oracle 11g. -. RESTORE_FIXED_OBJECTS_STATS. AS_OF_TIMESTAMP => '19-FEB-08 06.08.00. -. Restoring Previous Versions of Statistics With Oracle Database 11g. statistics on these columns as a group (column group) can be gathered and thus resulting in high enhancement in CBO cardinality estimation.restore statistics of a specific table DBMS_STATS. -.GET_STATS_HISTORY_AVAILABILITY from dual.477333 AM -06:00'). -. Then decide to which point in time you want to restore the statistics. Page 64 Oracle 11g New Features for Administrators . set the initialization parameter OPTIMIZER_PENDING_STATISTICS to TRUE (the default value is FALSE). and then run a workload against the table or schema or just gather its statistics: ALTER SESSION SET OPTIMIZER_PENDING_STATISTICS = TRUE.00. null). If the pending statistics are valid. If you do not want to publish the pending statistics. such as DBA_TAB_STATISTICS and USER_IND_ STATISTICS. TABNAME => 'EMPLOYEES'.'EMPLOYEES').set the retention value exec DBMS_STATS.restore statistics of a specific schema DBMS_STATS. First. RESTORE_SCHEMA_STATS.RESTORE_SCHEMA_STATS( OWNNAME => 'HR'.08. SAMPLE_SIZE. select NUM_ROWS.Summary Sheets .get the oldest timestamp where statistics history is available select DBMS_STATS.Published statistics are stored in data dictionary views.in days MultiColumn Statistics When multiple columns from a single table are used together in the where clause of a query (multiple single column predicates). AS_OF_TIMESTAMP => '19-FEB-08 06. AVG_ROW_LEN.get the current retention value select DBMS_STATS. Oracle will manage the historical statistics repository. delete them by executing the following statement: exec DBMS_STATS.for the whole database exec DBMS_STATS.'EMPLOYEES').PUBLISH_PENDING_STATS('HR'. The optimizer will use the pending statistics (if available) instead of the published statistics when compiling SQL statements. -. by default every 31 days. purging the statistics on a regular basis. you can restore previous versions of statistics. and RESTORE_TABLE_STATS.restore to the point you want begin -. query the view DBA_OPTSTAT_OPERATIONS to know when gathering the statistics has been done using DBMS_STATS. DBMS_STATS package has the following procedures to do that: RESTORE_DICTIONARY_STATS.PUBLISH_PENDING_STATS(null. -. consider the following examples: -. they can be made public by executing the following statement: -.GET_STATS_HISTORY_RETENTION from dual. -. Oracle optimizer in previous versions (before 11g) does not understand the relationship between the columns.

begin -.COUNTRY_ID)'). METHOD_OPT=>'for all columns size skewonly for columns (STATE_ID.CREATE_EXTENDED_STATS( OWNNAME => NULL. '(STATE_ID. You can also create column groups manually by using the CREATE_EXTENDED_STATS function in the DBMS_STATS package.stats of the combined columns will be collected next time the stats is gathered V_NAME := DBMS_STATS. 'EMPLOYEES'.you can query USER_TAB_COL_STATISTICS (extension name appears as COLUMN_NAME) select COLUMN_NAME. end. EXTENSION => '(STATE_ID. EXTENSION from USER_STAT_EXTENSIONS where TABLE_NAME='EMPLOYEES'. -. Following are examples to do that: declare V_NAME VARCHAR2(30).to create expression extended stats (not statistics are yet gathered) V_NAME := DBMS_STATS.SHOW_EXTENDED_STATS_NAME function select DBMS_STATS. Page 65 Oracle 11g New Features for Administrators . EXTENSION => 'STATE_ID. After gathering the multi-column statistics as show in the example. TABNAME => 'EMPLOYEES'. Practically.SHOW_EXTENDED_STATS_NAME(OWNNAME => 'HR'. you will notice that the optimizer has retrieved the correct number of expected retrieved rows.you can use DBMS_STATS. -. this will lead to a significant improvement in the statement execution.COUNTRY_ID') AS E_NAME from dual. 'EMPLOYEES'.Summary Sheets . Expression Statistics is discussed in new following sub-section. The keyword FOR COLUMNS is used in this case as shown in the following example: begin DBMS_STATS.COUNTRY_ID)'). Following is an example: declare V_NAME VARCHAR2(30). METHOD_OPT='for all columns size The DBMS_STATS. Note The default value of METHOD_OPT is 'FOR ALL COLUMNS SIZE AUTO' which makes Oracle create column groups for a table.CREATE_EXTENDED_STATS( OWNNAME => NULL.DROP_EXTENDED_STATS('HR'. similar to how it is done for histograms. 'EMPLOYEES'. Expression Statistics In Oracle 11g.you can then issue the gathering process DBMS_STATS. you can create statistics on an expression. NUM_DISTINCT. You can use the methods in the following code examples to retrieve information on column groups that have been created: -. when you check the explain plan for a query of a where condition like "STATE_ID = 'CA' AND COUNTRY_ID = 'US'". Following is how to drop a column group that you have previously defined: exec DBMS_STATS. This function creates a column statistics entry in the system for a user specified column group or an expression in a table. -.GATHER_TABLE_STATS (NULL.GATHER_TABLE_STATS ('HR'. HISTOGRAM from USER_TAB_COL_STATISTICS where TABLE_NAME = 'EMPLOYEES'. TABNAME => 'EMPLOYEES'. skewonly' ). based on the workload analysis.you can query the data dictionary USER_STAT_EXTENSIONS select EXTENSION_NAME.Note The MultiColumn Statistics and Expression Statistics new features are both constitute what is called by Oracle as Extended Statistics. This function returns a system-generated name of this newly created entry for the extension.GATHER_TABLE_STATS procedure can also be used to create column group and gather its statistics all in one step.COUNTRY_ID)' ). end. begin -.

DROP_EXTENDED_STATS(null. The plan baseline is used by the optimizer to decide on the best plan to use when compiling a SQL statement. begin -. Selecting SQL Plan Baselines by the optimizer Evolving SQL Plan Baselines Stored outlines will be de-supported in a future release in favor of SQL plan management. is a new feature in Oracle 11g that prevents performance regressions resulting from sudden changes to the execution plan of a SQL statement by providing components for capturing. Automatically Collecting Statistics on Tables In Oracle Database 11g. The plans are not checked for performance but will be loaded with the ACCEPTED status. Those keywords are deprecated and ignored. or Cursor Cache. if you issue a query from EMPLOYEES table with a condition like LOWER(LAST_NAME)='ABC'.Summary Sheets . the optimizer has statistics about the retrieved rows and thus will be able to estimate the correct number of returned rows. alter system set OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES = TRUE. Note that you will not be able to drop an extended expression statistics. statistics are collected automatically for tables regardless of the MONITORING and NOMONITORING keywords used when creating them. SQL Plan Management SQL plan management (SPM). You can load the plans from SQL Tuning Sets. Following are code examples to achieve that: -. the system maintains a plan history that contains all plans generated by the optimizer and store them in a component called plan baseline. Among the plan history in the plan baseline. Its default value is FALSE. EXTENSION => '(lower(last_name))'). When SPM is enabled. and evolving SQL plan information. 2. 'EMPLOYEES'. Use the DBA_STAT_EXTENSIONS data dictionary view to retrieve information on expression statistics that have been created in the database. Consequently. end. 3. METHOD_OPT=>'for all columns size skewonly for columns (lower(last_name))').TABNAME => 'EMPLOYEES'. end. Changes to the execution plan may be resulted from database upgrades. Manual Plan Loading SQL plan baselines can be manually loaded with existing plans for a set of SQL statements.GATHER_TABLE_STATS(OWNNAME=>NULL. select EXTENSION_NAME. AWR Snapshots. Following is an example of the removal of an extended expression statistic: exec DBMS_STATS. if a function-based index is dependent on that statistic (ORA-20000 error will be returned). selecting. set the OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES initialization parameter to TRUE in the system or session level.to create expression extended stats and gather the statistics in one step DBMS_STATS. SQL Plan management is implemented by undertaking the following phases: 1. After executing the code above.to load plans from a SQL Tuning Set (STS) declare Page 66 Oracle 11g New Features for Administrators . the optimizer will most likely create a more efficient plan than if those statistics were not present. system and data changes. if used.TABLE_NAME=>'EMPLOYEES'. Note Automatic Plan Capture To enable automatic plan capture. '(lower(lat_name))' ). application upgrade or bug fixes. plans that are verified not to cause performance regression are marked as acceptable. EXTENSION from USER_STAT_EXTENSIONS where TABLE_NAME='EMPLOYEES'. Capturing SQL Plan Baselines: this can be done automatically or manually. Repository stored in data dictionary of plan baselines and statement log maintained by the optimizer is called SQL management base (SMB).

the optimizer will first use a cost-based search method to build a bestcost plan.emp') LOOP IF LENGTH (dd. begin -.create STS DBMS_SQLTUNE. end.LOAD_SQLSET(SQLSET_NAME => 'Top30_STS'. o When a SQL plan baseline plan is manually evolved. the OPTIMIZER_USE_SQL_PLAN_BASELINES parameter must be set to TRUE.CREATE_SQLSET( SQLSET_NAME => 'Top30_STS'. DBMS_SQLTUNE.LOAD_PLANS_FROM_SQLSET( SQLSET_NAME => 'Top30_STS'). A SQL plan baseline plan can be manually evolved using the function DBMS_SPM. POPULATE_CURSOR => baseline_cursor).EVOLVE_SQL_PLAN_BASELINE. 30)) p.my_plans pls_integer.SELECT_WORKLOAD_REPOSITORY( 'peak baseline'. In this case.SQLSET_CURSOR. -. the optimizer will decide to select the lowest-cost plan in the plan baseline. NULL. you can tell if a baseline is being used. my_plans pls_integer.loading Plans from the Cursor Cache declare my_sql_plan pls_integer. Note When you use autotrace. end.Summary Sheets . it will compare it to the plans in the plan baseline. You will see the following note in the autotrace output: SQL plan baseline "SYS_SQL_PLAN_a3185cea611ea913" used for this statement Evolving SQL Plan Baselines During the SQL plan baseline evolution phase. alter system set OPTIMIZER_USE_SQL_PLAN_BASELINES = TRUE .load STS from AWR -. end.select the top 30 SQL statements ordered by elapsed time OPEN baseline_cursor FOR SELECT VALUE(p) FROM TABLE (DBMS_SQLTUNE. all loaded plans are added as accepted plans. END IF. Selecting SQL Plan Baselines Each time a SQL statement is compiled. NULL. -. END LOOP. my_plans := DBMS_SPM. NULL.LOAD_PLANS_FROM_CURSOR_CACHE(sql_id=>dd. NULL. DESCRIPTION => 'Top 30 SQL Statements in peak workload'). To enable the use of SQL plan baselines. This function tries to evolve new plans added by the optimizer to the plan history of existing plan baselines and if Page 67 Oracle 11g New Features for Administrators .name of the AWR baseline NULL. o Automatic SQL Tuning (SQL Tuning Advisor).sql_id) > 0 THEN my_sql_plan := DBMS_SPM.to load plans from a AWR baseline declare baseline_cursor DBMS_SQLTUNE. begin FOR dd in (select sql_id from v$sqlarea where lower(sql_text) like 'select * from scott. -. begin my_plans := DBMS_SPM. -. 'elapsed_time'. v_sql varchar2(1000). Eventually.sql_id). This can be done by the following three ways: o When the plan is manually loaded to the SQL plan baseline. the optimizer determines if non-accepted plans in the baseline should be accepted.LOAD_PLANS_FROM_SQLSET( SQLSET_NAME => 'tset1').

-.105). use the CONFIGURE procedure of the DBMS_SPM package: exec DBMS_SPM.ALTER_SQL_PLAN_BASELINE ( PLAN_NAME => 'SYS_SQL_PLAN_bbedc741a57b5fc2'. PARAMETER_VALUE from DBA_SQL_MANAGEMENT_CONFIG. select ORIGIN. ENABLED.30). Displaying SQL Plan Baselines You can view the plans stored in the SQL plan baseline for a given statement or a given plan. begin report := DBMS_SPM.or SQL_HANDLE ATTRIBUTE_NAME =>'fixed'.PUT_LINE(report).between 5 and 523 Page 68 Oracle 11g New Features for Administrators .Summary Sheets .the FORMAT paramaeter accepts BASIC. The optimizer will not add new plans to a fixed SQL plan baseline.PUT_LINE('Number of Altered Plans:' || n). ACCEPTED. Purging Policy As part of the automated task in the maintenance window. The optimizer will pick a fixed plan with the least cost even though a non-fixed plan may have an even lower cost. To configure the retention period. SQL_HANDLE. declare n PLS_INTEGER. Viewing SPM Configuration Parameters The current configuration settings for the SQL management can be viewed using the following query: select PARAMETER_NAME. select * from table( DBMS_XPLAN.DISPLAY_SQL_PLAN_BASELINE( SQL_HANDLE=>'SYS_SQL_209d10fabbedc741'. the new plan is added as an accepted plan. DBMS_OUTPUT. the limit for the SPM is no more than 10% of the size of the SYSAUX tablespace. a weekly database alert is generated. FORMAT=>'basic')). it makes a recommendation to accept a SQL profile. end. begin n:= DBMS_SPM. The following is an example: declare report clob. TYPICAL (default) or ALL select * from table( DBMS_XPLAN. PLAN_NAME. if the advisor finds a tuned plan and verifies its performance to be better than a plan chosen from the corresponding SQL plan baseline.EVOLVE_SQL_PLAN_BASELINE( SQL_HANDLE => 'SYS_SQL_593bc74fca8e6738'). Fixed SQL Plan Baselines A SQL plan baseline is fixed if it contains at least one enabled plan whose FIXED attribute is set to YES. FORMAT=>'basic')). -. The allowable range for this limit is between 1% and 50%. ATTRIBUTE_VALUE =>'YES'). FIXED from DBA_SQL_PLAN_BASELINES where CREATOR='HR'.CONFIGURE('plan_retention_weeks'. end. Disk Space Usage by SMP By default. When tuning SQL statements with the SQL Tuning Advisor. When the space occupied by SQL management base exceeds the defined space budget limit. DBMS_OUTPUT.DISPLAY_SQL_PLAN_BASELINE( PLAN_NAME=>'SYS_SQL_PLAN_bbedc741a57b5fc2'. -.it verifies that a new plan performs better than a plan chosen from the corresponding plan baseline. To change the percentage limit. use the CONFIGURE procedure of the DBMS_SPM package: exec DBMS_SPM.CONFIGURE('space_budget_percent'. any plan that has not been used for more than 53 weeks are purged.

-. CREATOR => 'HR'). 4. DBMS_OUTPUT. 2.DROP_SQL_PLAN_BASELINE function which returns the number of plans that were removed. 5. DBMS_OUTPUT. as follows: 1. Dropping SQL plan baselines You can drop SQL plan baselines with the DBMS_SPM. end.'INSTANCES'.'ALL').'INSTANCES'. declare v_plans_dropped PLS_INTEGER. begin -. Export the staging table stage1 into a flat file using the export command or Oracle Data Pump.SET_DEFAULT_TASK_PARAMETER('ADDM'. Unpack the SQL plan baselines from the staging table into the SPM on the target system as follows: declare v_plans number.PUT_LINE('Number of SQL plans packed: ' || my_plans). end.Importing and Exporting SQL Plan Baselines Oracle Database supports the export and import of SQL plan baselines using its import and export utilities or Oracle Data Pump. create a staging table as follows: exec DBMS_SPM. begin -. Transfer the flat file to the target system.DROP_SQL_PLAN_BASELINE( SQL_HANDLE =>'SYS_SQL_353e8c17a551f70c'.Summary Sheets . end. The mode ADDM was working in Oracle 10g is now called instance ADDM. ENABLED => 'yes'. you set the parameter INSTANCES in DBMS_ADVISOR.you can also specify the PLAN_NAME or SQL_HANDLE my_plans := DBMS_SPM.UNPACK_STGTAB_BASELINE( TABLE_NAME => 'stage1'. 3. Pack the SQL plan baselines you want to export from the SQL management base into the staging table as follows: declare my_plans number. FIXED => 'yes'). Following are the available options to set this parameter: -. -. Page 69 Oracle 11g New Features for Administrators . PLAN_NAME =>'SYS_SQL_PLAN_a551f70c695cc014').Configure Database ADDM for all instances exec DBMS_ADVISOR.3').Configure Database ADDM for instances 1 and 3 only exec DBMS_ADVISOR.SET_DEFAULT_TASK_PARAMETER('ADDM'. On the original system.'1.CREATE_STGTAB_BASELINE(TABLE_NAME => 'stage1'). To enable Database ADDM. ADDM New Features Database ADDM Oracle Database 11g has added a new layer of analysis to ADDM called Database ADDM. 6.'INSTANCES'. DBMS_OUTPUT. Import the staging table stage1 from the flat file using the import command or Oracle Data Pump.'UNUSED'). begin v_plans := DBMS_SPM. The main target of database ADDM is to analyze and report on RAC environment.SET_DEFAULT_TASK_PARAMETER('ADDM'.PUT_LINE('Number of SQL Plans Unpacked: ' || v_plans).Disable Database ADDM for all instances exec DBMS_ADVISOR.PUT_LINE('Number of SQL Plans Dropped: ' || v_plans).you can pass PLAN_NAME or SQL_HANDLE or both v_plans_dropped:=DBMS_SPM.PACK_STGTAB_BASELINE( TABLE_NAME => 'stage1'.

COMPLETED. BOUNCED. PCT_COMPLETION_TIME. displays the ADDM findings discovered by all advisors in the database describes the contribution for each finding from the different instances. provides instance-level information for ADDM tasks that finished executing. STATUS. The finding name provides additional information that helps to classify the finding being given. INTERRUPTED.TASK_ID group by to_char(EXECUTION_END.STATUS takes one of the following: ANALYZED. MESSAGE from DBA_ADDM_FINDINGS order by IMPACT desc -.STATUS takes one of the following: INITIAL. DBA_ADVISOR_TASKS b where FINDING_NAME like 'CPU Usage%' and a. EXECUTING.TASK_ID=b. NO_SNAPS. STATUS from DBA_ADDM_INSTANCES Finding Classifications A finding name has been added to the Advisor framework in Oracle Database 11g. Following are some queries from those views: -. IMPACT. ERROR select TASK_NAME. ERROR. such as the Cluster database home page in the Performance Analysis page. FINDING_NAME. select to_char(EXECUTION_END. Finding name can be found in the DBA_ADVISOR_FINDING_NAMES view. count(*) from DBA_ADVISOR_FINDINGS a. ERROR_MESSAGE from DBA_ADDM_TASKS order by EXECUTION_END desc -. SYMPTOM. NOT_FOUND select INSTANCE_NAME. ADVISOR_NAME. ADDM New Views Oracle Database 11g has added the following new ADDM-related views: DBA_ADDM_TASKS DBA_ADDM_INSTANCES DBA_ADDM_FINDINGS DBA_ADDM_FDG_BREAKDOWN displays information about all ADDM tasks in the database. Page 70 Oracle 11g New Features for Administrators . OBJECT_ID. INFORMATION -. IMPACT_TYPE. 'hh24') order by 1. TYPE. NO_STATS.The results of this additional level of analysis will appear in several places in OEM. 'hh24') hour .Summary Sheets .can be linked to DBA_ADDM_TASKS using TASK_ID select TASK_NAME.TYPE takes on of the following: PROBLEM.

DIR_NAME => 'System Parameter Directive'. -.---------1 24 2 23 2 25 2 26 VAR tname varchar2(60). */ var tname varchar2(60). and this constitutes at least 10% of the total database time during that period. PARAMETER_NAME=>'sga_target'). end. Using the package DBMS_ADVISOR is still active. The result of GET_REPORT will only show an 'Undersized SGA' finding if the finding is responsible for at least 2 average active sessions during the analysis period.ANALYZE_INST(:tname. SELECT DBMS_ADVISOR. 26). -.INTERVAL '4' HOUR order by 1. SNAP_ID from WRM$_SNAPSHOT where END_INTERVAL_TIME < SYSTIMESTAMP . 2). Below are code examples on using the DBMS_ADDM package: /* to execute a database wide ADDM analysis and report on the results */ -. begin :tname:='ADDM Database Task'. MIN_PERC_IMPACT => 10). END. 1. 1. you can set directives. :tname := 'my_instance_analysis_mode_task'.or use ANALYZE_INST ANALYZE_PARTIAL procedures end. 25. 'TEXT'. DBMS_ADDM. BEGIN DBMS_ADDM.apply the directive to all subsequently created ADDM Tasks DIR_NAME => 'Undersized SGA Directive'. set long 1000000 spool /tmp/addmrpt. SELECT DBMS_ADVISOR. DBMS_ADDM. DBMS_ADDM. or from within OEM. These directives can be assigned to a specific ADDM task.GET_REPORT(:tname ) FROM dual. spool off -.INSERT_FINDING_DIRECTIVE( TASK_NAME => NULL. or can be set as a system directive.directives must be given unique names FINDING_NAME => 'Undersized SGA'. 'ALL') FROM DUAL.Managing ADDM with DBMS_ADDM Oracle Database 11g introduces the DBMS_ADDM package to assist the DBA in administration of Oracle ADDM.GET_TASK_REPORT(:tname. -.txt SELECT DBMS_ADDM.Summary Sheets .get the list of valid snapshots within the last 4 hours select INSTANCE_NUMBER. -.INSERT_PARAMETER_DIRECTIVE( TASK_NAME => NULL. 'TEXT'. 'ALL') FROM DUAL.ANALYZE_DB(:tname. /* To create a directive to prevent ADDM from creating actions to alter the value of a specific system parameter. 2).ANALYZE_INST(:tname.GET_TASK_REPORT(:tname. See the following examples of the procedures used to set directives: /* To create a new ADDM task to analyze a local instance. begin DBMS_ADDM. */ var tname VARCHAR2(60). Page 71 Oracle 11g New Features for Administrators .derived from NAME in DBA_ADVISOR_FINDING_NAMES MIN_ACTIVE_SESSIONS => 2.2.DELETE('ADDM Database Task'). INSTANCE_NUMBER SNAP_ID --------------. Directives To exclude various ADDM analysis and findings from appearing in the report. Directives can be set via command line. :tname := 'my_instance_analysis_mode_task'.remove the ADDM analysis exec DBMS_ADDM.

Summary Sheets . */ var tname VARCHAR2(60). DBMS_ADDM. The result of GET_REPORT will only show actions for that SQL (actions to tune the SQL. MIN_ACTIVE_SESSIONS =>2. SELECT DBMS_ADVISOR. -. AWR New Features Default Retention of AWR Snapshots Changed By default. OWNER_NAME=>'SCOTT'. DBMS_ADDM.DELETE_SQL_DIRECTIVE(DIR_NAME =>'my_directive'). Views with the FILTERED column include: DBA_ADVISOR_FINDINGS.DELETE_FINDING_DIRECTIVE(DIR_NAME =>'my_directive'). Page 72 Oracle 11g New Features for Administrators . Following are examples of the procedures to remove directives: exec exec exec exec DBMS_ADDM. 1.found in views DBA_OBJECTS or DBA_SEGMENTS :tname := 'my_instance_analysis_mode_task'. Oracle Database 11g will now retain eight days of AWR snapshot information (as opposed to seven in Oracle 10g).GET_TASK_REPORT(:tname. DIR_NAME=>'my Segment directive'. FILTERED. DBA_ADVISOR_RECOMMENDATIONS. or a specific object number. and the average response time was at least 1 second. DBMS_ADDM. END.ANALYZE_INST(:tname. MIN_RESPONSE_TIME=>1000000).ANALYZE_INST(:tname. SELECT DBMS_ADVISOR. BEGIN DBMS_ADDM. 'ALL') FROM DUAL. -. SQL_ID =>'abcd123456789'. which can be found in a number of views. -. There are two types of baseline templates: o o Single baseline Repeating baseline Moving Window Baselines A moving window baseline (its name is always SYSTEM_MOVING_WINDOW) corresponds to all AWR data that exists within the AWR retention period.a partition or sub partition OBJECT_NUMBER => null). indicates if a particular row in the view was filtered out by a directive. :tname := 'my_instance_analysis_mode_task'. 1. /* to create a directive to limit reporting of actions on the SQL id 'abcd123456789'. DBMS_ADDM.INSERT_SEGMENT_DIRECTIVE( TASK_NAME => NULL.GET_TASK_REPORT(:tname. DBA_ADVISOR_ACTIONS. segment. This is useful when using adaptive thresholds because the AWR data in the entire AWR retention period can be used to compute metric threshold values. 'TEXT'. -. New Types of AWR Baselines Oracle Database 11g offers the following new types of AWR baseline: • Moving Window Baselines: currently there is only one named as SYSTEM_MOVING_WINDOW • Baseline Templates: they enable you to create baselines for a contiguous time period in the future. BEGIN DBMS_ADDM. 'TEXT'. A new column./* To creates a directive that will prevent ADDM from creating actions to "run Segment Advisor" for specific owner. END. 2). DIR_NAME =>'my SQL directive'.owner of the segment to be filtered out OBJECT_NAME=>null. 'ALL') FROM DUAL.DELETE_SEGMENT_DIRECTIVE(DIR_NAME =>'my_directive'). or to investigate application using it) if the SQL is responsible for at least 2 average active sessions during the analysis period.all objects (wildcards are allowed) SUB_OBJECT_NAME=>null. subsegment. 2). */ var tname VARCHAR2(60).DELETE_PARAMETER_DIRECTIVE(DIR_NAME =>'my_directive').INSERT_SQL_DIRECTIVE( TASK_NAME => NULL. DBMS_ADDM.

DURATION.DROP_BASELINE_TEMPLATE( TEMPLATE_NAME => 'MyTemplate' ). it will never expire DBID => 3310949047 -.optional: if unspecified.m.CREATE_BASELINE_TEMPLATE ( START_TIME => '2007-07-02 17:00:00 PST'.Summary Sheets . begin DBMS_WORKLOAD_REPOSITORY. END_TIME => '2007-07-02 20:00:00 PST'. REPEAT_INTERVAL from DBA_HIST_BASELINE_TEMPLATE.will be appended to the baseline names TEMPLATE_NAME => 'template_2007_mondays'.m. you can create a repeating baseline template to generate a baseline that repeats every Monday from 5:00 p. -.m. -.number of hours the baseline will last EXPIRATION => 30. DBID => 3310949047). end. 2007 from 5:00 p. START_TIME. to 8:00 p. EXPIRATION => 30. Rename Baselines You can use the statement as in the following example to rename existing baselines: begin DBMS_WORKLOAD_REPOSITORY. Single Baseline Template A single baseline template can be used to create a baseline during a single. TEMPLATE_NAME => 'Template_070702'. TEMPLATE_TYPE.You can resize the moving window baseline by changing the number of days in the moving window to a value that is equal to or less than the number of days in the AWR retention period as in the following example: -.the day of the week on which the baseline will repeat HOUR_IN_DAY => 17. you can create a single baseline template to generate a baseline that is captured on July 2.info about Baseline Templates select TEMPLATE_NAME.MODIFY_BASELINE_WINDOW_SIZE ( WINDOW_SIZE => 30). DBID => 3310949047). For example. HOUR_IN_DAY. -.m.then you can increase window size (in days) exec DBMS_WORKLOAD_REPOSITORY. -.number of days to retain each created baseline START_TIME => '2007-04-02 17:00:00 PST'. NEW_BASELINE_NAME =>'workload_baseline0407'. -. the local db id is used ). BASELINE_NAME => 'Baseline_070702'. DAY_OF_WEEK. END_TIME => '2007-12-31 20:00:00 PST'. for the year 2007. START_SNAP_TIME. -.CREATE_BASELINE_TEMPLATE ( DAY_OF_WEEK => 'monday'.RENAME_BASELINE( OLD_BASELINE_NAME =>'workload_baseline'. -. BASELINE_NAME_PREFIX =>'bas_07_mon'.MODIFY_SNAPSHOT_SETTINGS(RETENTION=> 43200). BASELINE_TYPE. For example. -. end. begin DBMS_WORKLOAD_REPOSITORY.info about the window select BASELINE_NAME.info on baselines taken in the system Page 73 Oracle 11g New Features for Administrators . Repeating Baseline Template A repeating baseline template is used to automatically create baselines that repeat during a particular time interval over a specific period in the future. end.first increase AWR retention period (in minutes) exec DBMS_WORKLOAD_REPOSITORY.(0 to 23) the hour in the day when the baseline will start DURATION => 3. fixed time interval in the future. -. to 8:00 p. EXPIRATION.END_TIME. END_SNAP_TIME from DBA_HIST_BASELINE.(in days) if unspecified. Obtaining Information About Existing Baselines Use the code in the following example to obtain information about existing baselines in the database: -. Dropping Baseline Templates Following is an example on how to drop a baseline template: Exec DBMS_WORKLOAD_REPOSITORY.

-. TEMPLATE_NAME from DBA_HIST_BASELINE_DETAILS Setting Metric Thresholds for Baselines Setting Metric Thresholds for the Default Moving Baseline using Workload Profiles To set metric thresholds for the default moving baseline in OEM: 1. Follow the links Database Home page> Related Links section> Baseline Metric Thresholds> Quick Configuration> Workload Profile section> select one of the following options: • Primarily OLTP • Primarily Data Warehousing • Alternating 2. current ASH is stored in V$ACTIVE_SESSION_HISTORY view and its historical data stored in the DBA_HIST_ACTIVE_SESS_HISTORY view. Miscellaneous New Performance Tuning Features Active session history (ASH) enhancements ASH statistics are enhanced to provide row-level activity information for each SQL statement that is captured.-. ERROR_COUNT.PCT_TOTAL_TIME Amount of time captured in snapshots. START_SNAP_TIME. such as IO. what proportion of time users are waiting and the time they spend on an activity. END_SNAP_TIME. Setting Metric Thresholds for Selected Baselines To set a metric threshold for a selected baseline in OEM: 1. END_SNAP_TIME. END_SNAP_ID. MOVING_WINDOW_SIZE. divided by the total possible -time for this baseline select INSTANCE_NUMBER. TEMPLATE_NAME from DBA_HIST_BASELINE. select Basic Metrics. Specify the metric you want to edit (from the Category/Name column) and the name of a baseline (from the AWR Baseline column) then click Edit Thresholds. it is generated by the system using a template select BASELINE_NAME. which provides you a quick overview of current ADDM findings. BASELINE_TYPE. 3. Click the Settings link to go to the Performance Page Settings page. START_SNAP_ID. The Baseline Display Settings section lets you select if and how the AWR baseline values are displayed in the Performance page charts. LAST_TIME_COMPUTED. Modify any threshold setting then click Apply Thresholds. BASELINE_ID. EXPIRATION. PCT_TOTAL_TIME. As with Oracle 10g. The Performance Page Settings page has two sections. In the View list. Page 74 Oracle 11g New Features for Administrators . Performance-Related Changes in Database Control Customized Performance Page You can in Oracle 11g set up a customized Database Performance page in Database Control. ADDM Performance Analysis On the Database Control Database home page. EXPIRATION. END_SNAP_ID. BASELINE_TYPE. START_SNAP_ID. Average Active Sessions The average active sessions section on the Performance page offers shows.details about the baseline -. in graphical form. Click Continue then click Finish. SHUTDOWN. you can now see an ADDM performance analysis summary table.if BASELINE_TYPE equals GENERATED. Follow the links Database Home> Related Links> Baseline Metric Thresholds 2. 4.Summary Sheets . START_SNAP_TIME. MOVING_WINDOW_SIZE. The Detailed Chart Settings section lets you choose defaults for displaying the instance activity charts. BASELINE_NAME.

DISK_READS. M. V$IOSTAT_FILE V$IOSTAT_FUNCTION Following are examples of queries on those views: -.I/O stats for Datafiles and Tempfiles -.REPORT_SQL_MONITOR function as follows: generate the SQL monitor report using the variable my_rept CLOB.2) "Single Block Read Latency (s)". M. SMALL_WRITE_REQS "single block write requests".BUFFER_GETS. which translates directly to the amount of time that clients need to wait before moving onto the next operation. -.SQL_ID = S. BEGIN :my_rept :=DBMS_SQLTUNE. M. SMALL_WRITE_REQS "single block read requests". database file. round(WAIT_TIME/1000.FIRST_REFRESH_TIME.LAST_REFRESH_TIME.'hh24:mi') "Last Refresh Time". -.ELAPSED_TIME "Elapsed Time (micro s)". This view displays I/O statistics of database files that are or have been accessed.CPU_TIME "CPU Time (micro s)". The SMALL_SYNC_READ_LATENCY column displays the latency for single block synchronous reads (in milliseconds). M. LARGE_READ_REQS "multiblock read requests". to_char(M. NUMBER_OF_WAITS "I/O waits".REPORT_SQL_MONITOR().6). and database function.data file and temp file -. ASYNCH_IO "asynch I/O Availability" from V$IOSTAT_FILE where FILETYPE_ID IN (2. to_char(M. LARGE_READ_REQS "multiblock read requests". FILETYPE_NAME. SMALL_READ_REQS "single block read requests". or when it has consumed at least 5 seconds of CPU or IO time in a single execution. Real-Time SQL Monitoring The real-time SQL monitoring feature of Oracle Database enables you to monitor the performance of SQL statements while they are executing.SMALL_SYNC_READ_LATENCY is Latency for single block synch reads (ms) select FILE_NO. SMALL_SYNC_READ_REQS "synch single block read reqs". By default. If Oracle Database Resource Manager is enabled. The statistics for monitored SQL statement execution can be displayed using the V$SQL_MONITOR and V$SQL_PLAN_MONITOR views.USER_IO_WAIT_TIME "IO Wait Time (micro s)" from V$SQL_MONITOR M. select STATUS. SMALL_READ_REQS "single block read requests".Enhanced I/O statistics I/O statistics are collected for all I/O calls made by Oracle Database in the following dimensions: consumer group. LARGE_WRITE_REQS "multiblock write requests". SQL monitoring is automatically started when a SQL statement runs parallel. LARGE_WRITE_REQS "multiblock write requests". The V$IOSTAT_FUNCTION view captures I/O statistics for database functions (such as the LGWR and DBWR).'hh24:mi') "First Refresh Time". Page 75 Oracle 11g New Features for Administrators . V$SQL S where M. Following are the new views providing this information: V$IOSTAT_CONSUMER_GR OUP captures I/O statistics for consumer groups.SQL_ID AND upper(SQL_TEXT) like 'SELECT%FROM%NAMES%' An alternative more convenient method is to DBMS_SQLTUNE. I/O statistics for all consumer groups that are part of the currently enabled resource plan are captured.Summary Sheets .Single block operations are small I/Os that are less than or equal to 128 kilobytes.2) "Total wait time (ms)" from V$IOSTAT_FUNCTION order by FUNCTION_NAME.I/O stats by functionality select FUNCTION_NAME. round(SMALL_SYNC_READ_LATENCY/1000. M.

END. use the MONITOR hint. select /*+MONITOR*/ from . or ranges of values. This execution plan is then used for all every execution of the statement. regardless of the bind variable values. / print :my_rept The SQL monitoring feature is enabled at the database level by default when the STATISTICS_LEVEL initialization parameter is either set to ALL or TYPICAL (the default value). the CONTROL_MANAGEMENT_PACK_ACCESS parameter must be set to DIAGNOSTIC+TUNING (the default value). it allows certain bind variable values.Summary Sheets . Oracle 11g uses Adaptive Cursor Sharing which compares the effectiveness of execution plans between executions with different bind variable values. Additionally. Page 76 Oracle 11g New Features for Administrators . use the NO_MONITOR reverse hint. to use alternate execution plans for the same statement. they sometimes lead to less than optimum execution plans. To force SQL monitoring at the SQL statement level. To prevent the hinted SQL statement from being monitored. Adaptive Cursor Sharing When bind variables are used in the SELECT statements against columns containing skewed data. This functionality requires no additional configuration. If it notices suboptimal plans. The optimizer creates the execution plan during the hard parse when the statement is first presented to the server...

Same rule apply when you upgrade a database from an earlier version to Oracle 11g.Summary Sheets . Oracle by default will create the database with new level of security settings as follows: Database audits of relevant SQL statements and privileges Modifications to the default profile. The following query will display the database users whose passwords are not case sensitive: select USERNAME.Database Security Stronger Password Hash Algorithm In Oracle Database 11g. audit data is stored in AUD$ table which should be manually maintained by you. Default Auditing Whether you create a new Oracle 11g database or you upgrade the database to Oracle 10g. the SHA-1 standard became the new algorithm for password hashing. users’ passwords will remain case-insensitive until you manually reset them. the database will delay the response to the client after the third attempt. If you import a dump file of users from Oracle Database 9i or 10g. If you want to disable auditing a specific operation. use the NOAUDIT command. if you accept to the auditing defaults. SUCCESS. the following operations will be audited: Alter any procedure Alter any table Alter database Alter profile Alter system Alter user Audit role by access Audit system Drop any procedure As with previous versions. S/MIME. Case-Sensitive Passwords Oracle 11g introduces case-sensitive passwords for databases created with the default Oracle Database 11g enhanced security. FAILURE from DBA_PRIV_AUDIT_OPTS order by PRIVILEGE. alter system set SEC_CASE_SENSITIVE_LOGON = TRUE. PGP. SSH. PASSWORD_VERSIONS from DBA_USERS Page 77 Create any job Create any library Create any procedure Create any table Create external job Create public database link Create session Create user Drop any table Drop profile Drop user Exempt access policy Grant any object privilege Grant any privilege Grant any role Audit system by access Oracle 11g New Features for Administrators . SHA-1 is a 160bit hash employed in several widely used security applications and protocols. Delayed Failed Logins If a user tries to connect to the database multiple times using an erroneous password. issue the following query: select PRIVILEGE. The new default profile is set with these settings: PASSWORD_LOCK_TIME=1 PASSWORD_GRACE_TIME=7 PASSWORD_LIFE_TIME=180 FAILED_LOGIN_ATTEMPTS=10 PASSWORD_REUSE_MAX=UNLIMITED PASSWORD_REUSE_TIME=UNLIMITED DBCA will automatically set the AUDIT_TRAIL initialization parameter to DB. The SEC_CASE_SENTITIVE_LOGON parameter must be set to TRUE to enable case-sensitive database passwords. Security Out of the Box Default Database Security Settings If you create a database using DBCA and you select to enable the security settings. including TLS and SSL. The delays of response back to the client are repeated even if the connections are initiated from different IP addresses or hosts. To display the privileges that are audited. and IPsec.

however. The server protects itself at the expense of the client (for example. and must has at least one letter and one digit. Case-Sensitive Password Files Passwords created in the password file can be set as case-sensitive by using the new option ignorecase with the utility orapwd. you must alter the password on Oracle Database 11g to the uppercase equivalent of the password designated in the database link’s CONNECT TO USERNAME IDENTIFIED BY clause section. It is a good practice to change passwords of users displayed by this view. Database Links and Case Sensitivity If you create a database link in an earlier version of Oracle than 11g.sql The function forces restrictions on the database users' passwords like minimum eight characters. n) The client experiences a delay of n seconds before the server process accepts the next request from the same client connection. a client transaction may be lost). The script $ORACLE_HOME/rdbms/admin/utlpwdmg. Anti Network Attacks Parameters Oracle Database 11g provides some initialization parameters to protect against Internet attacks including the following: SEC_PROTOCOL_ERROR_FURTHER_ACTION Specifies the further execution of a server process when receiving bad packets from a possibly malicious client. A minimal log message is printed in the alert logfile and in the server trace file. the DBA_USERS view in Oracle Database 11g has the password column blanked out instead of displaying the hashed value of the password. @$ORACLE_HOME/rdbms/admin/utlpwdmg. enables it in the default profile and also it creates the Oracle 10g function for legacy compatibility.sql creates the new function (named as VERIFY_FNCTION_11G). Following is an example: orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=ORAcle123 \ entries=25 ignorecase=n Change Default User Passwords The new DBA_USERS_WITH_DEFPWD view reports those accounts with default passwords for Oracle-supplied database accounts. select USERNAME from DBA_USERS_WITH_DEFPWD order by USERNAME. TRACE LOG A detailed trace file is generated when bad packets are received. PASSWORD from DBA_USERS order by USERNAME. Hiding Password Hash Values in DBA_USERS To provide further level of security. (DELAY. SEC_PROTOCOL_ERROR_TRACE_ACTION Specifies the trace level when bad packets are received from a possibly malicious client.where PASSWORD_VERSIONS NOT LIKE '%11G%' order by USERNAME. n) (DROP. A minimal Page 78 Oracle 11g New Features for Administrators . is not enabled by default. Following are its possible values: CONTINUE The server process continues execution. cannot be same or similar to the user name or the hostname.Summary Sheets . NONE The database server ignores the bad packets and does not generate any trace files or log messages. New Password Verification Function Oracle 11g provides a new password verification function with stronger settings than those in the functions of earlier versions. The server forcefully terminates the client connection after n bad packets. which can be used to debug any problems in client/server communication. select USERNAME. The database server may be subject to a Denial of Service (DoS) if bad packets continue to be sent by a malicious client. This function.

You cannot re-create the tablespace encryption key. the Wallet must be opened using the following command: ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY password>. Not returning the banner will make hacking a database more difficult since the user will not know which version of the database they are trying to hack. the data remains encrypted when it is stored in the redo logs. Tablespace Encryption In Oracle Database 11g. In this case. Also. This is done only once: ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY <password>.1 or higher. To verify that a wallet is open. Encrypted Tablespace Limitations • • • • • • You cannot encrypt an existing tablespace. Setting up TDE As with Oracle 10g. COMPATIBLE parameter must be set to 11. STATUS from V$ENCRYPTION_WALLET. you can perform the following steps to set up TDE: Add the following to the sqlnet. use Oracle Data Pump to export the objects in the tablespace using the expdp with ENCRYPTION_MODE=password and then import them to the destination database. the entire tables and associated indexes in the tablespace are encrypted. Opening and Closing the Wallet If you restart the instance. SEC_MAX_FAILED_LOGIN_ATTEMPTS Defines the number of authentication attempts that a given client connection can make on the server before the client process is dropped. Page 79 Oracle 11g New Features for Administrators . When you use an encrypted tablespace. as an extension to Transparent Data Encryption (TDE). You cannot transport an encrypted tablespace to a database that already has an Oracle wallet for TDE. The default value is 10. The NO SALT option is not supported. encrypted tablespace is less efficient than normal un-encrypted tablespace. SEC_RETURN_SERVER_RELEASE_BANNER Determines if the server banner will be returned to a client connection. ALERT An alert message is sent to a DBA or monitoring console. Tablespace encryption relies on encryption keys in a wallet outside the database. you can encrypt an entire tablespace. BFILES and external tables are not encrypted. Always include the wallet file in your backup plan and save the master key password in safe place. Logically.ora file: ENCRYPTION_WALLET_LOCATION = (SOURCE= (METHOD=file) (METHOD_DATA= (DIRECTORY=C:\oracle\OraDb10g\admin\ora10g\wallet))) Set the master key.amount of disk space is used.Summary Sheets . you can query the V$ENCRYPTION_WALLET view: select WRL_PARAMETER. Whereas expdp and impdp utilities are supported. exp and imp utilities are not supported with objects in the encrypted tablespaces. • • • Caution Losing the master key or the wallet file will lead to losing the data in the encrypted tablespace. ALTER SYSTEM SET ENCRYPTION WALLET CLOSE. Temporary and undo tablespaces cannot be encrypted.

You can then query the RESOURCE_VIEW view to find the dba. UTL_HTTP. PRIVILEGE => 'connect'. [ENCRYPTION [USING <ALGORITHM>]] -. -. with the UTL_INADDR package.Encrypting a Tablespace The tablespace creation statement for an encrypted tablespace has the following syntax: CREATE TABLESPACE <tbsp_name> .xml'.xml ACL in the /sys/acls directory: select ANY_PATH from RESOURCE_VIEW where ANY_PATH LIKE '/sys/acls/dba%' Too may entries in the ACL may lead to significant XML DB performance drop because ACL are checked for each access to Oracle XML DB repository.or 'resolve' (case sensitive) START_DATE => null. -.. Regarding the PRIVILEGE parameter. The following example will add the user RAMI to the dba.TS#=vt.Summary Sheets .when the access control entity ACE will be valid END_DATE => null). -. issue the following query: select vt. COMMIT. UTL_SMTP. ACL check operations perform best when the number of ACEs in the ACL is at 16 entries or less. and UTL_INADDR. and UTL_MAIL utility packages.NAME.xml: begin DBMS_NETWORK_ACL_ADMIN.privilege is granted or denied PRIVILEGE => 'connect'.. Following is an example of using the CREATE_ACL procedure to create an XML file called dba. END_DATE => null).ENCRYPTEDTS from V$ENCRYPTED_TABLESPACES vet. 2) Add Access Control Entries: Once you create the initial ACL. -.TS# Fine-Grained Access Control for UTL_* Packages Oracle Database 11g provides a mechanism to refine the level of access to the network access packages UTL_TCP. -. 3DES168 Triple Data Encryption Standard 168-bit encryption AES128 Advanced Encryption Standard 128-bit encryption AES256 Advanced Encryption Standard 256-bit encryption To know whether an existing tablespace is encrypted or not.xml'.specify encryption algorithm DEFAULT STORAGE(ENCRYPT) -. Page 80 Oracle 11g New Features for Administrators .CREATE_ACL ( ACL => 'dba.encrypt objects in the tablespace The ALGORITHM clause accepts one of the following values: o o o o AES192 Advanced Encryption Standard (the default). or the IP address that was given as a host name. the database user needs the connect privilege to an external network host computer if he or she is connecting using the UTL_TCP.if the time interval is defined. -.the ACE will expire after the specified date range end. vet. -. UTL_MAIL.xml file and grant him network access: begin DBMS_NETWORK_ACL_ADMIN. The ACL XML files reside in the /sys/acls directory of the XML DB repository. As general rule of thumb. UTL_SMTP. To resolve a host name that was given as a host IP address. PRINCIPAL => 'SCOTT'. IS_GRANT => TRUE.ENCRYPTIONALG.ADD_PRIVILEGE ( ACL => 'dba. -.ACE expiration date (TIMESTAMP WITH TIMEZONE format) end. You can use the DBMS_NETWORK_ACL_ADMIN package to facilitate management of the UTL_* network access packages as in the following steps: 1) Create an Access Control List (ACL): All ACL definitions are stored in XML DB in the form of XML documents. grant the database user the resolve privilege. UTL_HTTP. START_DATE => null. V$TABLESPACE vt where vet. you can continue to add more privileges to the XML file. PRINCIPAL => 'RAMI'.case sensitive DESCRIPTION=> 'Network Access Control for the DBAs'.user or role the privilege is granted or denied (upper case) IS_GRANT => TRUE. vet.

xml'.ADD_PRIVILEGE ( POSITION => 1. The lower port and the upper port define the lower and the upper boundaries of the allowable port range.In ACL. exec DBMS_NETWORK_ACL_ADMIN. PRIVILEGE. 3) Assign Hosts: The ASSIGN_ACL procedure is used to authorize access to one or more network hosts as follows: begin DBMS_NETWORK_ACL_ADMIN.DOMAINS('dbaexpert.DELETE_PRIVILEGE( ACL=>'dba. If the sufficient ACL privileges or ACL assignments are not provided.xml' ). They should be set for connect privileges not resolve privileges. Following is an example to test the code in the previous step.REQUEST('http://www.com') from dual. If you have two contradicting entries in the list. end. use the following query: select HOST.xml' Logged on users can use the following query to see their access entries in the dba. Further Security New Features New SYSASM Privilege for ASM Administration SYSASM is a new privilege introduced in Oracle 11g. select UTL_HTTP. UPPER_PORT => 443). end. COMMIT. END_DATE => null). 4) Validate that the ACL permissions worked accordingly.com'. START_DATE => null. UPPER_PORT. PRINCIPAL=> 'RAMI'). LOWER_PORT => 80.DOMAIN_LEVEL(host) desc. PRINCIPAL => 'SAMI'. the first one in the order will take effect. Use the DROP_ACL procedure to remove the XML file from the /sys/acls directory as follows: exec DBMS_NETWORK_ACL_ADMIN. Users who are granted this privilege can perform ASM administration tasks.ahmedbaraka.xml'. IS_GRANT from DBA_NETWORK_ACL_PRIVILEGES where ACL like '%dba.on the top ACL => 'dba. Query Your Access Control List To display list of the ACLs created in the database.Summary Sheets . LOWER_PORT. The idea behind this privilege is to separate database management and the storage Page 81 Oracle 11g New Features for Administrators . IS_GRANT => FALSE.ASSIGN_ACL ( ACL => 'dba. you will receive the ORA-24247 error. STATUS privilege from USER_NETWORK_ACL_PRIVILEGES where HOST in (select * from table(DBMS_NETWORK_ACL_UTILITY. -. LOWER_PORT.xml'.xml file: select HOST. UPPER_PORT.com'))) and PRIVILEGE = 'connect' order by DBMS_NETWORK_ACL_UTILITY. PRIVILEGE => 'connect'. LOWER_PORT. ACL from DBA_NETWORK_ACLS You can query the DBA_NETWORK_ACL_PRIVILEGES view to query network privileges granted or denied for the access control list as follows: select PRINCIPAL.DROP_ACL ( ACL=>'dba. Access Control Lists Maintenance Use DELETE_PRIVILEGE to remove an access control entry from the XML file. You can control the order number of an added entry as follows: begin DBMS_NETWORK_ACL_ADMIN. HOST => 'dbaexpert. the security entries are evaluating in order precedence.

Summary Sheets . Page 82 Oracle 11g New Features for Administrators . For details of all the new enhancements related to Data Pump. refer to the section "Virtual Private Catalogs". For further details about using this privilege. For complete details on RMAN virtual private catalogs.management responsibilities. RMAN Virtual Private Catalog In Oracle Database 11g. refer to the chapter "Automatic Storage Management". Data Pump Encryption Oracle Database 11g introduces the encryption of Data Pump dump files. you can restrict access to the recovery catalog by granting access to only a subset of the metadata in the recovery catalog. refer to the chapter "Data Pump".

cmd' USING $media_family $format $restore_point 3. that is USING. This requires the database to work in archivelog mode and has the Database Flashback enabled. Following is an example: #!/bin/tcsh # name: runbackup. RMAN command line now has a new keyword. any attempt by users to access data in the corrupt blocks will result in an error message.to fix all corrupted blocks in the database -.sh # usage: use the tag name and number of copies as arguments set media_family = $argv[1] set format = $argv[2] set restore_point = $argv[3] rman @'/u01/scripts/quarterly_backup. Following is an example: %runbackup. BACKUP DATABASE TAG &2 FORMAT '/disk2/bck/&1%U. The new command is more efficient since because it searches the flashback logs for older uncorrupted versions of the corrupt blocks. Create an RMAN command file that uses substitution variables.after validate database. Following are examples of using the new command: RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10. block command replacing the old blockrecover command. Following is an example: # quarterly_backup. Following are the steps to create dynamic shell script that accepts substitution variables in a Unix platform: 1.Summary Sheets . } EXIT. Run the shell script and pass the values to the substitution variables. named the recover . -. RMAN> RECOVER CORRUPTION LIST. 2. which is used to pass substitution variables to the command line. corrupted blocks are reported in V$DATABASE_BLOCK_CORRUPTION RMAN> VALIDATE DATABASE. which you can then incorporate in shell scripts..bck' KEEP FOREVER RESTORE POINT &3.. there is a new command to perform block media recovery. telling the user that the data block is corrupt. RMAN Substitution Variables You can now use substitution variables in RMAN command files. Create a shell script that you can use to run the RMAN command file created in the previous step.cmd CONNECT TARGET / RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=&1)'. RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10 FROM BACKUPSET = 11. While the block media recovery is going on.Backup and Recovery New Features Enhanced Block Media Recovery In Oracle Database 11g. RECOVER DATAFILE 2 BLOCK 24 DATAFILE 4 BLOCK 10 FROM TAG = sundaynight. Following are examples on how to do that.sh archival_backup bck0906 FY06Q3 Page 83 Oracle 11g New Features for Administrators .

The V$BACKUP_DATAFILE and RC_BACKUP_DATAFILE views have the new column SECTION_SIZE. device type disk . } -. DELETION POLICY parameters are new RMAN configuration The OMPRESSION ALGORITHM parameter sets the compression algorithm used by RMAN for compressing a backup. If a backup process failed. select PIECE#. Page 84 Oracle 11g New Features for Administrators . You can have up to 256 sections per datafile.RMAN command file hr_backup.Batch file hr_backup. 500m tablespace example. SECTION_SIZE from V$BACKUP_DATAFILE. Use the new backup command clause SECTION SIZE to perform multisection backups as follows: run { allocate channel c1 allocate channel c2 allocate channel c3 backup SECTION SIZE device type disk . ZLIB It is optimized for CPU efficiency. In a multisection backup. you can backup the datafile into sections with each section of a size equals to the size of your storage unit.cmd' USING %1 %2 --. If the backup command was executed in command-line.Summary Sheets .cmd CONNECT TARGET / RUN { ALLOCATE CHANNEL c1 DEVICE TYPE disk. but will usually produce more compact backups. however. -. only those sections that were not backed up prior to the backup failure are required to backup. This column specifies the number of blocks in each section of a multisection backup and its value is 0 for whole file backups. If you have a datafile of a size larger than the maximum size of your storage medium unit (for example the tape).bat rman @'C:\orabackup\scripts\hr_backup. device type disk .bck'.bat HR01MAR08 RS_HR01MAR08 New RMAN Configuration Parameters The COMPRESSION ALGORITHM and ARCHIVELOG parameters in the Oracle Database 11g. if it was not configured in RMAN. U The Multisection Backups 85B Oracle 11g lets you back up and restore a large file in sections. will take place.Following is an example of achieving the same concept steps but in Windows platform: -. SQL 'CREATE RESTORE POINT &2'. the output backupset will have backup pieces of size 500 MB each.} EXIT. each RMAN channel backs up a different section of a datafile.three channels operate in parallel The example above shows how to use the multisection backup in a block. No parallelism.run the batch file hr_backup. BACKUP DATAFILE 'c:\oracle\oradata\ora11g\HR_TBS1. This leads to the following benefits: o o o Backup performance of a large file is significantly enhanced by allocating multiple channels to backup the datafile.DBF' TAG &1 FORMAT 'c:\orabackup\&1%U. It requires the Oracle Advanced Compression option. Its possible values are the following: consumes more CPU resource than ZLIB. U The ARCHIVELOG DELETION POLICY parameter will be discussed in Configuring an Archived Redo Log Deletion Policy section.

you have a new option.1) B28270-02". NOKEEP. SKIP INACCESSIBLE database. KEEP is an archival backup.validates recovery files created in the current and all previous flash recovery area -. backupset 17.Creating Archival Backups The BACKUP . datafile 3 block 24. Following are examples of some VALIDATE command options: validate validate validate validate validate validate validate [CHECK LOGICAL] database. -. The following examples illustrate how to use the command: RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=archival_backup)'. use the CHANGE command as follows: CHANGE BACKUP TAG 'weekly_bkp' KEEP FOREVER. } Note BZIP2 You can’t use the KEEP clause for backup files in the flash recovery area. Details about how to achieve that is explained in the documentation "Oracle Database Backup and Recovery User's Guide 11g Release 1 (11. You can optionally specify CHECK LOGICAL.bck' TAG TESTDB KEEP UNTIL 'SYSDATE+1' RESTORE POINT TESTDB08. In the new version of the command. The backup is all-inclusive because every file needed (including archived redo logs) to restore and recover the database is backed up to a single disk or tape location for long-term storage. -. KEEP command can be used to create a backup that is both all-inclusive and exempt from the backup retention policy. Page 85 Oracle 11g New Features for Administrators . page 23-21. you cannot use the CHANGE . the KEEP.regardless the configured retention policy BACKUP DATABASE FORMAT '/u01/oraclebck/%U. -. In Oracle 11g. If you want to change the status of a regular backup to an archival backup.. and even individual data blocks. The command by default checks for physical corruption.Summary Sheets ...with forever option (recovery catalog is required) BACKUP DATABASE TAG BAKQ108 KEEP FOREVER RESTORE POINT FY08Q1. KEEP command for backup files stored in the flash recovery area. -. RESTORE POINT.. However. and UNTIL TIME options are retained.. Also. Instead.. -.destinations validate recovery area. the backup becomes obsolete. Corrupted blocks are reported in V$DATABASE_BLOCK_CORRUPTION. copy of database. Restoring an Archival Backup The procedure for restoring the archival backup is the same as for duplicating a database except in the DUPLICATE command you must specify the restore point that was created with the archival backup. backup sets. section "Using DUPLICATE to Restore an Archival Backup". some modifications made on the RMAN BACKUP .make it follow back the retention policy CHANGE BACKUP TAG 'weekly_bkp' NOKEEP. copy of tablespace hr_tbs. The general name for a backup created with BACKUP . -. Note The VALIDATE command checks only for intrablock corruption both physical and logical in nature. KEEP command. The RESTORE POINT option lets RMAN automatically create a normal restore point.After one day. It doesn’t check for interblock corruption.backup will be kept for 365 days (long-term) BACKUP DATABASE TAG BAKQ108 KEEP UNTIL TIME 'SYSDATE+365' RESTORE POINT FY08Q1.18. FOREVER. VALIDATE Command You can use the new command VALIDATE to manually check for physical and logical corruptions in datafiles... tablespace hr_tbs. the LOGS and NOLOGS options are not there any longer.

Caution The BACKUP ARCHIVELOG command is affected by the archived log deletion policy. and tempfiles.disable the policy CONFIGURE ARCHIVELOG DELETION POLICY TO NONE. 1.1 Decide on what are the names of the duplicate files on the destination server. If the target database is open. then skip to the next step. however. Decide on Duplicate File Names If you are duplicating to a different host that uses the same directory structure as the source host. When you issue the DUPLICATE command later. If the deletion policy is configured with the BACKED UP n TIMES clause. Implementing active database duplication includes the following steps: 1. then the BACKUP ARCHIVELOG command skips the logs. Following are examples: -. Instance that runs the duplicated database is called auxiliary instance. run the CONFIGURE ARCHIVELOG DELETION POLICY BACKED UP n TIMES command with the desired options. Following is an example on how to do that: run {ALLOCATE CHANNEL CH1 DEVICE TYPE DISK.archived redo logs are eligible for deletion when there are at least two backups of -. This deletion policy applies to all archiving destinations. To enable an archived redo log deletion policy. VALIDATE DATAFILE 3 SECTION SIZE = 500M. You can. Page 86 Oracle 11g New Features for Administrators . and if you want to name the duplicate files the same as the source database files..Validating large datafiles can be speeded up by splitting the checked files into sections and those sections are checked in parallel. Duplicate files include: control files. DELETE ARCHIVELOG ALL considers only the configured archived log deletion policy. DELETE and DELETE . you will use its options to implement the new names. including the flash recovery area. Oracle Net must be aware of both the target and duplicate instances. it must be in ARCHIVELOG mode.} Configuring an Archived Redo Log Deletion Policy You can use RMAN to create a persistent configuration that controls when archived redo logs are eligible for deletion from disk or tape. The target database must be open or in mount state. ARCHIVELOG commands. Prerequisites • • • • • Both the target and destination databases must be on an identical operating system platform. In contrast. online redo logs. This direct database duplication is called active database duplication. Active Database Duplication In Oracle Database 11g.them on the tape CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO SBT. you can directly duplicate a database over the network without having to back up and provide the source database files. If n backups of the logs exist. datafiles. it applies on the automatic deletion of the logs in the flash recovery area and the manual deletion by the BACKUP . then a BACKUP ARCHIVELOG command copies the logs unless n backups already exist on the specified device type. Note DELETE OBSOLETE considers only the backup retention policy and does not use the configured archived log deletion policy to determine which logs are obsolete... The password file must exist for the source database and both the target and destination databases must have the same SYS password..Summary Sheets . It can be done either with Database Control or through RMAN. When the policy is configured. -. ALLOCATE CHANNEL CH2 DEVICE TYPE DISK. override the archived redo log deletion policy you configured by specifying the FORCE clause in the BACKUP ARCHIVELOG command.

In this case. Start the instance in NOMOUNT mode.1.2 Establish Oracle Net connectivity to the auxiliary instance in both the source and destination servers. the recovery catalog database.2.168.\pfile..ora in the destination DB_NAME=dup1 2. Start RMAN and connect to the source database as TARGET. You can create the password file manually or by specifying the PASSWORD FILE option on the DUPLICATE command.2.255. Also add the auxiliary database service to the listener configuration file in the source server. PASSWORD FILE .Summary Sheets .manually #orapwd FILE=PWDora11g2. RMAN>CONNECT TARGET SYS@prod # source database RMAN>CONNECT AUXILIARY SYS@dupdb # duplicate database instance RMAN>CONNECT CATALOG rman@catdb # recovery catalog database 3. Start and Configure RMAN Before Duplication 3.. specifying the PFILE parameter: SQL>conn sys/mypassword@dup1 as sysoper SQL>STARTUP NOMOUNT pfile=c:\. if applicable.init 3. the duplicate database instance as AUXILIARY.1 Create a password file in the destination server with the same SYSDBA password as the source database. #contents of the init..world) (PROTOCOL = TCP) (Host = 192.use PASSWORD FILE option RMAN>DUPLICATE TARGET DATABASE .ora PASSWORD=mypassword ENTRIES=10 ignorecase=n 2. -.4 Use SQL*Plus to connect to the auxiliary database instance with SYSOPER privileges.32) (Port = 1521) ) ) (CONNECT_DATA = (SID =dup1) (SERVER = DEDICATED) ) ) SID_LIST_LISTENER = (SID_DESC = (GLOBAL_DBNAME = prod1) (ORACLE_HOME = /u01/app/oracle/product/10g/) (SID_NAME =prod1) ) (SID_DESC = (GLOBAL_DBNAME = dup1) (ORACLE_HOME = /u01/app/oracle/product/10g/) (SID_NAME =dup1) ) ) 2. Following are examples of a configuration in tnsnames. Prepare the Auxiliary Instance 2.ora files: dup1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = tcp...3 Including SPFILE option in the DUPLICATE command will make RMAN copy the SPFILE from the source server to the destination. you need to create a text-based initialization parameter file for the auxiliary instance that contains only one parameter: DB_NAME which can be set to an arbitrary value. Page 87 Oracle 11g New Features for Administrators . CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET. You may want to increase the parallelism setting of your source database disk channels so that RMAN copies files over the network in parallel. -.ora and listener. and.

-.RMAN should duplicate the password file from the source FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK.duplicating a database to a remote host with a different directory structure DUPLICATE TARGET DATABASE TO dupdb FROM ACTIVE DATABASE DB_FILE_NAME_CONVERT '/oracle/oradata/prod/'. RMAN>UPGRADE CATALOG. connect target sys/mypassword@db1 catalog rman/rman@dest UNREGISTER DATABASE.Summary Sheets . -.4.if you want to recover the duplicate database to one week ago DUPLICATE TARGET DATABASE TO dupdb PASSWORD FILE SPFILE NOFILENAMECHECK UNTIL TIME 'SYSDATE-7'. # to determine the schema version of the recovery catalog # start SQL*Plus and connect to the recovery catalog database as the catalog owner SQL>conn rman/ramn@mydb #the highest version in the RCVER table is the current catalog schema version SQL>SELECT * FROM rcver.'/scratch/oracle/oradata/dupdb/' SPFILE PARAMETER_VALUE_CONVERT '/oracle/oradata/prod/'. '/scratch/oracle/oradata/dupdb/redo/'. Run the DUPLICATE command Following are the options to issue the DUPLICATE command in the RMAN session. # start RMAN and connect to the recovery catalog database RMAN catalog rman/rman@mydb # upgrade the catalog (run the command twice to confirm) RMAN>UPGRADE CATALOG. the version of the source recovery catalog schema must be equal to the current version of the RMAN executable with which you run the command. If the source catalog schema is a lower version. then upgrade it to the current version before importing the schema. GRANT CREATE TYPE TO rman. Prerequisites for Importing a Recovery Catalog If a database is currently registered in both the source and destination catalog schemas. When using IMPORT CATALOG. Importing and Moving Recovery Catalogs You can use the IMPORT CATALOG command in RMAN to merge one recovery catalog schema into another. Page 88 Oracle 11g New Features for Administrators . then unregister the database from source catalog schema before performing the import. -. RMAN will restart the instance with RESETLOGS. # to upgrade a recovery catalog schema to the current RMAN version # make sure the CREATE TYPE privilege is granted to the RECOVERY_CATALOG_OWNER role SQL>SELECT PRIVILEGE FROM ROLE_SYS_PRIVS WHERE ROLE='RECOVERY_CATALOG_OWNER' AND PRIVILEGE = 'CREATE TYPE'. After the duplication is finished. '/scratch/oracle/oradata/dupdb/' SET SGA_MAX_SIZE '300M' SET SGA_TARGET '250M' SET LOG_FILE_NAME_CONVERT '/oracle/oradata/prod/redo/'.duplicating a database to a remote host with the same directory structure DUPLICATE TARGET DATABASE TO dupdb PASSWORD FILE -.

you will notice all databases are unregistered from RMAN repository RMAN>LIST INCARNATION. Following are the steps to create a new private catalog for the database user SCOTT: # grant the role RECOVERY_CATALOG_OWNER to the user SQL>GRANT RECOVERY_CATALOG_OWNER TO scott. # in RMAN session. If the catalog is to be used for releases pre-Oracle 11g clients. mydb2. connect as the base catalog owner RMAN>CONNECT CATALOG rman/rman@mydb RMAN>GRANT CATALOG FOR DATABASE db1. Virtual Private Catalogs 91B In Oracle Database 11g. The set of views and synonyms that makes up the virtual private catalog is stored in the schema of the virtual catalog owner.Summary Sheets . Moving a Recovery Catalog to Another Database By following the same steps of using the IMPORT CATALOGE to import a recovery catalog schema. Note A virtual private catalog owner can create a local stored script. RMAN>IMPORT CATALOG rman1/rman1@src DB_NAME = mydb1. # make sure only granted dbs are seen RMAN>LIST INCARNATION.DBMS_RCVCAT. Only make sure the destination has a new recovery catalog without any database registered in it. # connect as the granted user (virtual catalog onwer) and create the virtual catalog RMAN>CONNECT CATALOG scott/lion@mydb RMAN>CREATE VIRTUAL CATALOG. where "rman" is the name of the base catalog owner: SQL> CONN scott/lion@mydb SQL> EXEC rman. you can also move a catalog schema from one database (source) to another (destination). but has only read-only access to global scripts. The central or source recovery catalog is now called the base recovery catalog. # in the source. RMAN automatically renames the scripts from the source recovery catalog (the format for the renamed files is COPY OF Script_Name). you can restrict access to the recovery catalog by granting access to only a subset of the metadata in the recovery catalog.CREATE_VIRTUAL_CATALOG. or just virtual catalog. RMAN>LIST INCARNATION. The CATALOG FOR DATABASE privileges include the privilege to register and unregister those databases for which the catalog for database privilege was granted.Importing a Recovery Catalog Following are examples of using the IMPORT CATALOG command: #connect to the destination recovery catalog RMAN>connect catalog rman/rman@dest #Issue the import catalog command # all RMAN repository metadata is imported from src to dest RMAN>IMPORT CATALOG rman1/rman1@src. db2 TO SCOTT. # to import from source without the automatice databases unregistration RMAN>IMPORT CATALOG rman1/rman1@src NO UNREGISTER. Page 89 Oracle 11g New Features for Administrators . The subset that a user has read/write access to is termed as virtual private catalog. in the SQL*Plus log on as the virtual private catalog owner and run the following procedure. # to import metadata of specific databases RMAN>IMPORT CATALOG rman1/rman1@src DBID = 123456. Note If you have global stored scripts in the both recovery catalogs with identical names. RMAM>connect target rman1/rman1@src. 123457.

Page 90 Oracle 11g New Features for Administrators . to perform most of the RMAN operations on it. Following is an example: # Log in as the virtual catalog owner: RMAN>CONNECT CATALOG scott/<password>@mydb. during a backup. Miscellaneous New Features in RMAN 92B Archived Redo Log Failover The archived redo log failover feature enables RMAN to complete a backup even when some archiving destinations have missing logs or contain logs with corrupt blocks.Summary Sheets . # Issue the drop catalog command RMAN>DROP CATALOG.Managing Virtual Private Catalogs The base recovery catalog owner can optionally grant a virtual catalog owner the right to register new target databases in the recovery catalog by specifying the REGISTER database clause with the GRANT command. Following are examples of removing the privileges from a virtual catalog owner: # To remove recovery catalog access to a database from a user: RMAN>CONNECT CATALOG RMAN/RMAN@MYDB. Caution When the DROP CATALOG command is issued by the virtual catalog owner. Dropping a Virtual Private Catalog Virtual private catalog owners can drop the private recovery catalog they own by issuing the DROP CATALOG command. Since the new optimized undo backup is automatically enabled. # To revoke both the catalog and register privileges from a user: RMAN>REVOKE ALL PRIVILEGES FROM scott. thus leading to a saving of storage space as well as faster backups for large OLTP-type databases. RMAN>REVOKE CATALOG FOR DATABASE db1 FROM scott. # To revoke the ability to register new databases from a virtual private catalog owner: RMAN>REVOKE REGISTER DATABASE FROM scott. all the metadata pertaining to it is deleted from the base recovery catalog. the committed data is not backed up. The RMAN will search and use an alternative destination. you do not have to configure anything special to take advantage of this feature. Following is an example: RMAN> grant register database to scott. Optimized Backing Up of Undo Data In Oracle Database 11g. The virtual catalog owner must have the SYSDBA and SYSOPER privileges on the traget database.

DUAL mode creates a dump file set that can later be imported either transparently or by specifying a password that was used when the dual-mode encrypted dump file set was created. you must specify either the ENCRYPTION or ENCRYPTION_PASSWORD parameter. ENCRYPTION Parameter This parameter specifies whether or not to encrypt data before writing it to the dump file set. TRANSPARENT mode allows an encrypted dump file set to be created without any intervention from a database administrator (DBA).Summary Sheets .dmp compression=all Encryption Enhancements 94B To secure the exported dump file.hr_enc. The default value depends upon the combination of encryption-related parameters that are used. Those parameters are valid only in the Enterprise Edition of Oracle Database 11g. If neither ENCRYPTION nor ENCRYPTION_PASSWORD is specified. It syntax is as follows ENCRYPTION_MODE = { DUAL | PASSWORD | TRANSPARENT } PASSWORD mode requires that you provide a password when creating encrypted dump file sets.dmp JOB_NAME=enc ENCRYPTION=data_only ENCRYPTION_PASSWORD=mypassword ENCRYPTION_ALGORITHM Parameter This parameter specifies which cryptographic algorithm should be used to perform the encryption. the following new parameters are presented in Oracle 11g Data pump: ENCRYPTION. The ENCRYPTION parameter has the following options: ENCRYPTION = {all | data_only | encrypted_columns_only | metadata_only | none} Following is an example: expdp hr DUMPFILE=dp_dir. Oracle provides the mechanism to compress both data and metadata during the extract operation.compress. Following is an example: expdp hr DIRECTORY=dp_dir DUMPFILE=hr_enc. Following is its syntax: ENCRYPTION_ALGORITHM = { AES128 | AES192 | AES256 } The ENCRYPTION_ALGORITHM parameter ENCRYPTION_PASSWORD parameter. ENCRYPTION_PASSWORD and ENCRYPTION_ALGORITHM.dmp / ENCRYPTION_PASSWORD=mypassword ENCRYPTION_ALGORITHM=AES128 ENCRYPTION_MODE Parameter This parameter works the same way the encryption mode was operating in RMAN in Oracle 10g. provided the required Oracle Encryption Wallet is available. or both. then the ENCRYPTION parameter defaults to ALL. The available options for the COMPRESSION parameter are as follows: compression={all | data_only | metadata_only | none} Following is an example: $expdp full=yes userid="'/ as sysdba'" dumpfile=dbadir:full. It specifies the type of security to use when encryption and decryption are performed. If only the ENCRYPTION_PASSWORD parameter is specified. then ENCRYPTION defaults to NONE.Data Pump Utilities Compression Enhancement In Oracle Database 11g.dmp ENCRYPTION=all ENCRYPTION_PASSWORD=mypassword ENCRYPTION_ALGORITHM=AES256 ENCRYPTION_MODE=dual requires that you also specify either the ENCRYPTION or Page 91 Oracle 11g New Features for Administrators . Following is an example: expdp hr DIRECTORY=dp_dir DUMPFILE=hr_enc. To enable encryption.

begin v_return:=translate(p_in_data.column_name:[schema.]pkg.employees REMAP_DATA=hr.dmp TABLES=hr.function(s) used by the remap Create or replace package remap_pckg as function modify_char ( p_in_data varchar2) return varchar2.Reusing a Dump File In Oracle 11g data pump export utility.Summary Sheets . return v_return. The syntax of the using the parameter is as follows: REMAP_DATA=[schema.employees.'bcdefghijklmnopqrstuvwxyza'). Syntax of this parameter is as follows: REMAP_TABLE=[schema.function Following is an example of how to use it.dmp REMAP_TABLE=hr. end. the new parameter REUSE_DUMPFILES enables you to overwrite a preexisting dump file.modifychar Remap function should not issue any COMMIT or ROLLBACK statements.last_name:hr. Following is an example: expdp hr DIRECTORY=dp_dir DUMPFILE=hr. The REMAP_DATA parameter specifies a remap function that takes as a source the original value of the designated column and returns a remapped value that will replace the original value in the dump file. end.dmp TABLES=employees REUSE_DUMPFILES=y Remapping Data 96B There is a new parameter that allows you during export or import to modify the input or output data based on your remapping scheme. Renaming Tables During Export or Import 97B In Oracle 11g.]tablename.remap_pckg. the Data Pump allows you to rename a table during the import process with the REMAP_TABLE parameter.dmp REMAP_TABLE=hr.docs. / Create or replace package body remap_pckg as function modify_char (p_in_data varchar2) return varchar2 as v_return varchar2(30). Data Pump and Partitioned Tables 98B The new parameter PARTITION_OPTIONS specifies how table partitions should be created during an import operation.'abcdefghijklmnopqrstuvwxyz'. / expdp hr/passwd DIRECTORY=dp_dir DUMPFILE=remap. This parameter takes one of the following values: NONE creates tables as they existed on the system from which the export operation was performed.]old_tablename[. Page 92 Oracle 11g New Features for Administrators . end.docs:docs2 userid=hr/password impdp dumpfile=dp_dir:docs.part1:docs3 userid=hr/password Note Tables will not be remapped if they already exist even if the TABLE_EXISTS_ACTION is set to TRUNCATE or APPEND. -.partition]:new_tablename Following are examples of using this parameter impdp dumpfile=dp_dir:docs.

In the case of deferred constraints. create table docs organization external ( type ORACLE_DATAPUMP default directory dbadir access parameters ( logfile logdir:docs COMPRESSION ENABLED) -.dmp \ LOGFILE=logq1y08. the default is NONE. impdp Robert/robert DIRECTORY=data_pump_dir DUMPFILE=remap. impdp system/mypassword TABLES=sh.unload the P_Q1Y08 partition of the sh.sales:p_q1y08 USERID=sh/sh DIRECTORY=dp_dir DUMPFILE=p_q1y08.dmp tables=ROBERT. Enhancement in the Transportable Parameter 10B With Oracle 11g. you needed the REJECT LIMIT clause to do so. as appropriate. imports will always be rolled back. partitions. Following are examples of using this new parameter: -. If the export operation that created the dump file was performed with the transportable method. creating external tables using ORACLE_DATAPUMP driver is enhanced. The default name of the new table will be the concatenation of the table and partition name or the table and subpartition name.import the P_Q1Y08 partition of the sh. In Oracle Database 10g. only the metadata associated with specific tables. combines all partitions and subpartitions into one table.log REUSE_DUMPFILES=Y TRANSPORTABLE=always -. You can take advantage of the new COMPRESSION and ENCRYPTION (required TDE enabled) options.dmp \ LOGFILE=logdir:logq1y08. then the import operation must use the DEPARTITION option.merge all the partitions in sh.dmp REMAP_SCHEMA=sh:scott -. then the import operation cannot use the MERGE option. when you use the TRANSPORTABLE parameter in the data pump import and export utilities.dbf' Ignoring Nondeferred Constraints 9B In Oracle 11g.sales into one non-partitioned table in scott schema. a row error will not cause a table load to abort.sales table impdp USERID="'/ as sysdba'" PARTITION_OPTIONS=departition DUMPFILE=dp_dir:p_q1y08. Otherwise. Restrictions • • • If the export operation that created the dump file was performed with the TRANSPORTABLE method and if a partition or subpartition was specified. an error message is generated and the objects are not loaded.Summary Sheets . Page 93 Oracle 11g New Features for Administrators .dmp') ) as select * from documents Another improvement.DEPARTITION promotes each partition or subpartition to a new individual table.sales PARTITION_OPTIONS=merge DIRECTORY=dp_dir DUMPFILE=sales. setting the DATA_OPTIONS parameter to SKIP_CONSTRAINT_ERRORS will cause the import program to skip errors generated by the nondeferred database constraints.you can add ENCRYPTION ENABLED location ('docs.sales table with the TRANSPORTABLE=ALWAYS expdp TABLES=sh. the behavior of the parameter remains the same as in the previous version. MERGE The default is DEPARTITION when partition names are specified on the TABLES parameter and TRANPORTABLE=ALWAYS is set (whether on the import operation or the export).NAMES data_options=SKIP_CONSTRAINT_ERRORS External Tables Based on Data Pump Driver 10B In Oracle 11g. rather than all metadata. Other than that.log TRANSPORT_DATAFILES='+FRA/dba11g1/kb2. or subpartitions will be extracted. If there are any grants on objects being departitioned.

perform the following steps: 1. and click the Next button. In the Upgrades Operations page. When the operation finishes. 4. The DBUA utility logs its operation in the $ORACLE_BASE/cfgtoollogs/dbua/logs/ASMUpgrade. . 3. a successful message should be displayed. 4. Using the SYSASM privilege instead of the SYSDBA privilege provides a clearer division of responsibility between ASM administration and database administration. Install the Oracle Database 11g software to a new ORACLE_HOME directory. Upgrading ASM Manually 104B Following are the steps you follow to upgrade an existing Oracle 10g ASM to 11g: 1. Upgrading ASM using DBUA 103B Database Update Assistant (DBUA) can be used to upgrade the ASM instance from Oracle Database 10g to Oracle Database 11g.ASM management commands are available to Adam CONNECT firas/his_password ALTER DISKGROUP dg1 DISMOUNT. ALTER DISKGROUP dg2 MOUNT. confirm the source and target information. Copy the ASM initialization file from the old ORACLE_HOME to the new one. cd $ORACLE_HOME/bin $ . 2. Following are code examples illustrating how to use this privilege: -. and so on.grant the privilege GRANT SYSASM TO firas.log. -. Members of the OSASM group can connect as SYSASM using operating system authentication and have full access to ASM. 3.Summary Sheets . Edit any directory-based parameters (such as diag and dump) in the ASM initialization file as required. then click on Finish button.. click the Upgrade Automatic Storage Management Instance radio button. -.check the granted privilege SELECT * FROM V$PWFILE_USERS.Automatic Storage Management (ASM) SYSASM Privilege and OSASM Group This feature introduces a new SYSASM privilege that is specifically intended for performing ASM administration tasks. In the summary page. Be aware that users with SYSOPER privilege have some ASM privileges. Following table shows available and restricted ASM privilege for users with SYSOPER privilege: Avaiable ASM Privilege Restricted ASM Privilege STARTUP AND SHUTDOWN ALTER DISKGROUP MOUNT ALTER DISKGROUP DISMOUNT ALTER DISKGROUP ONLINE DISK ALTER DISKGROUP OFFLINE DISK ALTER DISKGROUP REBALANCE ALTER DISKGROUP CHECK CREATE DISKGROUP / DISK DROP DISKGROUPS / DISKS ALTER DISKGROUP / DISK RESIZE OSASM is a new operating system group that is used exclusively for ASM. To do that. Change the directory to the new $ORACLE_HOME/bin and launch DBUA. Page 94 Oracle 11g New Features for Administrators ./dbua 2. Update the /etc/oratab or /var/opt/oracle/oratab file with the new ASM ORACLE_HOME location.

cd $ORACLE_HOME/bin # . Page 95 Oracle 11g New Features for Administrators . To get a listing of all the obsolete initialization parameters.. The compatible. Once the CSS configuration is complete. you need to change your ORACLE_HOME to the new Oracle version 11. you should reconfigure the Oracle CSS using the new ORACLE_HOME. -.0/asm -p init+ASM1. .asm attribute. you can modify the new ASM home within the OCR using the srvctl utility as follows: srvctl modify asm -n racnode1 -i +ASM1 -o /apps/oracle/product/11.1 ORACLE_HOME and start the ASM instance. Grant the SYSASM role to the SYS GRANT SYSASM to sys. select NAME. If you are upgrading a non-RAC ASM instance. VALUE from V$ASM_ATTRIBUTE where GROUP_NUMBER=1.rdbms attribute. if the database tries to access an ASM instance started in restricted mode. ALTER DISKGROUP data SET ATTRIBUTE 'compatible. ASM Restricted Mode 105B In Oracle 11g. Diskgroup Attributes 106B Oracle Database 11g introduces a new concept called ASM attributes at the diskgroup level.in the diskgroup level SQL>ALTER DISKGROUP DATA MOUNT RESTRICTED.check status of diskgroups SQL>SELECT NAME.5. All of the diskgroup attributes can be queried from the V$ASM_ATTRIBUTE view. you can address them now. 'compatible. refer to the ASM alert log file. You can do this by executing the localconfig command from the new home. Also. Consider the following examples: CREATE DISKGROUP data disk '/dev/raw/raw1'.. individual diskgroup can be set in restricted mode./localconfig reset 6. If you have obsolete initialization parameters. The stripping attribute for a specific template.1. 8. ORA-15236 error will be returned.asm' = '11. you can start the ASM instance in restricted mode. -. disk_repair_time in units of minute (M) or hour (H) and is set by the ALTER DISKGROUP command The redundancy attribute for a specific template. The compatible.asm' = '11.STATE FROM V$ASM_DISKGROUP. databases will not be permitted to access the ASM instance.1. The attributes for the diskgroup can be established at create diskgroup time or can be modified using the ALTER DISKGROUP command later. attribute 'au_size' = '16M'.1'.0'.ora 7. Following are the attributes you can set: • • • • • • Allocation unit (AU) sizes.0.in the ASM instance level SQL>STARTUP RESTRICT. If you are upgrading a ASM instance in a RAC environments.Summary Sheets . When in restricted mode.0. -.

Summary Sheets . Its default value is 10. 16. Following are some queries to obtain information about the compatibility settings: -. -.if you get an offline disk because of a transient failure.1. You can check the AU size through the following query: select NAME. Compatibility Settings Compatibility in ASM is controlled in three ways.the disk(s) offline ALTER DISKGROUP dg1 OFFLINE DISK d3_0001. 8.specify the duration of the disk_repair_time (default is 3. ASM Fast Mirror Resync Any problems that make a failure group temporarily unavailable are considered transient failures that can be recovered by the ASM fast mirror resync feature. controller failures. 10. -.6 hour) ALTER DISKGROUP dg1 SET ATTRIBUTE 'disk_repair_time' = '5H'.1'. HEADER_STATUS.minutes -.verify the attribute settings select NAME.Variable AU Sizes The default size of Allocation Unit (AU) is 1 MB which is sufficient for most regular databases. DATABASE_COMPATIBILITY DB_COMP from V$ASM_DISKGROUP. STATUS.COMPATIBLE_VERSION from V$ASM_CLIENT. or disk power supply interruptions. Disk path malfunctions. MOUNT_STATUS. With Oracle 11g. can cause transient failures. 4. if you want to reset the elapsed time. 2.1. This is a diskgroup-level compatibility and is specified by setting the COMPATIBLE. or 11. ALTER DISKGROUP dg1 SET ATTRIBUTE 'compatible. VALUE from V$ASM_ATTRIBUTE. host bus adapter failures. BLOCK_SIZE. -. MODE_STATUS. Page 96 Oracle 11g New Features for Administrators .disk_repair_time attribute ALTER DISKGROUP dg1 OFFLINE DISK d3_0001 DROP AFTER 50m.1'. However. -.while the fix is in progress.in hours ALTER DISKGROUP dg1 SET ATTRIBUTE 'disk_repair_time' = '40M'.asm' = '11.Compatibility of the database clients that use the ASM select DB_NAME.2.you can also make a disk offline with a repair time different from its -. ALLOCATION_UNIT_SIZE AU_SIZE. AU size can be specified at diskgroup creation time to 1. 32. -. as shown below: COMPATIBLE initialization parameter The compatible initialization parameter can be set for either ASM or the database instance.diskgroup compatibility must be set to 11.ASM attribute. STATE.1 ALTER DISKGROUP dg1 SET ATTRIBUTE 'compatible.remaining time left in SECONDS before ASM drops an offline disk select NAME. you will have enormous number of AUs.diskgroup compatibility setting select NAME. -.disks in a failure group (f2) can also be taken offline ALTER DISKGROUP dg1 OFFLINE DISKS IN FAILGROUP f2 DROP AFTER 5m. It determines the minimum software version for an ASM instance that uses the disk group.SOFTWARE_VERSION. ALLOCATION_UNIT_SIZE from V$ASM_DISKGROUP. The extents are resynced when the disk is brought back online. such as cable failures. -.RDBMS attribute. -. Setting the initialization parameter to a lesser value than the software release will exclude availability of the new features introduced in the new release. Following are the steps to enable and handle this feature: -. you can see the -. or 64MB in size. STATE. REPAIR_TIMER/60 from V$ASM_DISK WHERE GROUP_NUMBER=1. This is a diskgroup-level compatibility and is specified by setting the COMPATIBLE. just take -. you cannot later reverse it to a lower value. ALTER DISKGROUP dg1 OFFLINE DISKS IN FAILGROUP f2.rdbms'='11. RDBMS Compatibility ASM Compatibility If you assign any of the compatibility setting to a higher value. ASM fast resync keeps track of pending changes to extents on an OFFLINE disk during an outage. COMPATIBILITY ASM_COMP. It takes one of the following values: 10.1. This attribute determines the minimum COMPATIBLE database initialization parameter setting for any database instance that uses the disk group. when you have databases with TB sizes.

Note: ALTER DISKGROUP DROP DISK will not work ALTER DISKGROUP dg1 OFFLINE DISK D3_0001 DROP AFTER 0m.if the disk needs to be dropped immediately and before the repair time has expired -.-. -. you can validate the internal consistency of ASM diskgroup metadata using the ALTER DISKGROUP .Summary Sheets . CHECK command.. you can bring them online ALTER DISKGROUP dg1 ONLINE ALL. -.check specific diskgroup with automatic repair SQL>ALTER DISKGROUP data CHECK. Checking Diskgroup 107B Starting from Oracle Database 11g. ALTER DISKGROUP dg1 ONLINE DISK d3_0001.. Page 97 Oracle 11g New Features for Administrators .disable automatic repair SQL>ALTER DISKGROUP data CHECK NOREPAIR. Summary of errors is logged in the ASM alert log file.after the disk(s) are fixed. -.

if the blocks on the original location cannot be properly read. remap <disk group name> <disk name> <block range> > remap DISK_GRP1 DATA_0001 5000-5999 Backing up and Restoring Diskgroup Metadata The md_backup command captures information about ASM disks. it creates a file named as ambr_backup_intermediate_file which contains the metadata information of all the mounted diskgroups. Following is the basic syntax of the command: md_backup [-b <backup_file_path> ] [-g diskgroup_name [-g diskgroup_name …]] Following is an example of using the command: md_backup –b /tmp/asm_backup.dmp +dg1 >cp vdb. Internally. diskgroup and failure group configurations.port_number]. and template and alias directory structures. and stores them in a user-designated backup text file.ctf1 /tmp # the target ASM instance must be registered with the LISTENER >cp +DATA/DBA11g/DATAFILE/DOCS_D1. If you issue the md_backup command without any option.. >lsdg dgroup2 lists the disks that are visible to ASM by scanning the disk headers of the disks seen by the value of the ASM_DISKSTRING >lsdsk -k -d DATA *_001 >lsdsk -s -d DATA *_001 >lsdsk -t -d DATA *_001 >lsdsk -c -t -d DATA *_001 >lsdsk -g -t -d DATA *_001 cp [-ifr] [connect_string:]src_fname [connect_string:]tgt_fname cp [-ifr] [connect_string:]src_fnameN... >cp +dg1/vdb. You can set its options to build a script file that contains the SQL statements required to rebuild the ASM components from the backup file. src_fnameN+1 . you should remove it before issuing the command.289.mdb -g dg1 –g dg2 If the backup file already exists. [connect_string:]tgt_directory The connect_string is in the form of: user_name@host_name[.Summary Sheets .<diskgroup_name>..+ASM:+DATA/DBA11g1/datafile/xxx Repairs a range of physical blocks on disk (only blocks exhibiting read disk I/O errors are repaired) excluding those with corrupted contents. Following are summary of some of them: Command Syntax Description and Examples lsct [-gH] [group] lsdg [-gcH] [group] lsdsk [-ksptagcHI] [-d diskg_roup_name] [pattern] Lists information about current ASM clients.SID -i interactive -f force overwrite (aliases cannot be overwritten) -r recursive remap Enables you to copy files between ASM disk groups on local instances to and from remote instances.asmcmd Utility Commands Oracle 11g introduces new commands in the asmcmd utility and it also provides backward compatibility with Oracle Database 10g ASM instances. The md_restore command reads the backup file and restores a disk group. >lsct dgroup1 lists all diskgroups and their attributes.ctf1 /backups/vdb. it reads the blocks from a good copy of an ASM mirror and rewrites them to an alternate location on disk.'] -t type of restore.. full tag specifies that all the diskgroups should be re-created using the same configuration from the Page 98 Oracle 11g New Features for Administrators .ctf1 >cp /home/oracle/encrypted.'] [-o '<old_diskgroup_name>:<new_diskgroup_name>.. Following is the syntax of the command and description of its switches: md_restore -b <backup_file> [-li] [-t (full)|nodg|newdg] [-f <sql_script_file>] [-g '<diskgroup_name>.631914611 sys@rac1...

you can manually repair blocks that have read disk I/O errors using the remap command. ASM will automatically read a mirrored block and write a relocated copy to produce successful copy. md_restore –b /tmp/backupfile –t nodg –g dg1 –i # To create a different diskgroup name: md_restore –b /tmp/backupfile –t newdg -o "DGNAME=dg1:dg3" –i # To apply the override options as specified in the dg_over. you can restore the RMAN backup to the diskgroup. it considers that the block has IO error. Discussing those features is beyond the scope of this document.Summary Sheets . Following is the syntax of the command: remap <diskgroup name> <disk name> <block range> Fast Rebalance 109B In Oracle 11g. databases are not allowed to access the datafiles in it. fast rebalance eliminates ASM messaging among the ASM instances in a RAC configuration when a disk is added to a disk group.MDB backup file.txt –i Note that md_backup is a backup of the metadata of the ASM instance. along with all the directories. In such a condition. The data is being backed up by RMAN. disk name. For details about them. When the diskgroup is in restricted mode. This feature is enabled by using the STARTUP RESTRICT or ALTER DISKGROUP … MOUNT RESTRICT commands. override option is used only with the newdg option to remap the diskgroup name. -i -l Following are examples of using the command: # To perform a restore of the dg1 diskgroup from the MDB backup file. the command aborts when it encounters an error. By default. newdg create disk group with a different name and restore metadata. nodg restore metadata only and skip the diskgroup creation. you can refer to the new documentation "Oracle Database Storage Administrator's Guide 11g". ignore errors. Oracle 11g provides the FORCE INCLUDING CONTENTS option to drop the diskgroup even if it is not mounted. -o is required.txt file and restore # from the backup file: md_restore –b /tmp/backupfile –t newdg –of /tmp/dg_override. The FORCE option with Drop Diskgroup Command 10B If a disk is destroyed beyond repair. Bad Block Recovery If ASM cannot read a physical block from a disk. Following is an example: SQL>DROP DISKGROUP dg7 FORCE INCLUDING CONTENTS. you want to drop it. In this case. This tag is used to allow the user to change diskgroup name. But because the disk is practically damaged. and failure groups. you cannot mount it and thus you cannot issue the DROP DISKGROUP command against it. use this: md_restore –b /tmp/backupfile –t full –g dg1 -i # To just restore the metadata for the dg1 diskgroup (the diskgroup already exists). However. -f -o write SQL commands to <sql_script_file> instead of executing them. After the diskgroup is created. paths. Miscellaneous ASM New Features 1B Oracle 11g introduces some other new features in its ASM related to the clustered ASM architecture. Following is a brief description about those features: Page 99 Oracle 11g New Features for Administrators . log all messages to a log file.

Using ASM versus Direct NFS is still controversial subject.Preferred Read Failure Groups You can configure ASM to read from a secondary extent if that extent is closer to the node instead of ASM reading from the primary copy which might be farther from the node. Oracle will utilize the operating system’s NFS client as specified in /etc/fstab and post an error message in the alert log. You can implement Network Interface Card (NIC) bonding without the need of the expensive advanced Ethernet switches. This configuration is described as Preferred Read Failure Group. Note In Oracle 11g ASM. If Oracle’s Direct NFS is not able to open the NFS server. This feature has the following advantages: • • You can achieve better IO performance. Rolling upgrade means that all of the features of a clustered ASM environment function when one or more of the nodes in the cluster use different software versions.Summary Sheets . more efficient system resource utilization. Using preferred read failure groups is most useful in extended clusters. It is not either necessary to have homogeneous network cards. thus providing greater uptime. Oracle Direct NFS Oracle Database 11g kernel has built-in support for the network file system (NFS) without relying on OS support for NFS. and lower operating costs in NAS environments. ASM Rolling Upgrades ASM rolling upgrades enable you to independently upgrade or patch clustered ASM nodes without affecting database availability. you can create an ASM disk group using NFS files. Page 100 Oracle 11g New Features for Administrators .

as in the following example: DECLARE x NUMBER := 0.. END LOOP.PUT_LINE (' After loop: x = ' || TO_CHAR(x)).PUT_LINE ('Inside loop. the current iteration of the loop completes and control passes to the next iteration.nextval.147. FROM DUAL statement in PL/SQL when you want to assign a NEXTVAL of a sequence to a variable. the current iteration of the loop completes immediately and control passes to the next iteration of the loop. CONTINUE WHEN x < 3. after CONTINUE: x = ' || TO_CHAR(x)). END. error returned SIMPLE_INTEGER accepts NULL higher performance in native compiled PL/SQL when it takes values out of its range.After CONTINUE statement. EXIT WHEN x = 5. x := x + 1.483.147. Following is an example: DECLARE new_Val NUMBER. . the condition in the WHEN clause is evaluated.648 to 2. you can exit the current iteration of a loop using the new statements: CONTINUE or CONTINUE-WHEN. BEGIN new_Val := my_sequence. It has the same range as of PLS_INTEGER (–2. DBMS_OUTPUT. If the condition is true.. END IF.PUT_LINE ('Inside loop.Summary Sheets .483. the value wrap from smallest to largest and from largest to smallest Page 101 Oracle 11g New Features for Administrators .PUT_LINE ('Inside loop: x = ' || TO_CHAR(x)). END LOOP. IF x < 3 THEN CONTINUE. Sequences Without Selecting from Dual It is no longer necessary to execute a SELECT . END. DBMS_OUTPUT. EXIT WHEN x = 5. When a CONTINUE statement is encountered.647) but with the following differences: PLS_INTEGER cannot be null less performance in native compiled PL/SQL when it takes values out of its range. The previous example can be altered as in the following code: DECLARE x NUMBER := 0. BEGIN LOOP -. x := x + 1.PUT_LINE (' After loop: x = ' || TO_CHAR(x)). DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR(x)). control resumes here DBMS_OUTPUT.. control resumes here DBMS_OUTPUT. SIMPLE_INTEGER SIMPLE_INTEGER is a new data type introduced in Oracle 11g PL/SQL. DBMS_OUTPUT.After CONTINUE statement. BEGIN LOOP -. END. after CONTINUE: x = ' || TO_CHAR(x)). When a CONTINUE-WHEN statement is encountered.PL/SQL New Features PL/SQL New Features CONTINUE Statement In Oracle 11g PL/SQL.

It takes the following two arguments: identifier Mode The name of the subprogram. -. DECLARE PROCEDURE PROC1(p_idata IN VARCHAR2) IS BEGIN ..put_line(dbms_utility.Named and Mixed Notation in PL/SQL Subprogram Invocations The use of NAME=>value is now supported in PL/SQL function calls that are contained in expressions in SQL statements.. Page 102 Oracle 11g New Features for Administrators .P_DEPT_ID=> DEPARTMENT_ID) FROM EMPLOYEES. The pragma INLINE compiler directive specifies that a subprogram call is. The optimizer may find a better optimization that does not need inlining. END. For NO. It will inline subprogram calls the developer has flagged with the pragma INLINE directive. If YES and PLSQL_OPTIMIZE_LEVEL=2. the subprogram will be inlined. the PL/SQL compiler will automatically inline subprograms where performance gains are predicted.inlining is NOT used pragma INLINE(PROC1. END. DECLARE PROCEDURE PROC1(p_idata IN VARCHAR2) IS BEGIN .inlining is used pragma INLINE(PROC1. dbms_output.GET_INFO(EMPLOYEE_ID. or is not..example 2 ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=3.GET_INFO(EMPLOYEE_ID..format_call_stack()). PROC1('test'). SELECT EMP_PKG.GET_INFO(P_EMP_ID=>EMPLOYEE_ID. It must appear immediately before the subprogram call. END. Subprogram Inlining Subprogram inlining replaces a subprogram call (to a subprogram in the same program unit) with a copy of the called subprogram. PROC1('test'). In addition to the level 2 optimizations. END. dbms_output.example 1 ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=2. Following are illustrated examples: -. If YES and PLSQL_OPTIMIZE_LEVEL=3. So for example. to be inlined. -. all of the following SELECT statements are now valid: SELECT EMP_PKG..'YES'). as well as place a high priority on inlining programmer flagged calls.example 3 ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=3. The PLSQL_OPTIMIZE_LEVEL initialization parameter specifies the level of optimization used to compile the PL/SQL library unit and is used to switch on and off subprogram inlining in a PL/SQL code.format_call_stack()). BEGIN -. This will lead to better performance in almost all the cases. The parameter accepts the following values: 1 2 3 No PL/SQL compilation optimizations are done. BEGIN -. no inlining will occur for the subprogram.P_DEPT_ID=>DEPARTMENT_ID) FROM EMPLOYEES.DEPARTMENT_ID) FROM EMPLOYEES. Either YES or NO.inlining is NOT used PROC1('test'). PL/SQL will rearrange code for performance but will not automatically inline subprograms. -.. the optimizer will place a high priority on inlining the subprogram.put_line(dbms_utility.Summary Sheets .'YES'). SELECT EMP_PKG.

.. -.. The triggers you specify with FOLLOWS clause must already exist. before each row. Page 103 Oracle 11g New Features for Administrators . Following is an example of using this new clause. you can control the order on which the triggers on a table are fired using the new clause FOLLOWS. CREATE TRIGGER EMP_CHECK_SAL BEFORE INSERT ON EMPLOYEES DISABLED WHEN .. BEFORE EACH ROW IS BEGIN .. The compound trigger makes it easier if you want triggers of various timing points to share common data..'YES').format_call_stack()). AFTER STATEMENT IS BEGIN . Creating Triggers As ENABLED or DISABLED Two new keywords. refer to the documentation "Oracle Database PL/SQL Language Reference 11g". U U Ordering of Triggers In Oracle 11g. be defined on the same table as the trigger being created. and have been successfully compiled.inlining may occur. END AFTER STATEMENT. CREATE TRIGGER Trigger3 BEFORE INSERT ON EMPLOYEES FOLLOWS trigger2. Compound Triggers Type Oracle 11g introduces a new type of triggers called compound triggers... BEFORE STATEMENT IS BEGIN .Summary Sheets ... BEGIN -. and all of those sections share the same set of variables declared in the trigger’s common declaration section. AFTER EACH ROW IS BEGIN . END. have been added to the trigger creation statement.put_line(dbms_utility. A compound trigger implements all of the timing-point logic (before statement.trigger1 WHEN .inlining is used pragma INLINE(PROC1. They need not be enabled. END BEFORE EACH ROW.. END BEFORE STATEMENT. PROC1('test'). after statement) within its body.. The following example illustrates the general syntax of creating a compound trigger: CREATE TRIGGER trigger_name FOR UPDATE OF salary ON employees COMPOUND TRIGGER -. ENABLED and DISABLED.Declaration Section -.DECLARE PROCEDURE PROC1(p_idata IN VARCHAR2) IS BEGIN . They appear immediately before the optional WHEN clause and after the optional FOLLOWS clause.Variables declared here have firing-statement duration. dbms_output. threshold CONSTANT SIMPLE_INTEGER := 200. END. if performance gain is predicted PROC1('test'). after each row... For further details.. PL/SQL Function Result Cache Fundamentals of using this new feature are described in the section "PL/SQL Function Result Cache".

The target here is to have some performance gain. idx := 0. salaries.count(). and no other timing-point section.PUT_LINE('Flushed ' || n || ' rows'). END flush_array.Declaration Section: -. END AFTER EACH ROW. It cannot transfer control to another section. Only the BEFORE EACH ROW section can change the value of :NEW. Any section can include the functions Inserting.AFTER EACH ROW Section: AFTER EACH ROW IS BEGIN idx := idx + 1.salary := :NEW. change_date DATE NOT NULL. and Applying.employee_id. -.change_date := SYSDATE(). CONSTRAINT fk_employee_salaries FOREIGN KEY (employee_id) REFERENCES employees (employee_id) ON DELETE CASCADE) / CREATE OR REPLACE TRIGGER maintain_employee_salaries FOR UPDATE OF salary ON employees COMPOUND TRIGGER -. IF idx >= threshhold THEN flush_array().salary. salaries(idx).Choose small threshhold value to show how example works: threshhold CONSTANT SIMPLE_INTEGER := 7.delete(). TYPE salaries_t IS TABLE OF employee_salaries%ROWTYPE INDEX BY SIMPLE_INTEGER. PROCEDURE flush_array IS n CONSTANT SIMPLE_INTEGER := salaries. Updating. DBMS_OUTPUT. consider the following: • • • A compound trigger defined on a view has an INSTEAD OF EACH ROW timing-point section. END trigger_name. salaries(idx).AFTER STATEMENT Section: AFTER STATEMENT IS BEGIN Page 104 Oracle 11g New Features for Administrators . Following are some of the restrictions in the compound triggers: • • • A compound trigger must be defined on either a table or a view. BEGIN FORALL j IN 1.n INSERT INTO employee_salaries VALUES salaries(j).employee_id := :NEW. When using compound triggers. Deleting. Two common uses of the compound triggers are: • • To accumulate rows inserted into a table by a statement to bulk-insert them into another table. salaries(idx). To avoid the mutating-table error (ORA-04091).Compound Trigger Records Changes to One Table in Another Table CREATE TABLE employee_salaries ( employee_id NUMBER NOT NULL.Summary Sheets . change_date). Examples of implementing those two targets are copied from Oracle documentation and pasted in the following examples: -. END IF. idx SIMPLE_INTEGER := 0. CONSTRAINT pk_employee_salaries PRIMARY KEY (employee_id. salary NUMBER(8. Timing-point sections must appear in the order shown in the example above.END AFTER EACH ROW. salaries salaries_t.. -.2) NOT NULL. An exception that occurs in one section must be handled in that section.

END AFTER STATEMENT. p_store_id). TO_REFCURSOR. END check_Employee_Salary_Raise. FOR j IN 1. TYPE type_refcur IS REF CURSOR. END LOOP.. AFTER EACH ROW IS BEGIN IF :NEW.Salary > Ten_Percent*Department_Avg_Salaries(:NEW. END AFTER EACH ROW.Department_ID.Department_ID. CREATE OR REPLACE TRIGGER check_Employee_Salary_Raise FOR UPDATE OF Salary ON Employees COMPOUND TRIGGER Ten_Percent CONSTANT NUMBER := 0. 'Raise too big'). c_ref_trans_cur := DBMS_SQL. TYPE Department_Salaries_t IS TABLE OF Employees. END LOOP.TO_REFCURSOR(c_trans_cur). trans_amt.Salary%TYPE. FETCH c_ref_trans_cur BULK COLLECT into trans_id. Department_IDs Department_IDs_t.COUNT LOOP DBMS_OUTPUT.Summary Sheets .. NVL(e. begin c_trans_cur := Dbms_Sql.Department_IDs. trans_amt from trans where store_id = :store_id'. Avg_Salaries Salaries_t.PARSE(c_trans_cur.Salary).EXECUTE(c_trans_cur). CLOSE c_ref_trans_cur. l_stmt. trans_id NUM_TAB.Department_ID%TYPE. trans_amt NUM_TAB. END maintain_employee_salaries.1. -1) BULK COLLECT INTO Avg_Salaries. END. FOR ctr in 1 . the supplied package DBMS_SQL has a new function. Department_Avg_Salaries Department_Salaries_t. DBMS_SQL. END IF. The following example implements a business rule that states that an employee's salary increase must not exceed 10% of the average salary for the employee's department. Department_IDs FROM Employees e GROUP BY e. 'store_id'. trans_id.COUNT() LOOP Department_Avg_Salaries(Department_IDs(j)) := Avg_Salaries(j). TYPE Department_IDs_t IS TABLE OF Employees. Converting between Dynamic Cursor and REF CURSOR In Oracle Database 11g.native).flush_array().Salary . dbms_sql. ret := DBMS_SQL. Here is an example of such a conversion: CREATE OR REPLACE PROCEDURE list_trans_by_store ( p_store_id NUMBER ) IS TYPE num_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER. c_ref_trans_cur TYPE_REFCUR. Page 105 Oracle 11g New Features for Administrators . END BEFORE STATEMENT. TYPE Salaries_t IS TABLE OF Employees. l_stmt := 'select trans_id. DBMS_SQL. l_stmt CLOB. ret INTEGER.PUT_LINE(trans_id(ctr) || ' ' || trans_amt(ctr)).Salary%TYPE INDEX BY VARCHAR2(80). which converts the DBMS_SQL dynamic cursor to a ref cursor.:Old. c_trans_cur NUMBER. BEFORE STATEMENT IS BEGIN SELECT AVG(e.Department_ID) THEN Raise_Application_Error(-20000.Open_Cursor.BIND_VARIABLE(c_trans_cur.

if you want to convert a Native Dynamic SQL to REF CURSOR. for which DBMS_SQL is more appropriate.Suppose you want to write a generic procedure where you do not know the column list in the select clause at compile time. you start with native dynamic sql with a ref cursor and later change it to DBMS_SQL to describe and fetch the columns from the cursor. Now.Summary Sheets . the life of the ref cursor is over. Page 106 Oracle 11g New Features for Administrators . suppose you do not know the bind variable as well. Similarly.TO_CURSOR_NUMBER (c_ref_cur). After this call. This is where the native dynamic SQL comes in handy. TO_CURSOR_NUMBER: cur_handle := DBMS_SQL. you can define a ref cursor for that. Suppose you know the binds at compile time but not the select list. How can you accomplish this complex requirement with minimal code? Simple: Just start with DBMS_SQL for the bind part and then convert it to ref cursor later for the other part. you will need to call another function. The ref cursor specified by the variable c_ref_cur must be opened prior to this call. it can be manipulated only as a DBMS_SQL cursor.

Using the parameter will be discussed in the next sub-section. This parameter specifies whether or not to treat LOB files as SecureFiles. cv_content BLOB ) TABLESPACE tools LOB (cv_content) STORE AS SECUREFILE ( KEEP_DUPLICATES -. encrypt.. space is significantly saved. . DEDUPLICATE option makes Oracle stores a single copy of a file when storing many identical files. All SecureFile-specific storage options and features (for example.. The BasicFile LOB defaults will be used for storage options not specified. Following is an example of creating a table with a SecureFile LOB column: CREATE TABLE employees ( employee_id NUMBER NOT NULL PRIMARY KEY.SETOPTIONS. and compression settings of SecureFile LOBs can be altered using DBMS_LOB. however. Encryption for SecureFiles must use SALT. The primary focus of the SecureFiles feature is to do the following: • • • Improve performance Reduce space consumption Enhance security Creating SecureFile LOB Columns Use the clause STORE AS SECUREFILE or STORE AS BASICFILE to create a SecureFile or BasicFile columns in a table. Thus. The previous BLOB data types are referred to as BasicFiles. controlled by the initialization parameter DB_SECUREFILE. and AES256. AES128. This option can be altered for an existing SecureFile: ALTER TABLE employees MODIFY LOB(cv_content) (DEDUPLICATE). Note Beside ALTER TABLE command. deduplication. Be aware that the command shown in the example above will make Oracle read the values in the column and remove duplicates.or DEDUPLICATE TABLESPACE tools ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGGING). compress. 3DES168. The DB_SECUREFILE Initialization Parameter Creating SecureFiles in the database is controlled by the new dynamic initialization parameter DB_SECUREFILE. (the default) LOBs are allowed to be created as SecureFiles. Remember that compression and decompression will take effect immediately when you enable or disable compression. Compression can be disabled using the NOCOPRESS clause. LOB (cv_content) STORE AS SECUREFILE (COMPRESS HIGH) -. Following are its acceptable values: NEVER Any LOBs that are specified as SecureFiles are created as BasicFile LOBs. Encryption can be disabled using the following command: ALTER TABLE employees MODIFY (blob_content DECRYPT) Compression in SecureFiles can be enabled by using the COMPRESS clause in the CREATE TABLE or ALTER TABLE commands as in the following example: . if you store an already compressed file into it.Summary Sheets .or medium Note that Oracle will not be able to significantly reduce the size of a SecureFile. Available encryption algorithms are: AES192 (the default). This is. deduplicate) will cause an exception. Following is an example: ALTER TABLE employees MODIFY (cv_content ENCRYPT USING 'AES192'). PERMITTED Page 107 Oracle 11g New Features for Administrators . You can enable encryption for SecureFiles LOBs using the TDE.. encryption. name VARCHAR2(255) NOT NULL.Data Warehousing SecureFiles Oracle Database 11g completely reengineers LOB storage to what they call SecureFiles. You can query the DBA_ENCRYPTED_COLUMNS view to confirm that LOB columns are encrypted.

possible values are: TABLE. end. 'aaaaa'). Following is an example of modifying this parameter: ALTER SYSTEM SET DB_SECUREFILE='ALWAYS'.. CLUSTER. and freed space that has retention unexpired. INDEX SUBPARTITION.. IN VARCHAR2 DEFAULT NULL). OUT NUMBER. begin INSERT INTO t(id. Following are the SQL operations that are not supported on LOB columns: SELECT DISTINCT clobCol from... LOB SUBPARTITION OUT NUMBER. UPDATE... INDEX PARTITION.SPACE_USAGE can be used to obtain the space usage information of data blocks in a segment. clob_col.This will get the LOB column if it is up to 100 bytes.. SELECT.. 'FFFF').1 or higher. OUT NUMBER. Following are examples: -.. you can use the same SQL semantics on a LOB column (BasicFile or SecureFile) that you would use on a VARCHAR2 column. GROUP BY clobCol SELECT clobCol1 from tab1 UNION SELECT clobCol2 from tab2. The SecureFile defaults will be used for all storage options not specified. INSERT INTO t VALUES(1..SPACE_USAGE( segment_owner segment_name segment_type IN VARCHAR2. Space used by SecureFile The procedure DBMS_SPACE. and SELECT Operations CREATE TABLE t (id number. -. segment_size_blocks OUT NUMBER. SecureFile LOB must be created in a Automatic Segment Space Managed (ASSM) tablespace. then LOBs are not treated as SecureFiles.clobCol CREATE.Summary Sheets . It displays the space actively used by the LOB column. -. clob_col CLOB. WHERE tab1.LOBs with INSERT. IN VARCHAR2. IN VARCHAR2. ORDER BY clobCol SELECT. LOB PARTITION. OUT NUMBER. blob_col BLOB). There is a form of this procedure that specifically returns information about SECUREFILE LOB space usage. freed space that has retention expired. declare c_buffer VARCHAR2(100). TABLE SUBPARTITION INDEX. -. OUT NUMBER.ALWAYS All LOBs created in the system are created as SecureFile LOBs. IGNORE If the COMPATIBLE initialization parameter is not set to 11. OUT NUMBER.blob is passed a hexadecimal number UPDATE t SET clob_col= 'ROW2' WHERE id=2. ON tab(clobCol). Any BasicFile LOB storage options are ignored. TABLE PARTITION.. SELECT. segment_size_bytes used_blocks used_bytes expired_blocks expired_bytes unexpired_blocks unexpired_bytes partition_name Accessing a LOB Using SQL and PL/SQL 14B In most cases. (exception otherwise) SELECT clob_col INTO c_buffer FROM t WHERE id=2. Accessing LOB columns in Oracle 11g PL/SQL is the same as in the previous version.LOBs in Assignments and Parameter Passing Page 108 Oracle 11g New Features for Administrators . Also. Following is the syntax of that form of the procedure: DBMS_SPACE. The SECUREFILE keyword and all SecureFile options are ignored. 'row2'. OUT NUMBER.clobCol = tab2.'row1'. blob_col) VALUES(2. LOB..

declare var_buf VARCHAR2(100).. GRANT DROP ANY TABLE TO pm. o Can be done in parallel. GRANT EXECUTE ON DBMS_REDEFINITION TO pm.Privileges required to perform cloning of dependent objects. c_name VARCHAR(30) DEFAULT NULL. GRANT ALTER ANY TABLE TO pm. GRANT CREATE ANY TABLE TO pm.CLOB to VARCHAR2 conversion end. Online Redefinition Disadvantages o Additional storage equal to the entire table or partition and all LOB segments must be available. declare col_mapping VARCHAR2(1000). Online Redefinition Advantages: o No need to take the table or partition offline. GRANT CREATE ANY INDEX TO pm. CONNECT pm CREATE TABLE cust(c_id NUMBER PRIMARY KEY.Summary Sheets . blob_buf FROM t WHERE id=1. It can be done at the table or partition level. c_lob CLOB) LOB(c) STORE AS SECUREFILE (. -.. GRANT LOCK ANY TABLE TO pm. clob_buf CLOB. o Global indexes need to be rebuilt. GRANT SELECT ANY TABLE TO pm. Following is an example of how to migrate a table using Online Redefinition: -. end. -. GRANT CREATE ANY TRIGGER TO pm.Grant privileges required for online redefinition. c_zip NUMBER. -. begin SELECT clob_col. CREATE OR REPLACE PROCEDURE BAR (b IN OUT VARCHAR2) IS begin -. c_lob CLOB). Online Redefinition 15B Online redefinition is the only recommended method for migration of BasicFile LOBs to SecureFiles. INSERT INTO cust VALUES(1.Any procedure body a := 'abc'. begin Page 109 Oracle 11g New Features for Administrators .coversion from VARCHAR2 to CLOB clob_buf := var_buf. var_buf := clob_buf. -.).Creating Interim Table -. end. c_name VARCHAR(30) DEFAULT NULL. 'hhh'. 'ttt'). CREATE OR REPLACE PROCEDURE FOO ( a IN OUT CLOB) IS begin -. blob_col INTO clob_buf. 94065. blob_buf BLOB. c_zip NUMBER.Any procedure body b := 'xyz'.no need to specify constraints because they are copied over from the original table CREATE TABLE cust_int(c_id NUMBER NOT NULL.

col_mapping). 'cust_int'. exec DBMS_REDEFINITION.START_REDEF_TABLE('pm'. Partition Change Tracking (PCT) 16B A group of data dictionary views in Oracle 11g are improved to provide information about refreshing the materialized view partition. 94065.FINISH_REDEF_TABLE('pm'. DBMS_OUTPUT. 2. '||'c_lob c_lob'. Following are the related modifications: • • • In the DBA_MVIEWS view. QUARTER_AMT FROM PRODUCT_ROW ) PIVOT (MAX(QUARTER_AMT) FOR QUARTER_ID IN (1. 'cust_int'). 3. '||'c_name c_name. They provides freshness information for each PCT partition and subpartition. all triggers are invalidated and are automatically revalidated with the next DML execution on the table.-. 'cust'. NUM_FRESH_PCT_REGIONS. This is only possible. you cannot dynamically provide the possible values of the columns. NUM_STALE_PCT_PARTITIONS.---------Sharpie 130 215 190 300 Pencils 2100 918 3280 1315 Note: Unfortunately. NUM_STALE_PCT_REGIONS. QUARTER_ID.Drop the interim table DROP TABLE cust_int. 'hhh'. using the syntax above.TRUE. you cannot use a sub-query in the list of values provided for the QUARTER_ID in the pivot expression. TRUE. Therefore. PRODUCT_DESC 1 2 3 4 -------------------. 1. if you want to generate the report in XML format.to prove that the primary key on the c_id column is preserved after migration. This operator enables you to easily generate crosstab report using SQL language. INSERT INTO cust VALUES(1. DBMS_REDEFINITION. declare error_count pls_integer := 0. -. Generating SQL Crosstab Report using PIVOT Operator 17B Oracle 11g SQL introduces an excellent new SELECT statement operator: PIVOT.PUT_LINE('errors := ' || TO_CHAR(error_count)).map all the columns in the interim table to the original table col_mapping :='c_id c_id . '||'c_zip c_zip . 'cust'.---------. -.FALSE.---------. 4)). end. end. NUM_FRESH_PCT_PARTITIONS. Page 110 Oracle 11g New Features for Administrators . 'ttt').COPY_TABLE_DEPENDENTS('pm'. SELECT * FROM cust. The view DBA_MVIEW_DETAIL_RELATIONS was added with the following columns: DETAILOBJ_PCT.Summary Sheets .TRUE. New two views are introduced in Oracle 11g named as ALL_MVIEW_DETAIL_PARTITION and ALL_MVIEW_DETAIL_SUBPARTITION. 'cust'. DESC cust. begin DBMS_REDEFINITION. When online redefinition is applied on a table. the following columns added: NUM_PCT_TABLES. The following example produces a report of the maximum quarter sales amount for every quarter where the quarters are displayed as columns: SELECT * FROM ( SELECT PRODUCT_DESC.---------. error_count). 'cust_int'.

Summary Sheets .---------1 33048 165 0 0 0 2 33151 179 0 0 0 3 32978 173 0 0 0 4 33109 173 0 1 0 You can convert the columns representing the state into rows as follows: select * from CUST_MATRIX UNPIVOT ( state_counts for state_code in ("NEW YORK".---------.-----------Conn 165 Florida 0 Missouri 0 New Jersey 0 New York 33048 Conn 179 Florida 0 Missouri 0 Type --------------------------NUMBER(3) NUMBER NUMBER NUMBER NUMBER NUMBER Page 111 Oracle 11g New Features for Administrators . 2 AS QTR2."CONN". '02') as SR_Feb. (10001. (10000.---------.-------PUCHASE FREQUENCY NEW YORK CONN NEW JERSEY FLORIDA MISSOURI SQL> select * from cust_matrix.---------. QUARTER_ID.---------. Puchase Frequency ----------------1 1 1 1 1 2 2 2 STATE_CODE STATE_COUNTS ---------. IR_Feb The other new operator UNPIVOT has an opposite effect. IR_Jan. month. Suppose you have a spreadsheet with the following format: SQL> desc cust_matrix Name Null? ----------------------------------------. '01') as SR_Jan. QUARTER_AMT FROM PRODUCT_ROW ) PIVOT (MAX(QUARTER_AMT) FOR QUARTER_ID IN (1 AS QTR1. SR_Feb. month) IN ( (10000.You can use column aliases in the generated report as follows: SELECT * FROM ( SELECT PRODUCT_DESC.---------Sharpie 130 215 190 300 Pencils 2100 918 3280 1315 Following is another example of pivoting on multiple columns: SELECT * FROM (SELECT video_name. PUCHASE FREQUENCY NEW YORK CONN NEW JERSEY FLORIDA MISSOURI ----------------. 4 AS QTR4)) PRODUCT_DESC QTR1 QTR2 QTR3 QTR4 -------------------."MISSOURI")) order by "Puchase Frequency". '01') as IR_Jan."FLORIDA". rental_type FROM video_mstr_vw) PIVOT (SUM(quantity_rented) FOR (rental_type.---------. (10001. 3 AS QTR3. quantity_rented."NEW JERSEY".---------. '02') as IR_Feb ) ) ORDER BY SR_Jan. state_code .---------.

'DD-MON-YYYY')) ). does not exist in the child table. Also. CONSTRAINT child_parent_tab_fk FOREIGN KEY (parent_tab_id) REFERENCES parent_tab (id) ) PARTITION BY REFERENCE (child_parent_tab_fk). the HIGH_VALUE is null. yet the child table is partitioned on that column. If the advisor uses the partitioning as one of its recommendations. PARTITION_NAME. Reference Partitions Reference partitioning allows the partitioning of two tables related to one another by a referential constraint. indicating that the boundaries are derived from the parent table.it must be NOT NULL for reference partition code VARCHAR2(10). use the clause PARTITION BY REFERENCE to create a reference partition as in the following example: CREATE TABLE parent_tab ( id NUMBER NOT NULL. CREATE TABLE child_tab ( id NUMBER NOT NULL. SQL Access Advisor can now recommend creating partitions to improve the performance. CREATED_DATE. REF_PTN_CONSTRAINT_NAME FROM USER_PART_TABLES. you will notice that the child table will have partitions created with the same name as its parent table.Summary Sheets . The column on which the parent table is partitioned. SELECT TABLE_NAME.'DD-MON-YYYY')). PARTITIONING_TYPE. Reference partitions is useful when you want to partition a child table in the same fashion as in the parent table but the child table does not have the same partitioned columns. description VARCHAR2(50). The partitioning key is resolved and enforced through an existing parent-child relationship. description VARCHAR2(50). created_date DATE. HIGH_VALUE. PARTITION part_2008 VALUES LESS THAN (TO_DATE('01-JAN-2009'. you can review the SQL script that converts a heap table into a partitioned one. -. code VARCHAR2(10) NOT NULL. When you create the child table. created_date DATE. parent_tab_id NUMBER NOT NULL. CONSTRAINT parent_tab_pk PRIMARY KEY (id) ) PARTITION BY RANGE (created_date) ( PARTITION part_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008'. PARTITION_NAME. The tablespace for the reference partition can be overridden by using the DEPENDENT TABLES clause as in the following example: ALTER TABLE parent_tab ADD PARTITION part_2006 VALUES LESS THAN (TO_DATE('01-JAN-2007'. Details of the reference partitions can be obtained from the following query: SELECT TABLE_NAME. Page 112 Oracle 11g New Features for Administrators . CONSTRAINT child_tab_pk PRIMARY KEY (id). If you issue the following query. Reference partitions will be physically located in the same tablespace of the parent table if the TABLESPACE clause is not specified.'DD-MON-YYYY')) TABLESPACE parent_tab DEPENDENT TABLES (child_tab (PARTITION part_2006 TABLESPACE child_tbs)).Partitioning Improvements The Partition Advisor Partitioning advice is available within the SQL Access Advisor as part of the Enterprise Manager. NUM_ROWS FROM USER_TAB_PARTITIONS ORDER BY TABLE_NAME.

TBS3. TBS2. 'MONTH')) You can obtain information about created partitions by using the following query: EXEC DBMS_STATS. description VARCHAR2(50). in a round-robin fashion. You can.Summary Sheets . NUM_ROWS FROM USER_TAB_PARTITIONS ORDER BY TABLE_NAME. When using interval partitioning. Oracle Database 11g added the following composite partitioning methods: • • • • Composite Range-Range: This partitioning method will partition data using the range method. Interval Partitioning Interval partitioning is an extension of range partitioning which instructs the database to automatically create partitions of a specified interval when data inserted into the table exceeds all of the existing range partitions. RENAME PARTITION .. Composite List-Range Composite List-Hash Composite List-List Page 113 Oracle 11g New Features for Administrators . hourly. Automatically created partitions are named by the system using SYS_Pn format. The ROW MOVEMENT setting for both tables must match. If you want to create a partition for every quarter. or even down to the second. 'INTERVAL_TAB').'MONTH')) making sure that the first partition was created at the end of a given quarter. per minute. Extended Composite Partitioning Prior to Oracle Database 11g. or domain index storage tables. code VARCHAR2(10). Then for each partition. TBS4) -. The NUMTOYMINTERVAL function can be used to create partitions on a smaller scale like daily. Interval partitioning does not support subpartitions. external tables. A MAXVALUE partition cannot be defined for an interval partitioned table. subpartitions are created using the range method. create partitions in the tablespaces listed.The following restrictions apply to reference partitioning: • • • • The foreign key columns referenced in constraint must be NOT NULL.'MONTH')) STORE IN (TBS1. If you use the STORE IN clause to list a group of tablespaces. PARTITION_NAME. The foreign key constraint cannot use the ON DELETE SET NULL clause. the only composite partitioning schemes were range-list and range-hash partitioning. SELECT TABLE_NAME. Following is an example: CREATE TABLE interval_tab ( id NUMBER. then the new INTERVAL clause used to calculate the range for new partitions when the values go beyond the existing transition point. The PARTITION BY RANGE clause is used in the normal way to identify the transition point for the partition. TO command to rename them. created_date DATE ) PARTITION BY RANGE (created_date) INTERVAL (NUMTOYMINTERVAL(1..GATHER_TABLE_STATS(USER. NULL values are not allowed in the partition column. PARTITION_NAME. Oracle will. Interval partitioning is not supported for index-organized tables (IOTs). change the interval command to INTERVAL (NUMTOYMINTERVAL(3. use the ALTER TABLE .'DD-MON-YYYY')) ). HIGH_VALUE. and it must be of NUMBER or DATE type. You can convert an existing non-interval range partition table into an interval partition using the ALTER TABLE command as in the following example: ALTER TABLE interval_tab SET INTERVAL (NUMTOYMINTERVAL(1. Reference partitioning cannot be used for index-organized tables. consider the following restrictions: • • • • • • You can only specify one partitioning key column. however.optional ( PARTITION part_01 VALUES LESS THAN (TO_DATE('01-NOV-2007'.

-. PARTITION org2 VALUES (2) (SUBPARTITION p2_07q1 VALUES LESS THAN (to_date('01-APR-2007'.Composite List-Hash Partitions CREATE TABLE list_hash_tab ( id NUMBER. PARTITION p_Q2_07 VALUES LESS THAN (to_date('01-JUL-2007'. SUBPARTITION p_FEB07 VALUES LESS THAN (to_date('01-MAR-2007'.'dd-MON-yyyy')).'dd-MON-yyyy')). created_date DATE ) PARTITION BY LIST (code) SUBPARTITION BY HASH (id) ( PARTITION part_aa VALUES ('AA') ( SUBPARTITION part_aa_01 .'dd-MON-yyyy')) ). description VARCHAR2(50). SUBPARTITION p_MAY07 VALUES LESS THAN (to_date('01-JUN-2007'.'dd-MON-yyyy')) ( SUBPARTITION p_JAN07 VALUES LESS THAN (to_date('01-FEB-2007'. organization_id NUMBER. SUBPARTITION p1_cat_asm VALUES ('ASM'). message VARCHAR2(4000).'dd-MON-yyyy')). organization_id NUMBER. creation_date DATE ) PARTITION BY LIST (organization_id) SUBPARTITION BY LIST (document_category) ( PARTITION org1 VALUES (1) ( SUBPARTITION p1_cat_dg VALUES ('DG').'dd-MON-yyyy')). document_category VARCHAR2(10). SUBPARTITION p_MAR07 VALUES LESS THAN (to_date('01-APR-2007'. SUBPARTITION p_PRE_Q207 VALUES LESS THAN (MAXVALUE))). closed_date DATE) PARTITION BY RANGE (creation_date) SUBPARTITION BY RANGE (closed_date) ( PARTITION p_Q1_07 VALUES LESS THAN (to_date('01-APR-2007'. Page 114 Oracle 11g New Features for Administrators .Following are examples of creating tables with extended composite partitions: -.'dd-MON-yyyy')). creation_date DATE DEFAULT SYSDATE.'dd-MON-yyyy')). SUBPARTITION part_aa_02 ). SUBPARTITION p_JUN2007 VALUES LESS THAN (to_date('01-JUL-2007'.Composite List-List Partitions CREATE TABLE Docs_List_List ( document_id NUMBER. -.Summary Sheets . creation_date DATE) PARTITION BY LIST (organization_id) SUBPARTITION BY RANGE (creation_date) ( PARTITION org1 VALUES (1) (SUBPARTITION p1_07q1 VALUES LESS THAN (to_date('01-APR-2007'. code VARCHAR2(10).'dd-MON-yyyy')).Composite List-Range Partitioning CREATE TABLE Docs_List_Rist (document_id NUMBER.'dd-MON-yyyy')) ( SUBPARTITION p_APR07 VALUES LESS THAN (to_date('01-MAY-2007'. SUBPARTITION p_PRE_Q107 VALUES LESS THAN (MAXVALUE) ) . PARTITION part_bb VALUES ('BB') ( SUBPARTITION part_bb_01 . -. document_category VARCHAR2(10). SUBPARTITION p1_07q2 VALUES LESS THAN (to_date('01-JUL-2007'.'dd-MON-yyyy')). subject VARCHAR2(2000).Composite Range-Range Partitioning CREATE TABLE Alerts_Range_Range ( alert_notification_id NUMBER. SUBPARTITION part_bb_02 ) ).'dd-MON-yyyy')) ) ). SUBPARTITION p2_07q2 VALUES LESS THAN (to_date('01-JUL-2007'.

. PARTITION can be stated DELETE FROM docs PARTITION (docs_p2) WHERE doc_id=1002.Summary Sheets . ('DG'). ('ASM'). name VARCHAR2(255). System partitions are created using the PARTITION BY SYSTEM clause. including interval and interval-* composite partitioning.PARTITION can be used in queries to target specific partitions SELECT COUNT(*) FROM docs PARTITION (docs_p1) Page 115 Oracle 11g New Features for Administrators . However. -. Virtual column-based partitioning is supported with all basic partitioning strategies. partition p_other values less than (maxvalue)). Inserting into such a table must be partition aware. docs_d2. ('RAC'). For information about virtual columns. Virtual Column-Based Partitioning You can create a partition based on a virtual column. -. desc VARCHAR2(1000)) PARTITION BY SYSTEM ( PARTITION docs_p1 TABLESPACE PARTITION docs_p2 TABLESPACE PARTITION docs_p3 TABLESPACE PARTITION docs_p4 TABLESPACE docs_d1. partition p_1000k_5000k values less than (5000000). partition p_35k_50k values less than (50000). (default) ). ('SQL'). ('PLSQL').'). total_package as (salary + bonus ) VIRTUAL ) PARTITION BY RANGE(total_package) (partition p_10k values less than (10000).PARTITION must be stated INSERT INTO docs PARTITION (docs_p1) VALUES (1. System Partitioning With system partitioning. ('PLSQL'). U U Following is an example of creating virtual column-based partitions: CREATE TABLE hr_employees ( employee_id NUMBER NOT NULL. refer to the "Virtual Columns" section. name VARCHAR2(55). Oracle scans every partition on the table. 'New features in Oracle 11g Database. -. (default) ) ).SUBPARTITION SUBPARTITION SUBPARTITION subpartition PARTITION org2 ( SUBPARTITION SUBPARTITION SUBPARTITION SUBPARTITION SUBPARTITION SUBPARTITION p1_cat_sql p1_cat_plsql p1_cat_rac p1_cat_def VALUES (2) p2_cat_dg p2_cat_asm p2_cat_sql p2_cat_plsql p2_cat_rac p2_cat_def VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES ('SQL'). DELETE FROM docs PARTITION (docs_p2). docs_d4 ). dept_id NUMBER. ('RAC'). a table is physically divided into partitions but the application decides to which partition the rows should be stored. partition p_10k_35k values less than (35000).with DELETE command. . docs_d3. Following is an example: CREATE TABLE docs ( id NUMBER. update and delete operations can be performed with or without the partition-aware syntax.. Be aware that when you perform updates and deletes without the partition-aware syntax. 'Oracle 11g New Features'.

. o To insert data into a system-partitioned table using an INSERT INTO . Page 116 Oracle 11g New Features for Administrators .. the database creates "n" partitions with the name in the format of "SYS_Pn". o Traditional partition pruning and partition-wise joins are not supported on the tables with system partitions.With system partitions. o System partitioning can play no part in composite partitioning.Summary Sheets . o You cannot split a system partition. o Unique local indexes cannot be created on the partition key. AS subquery statement. The range of allowable values for "n" is from 1 to 1024K-1. o System partitioning is not available for index-organized tables or a table that is part of a cluster.. you must use partition-extended syntax to specify the partition into which the values returned by the subquery will be inserted. o If you specify PARTITION BY SYSTEM PARTITIONS n clause. AS SELECT statement. o System partitioning cannot be specified in a CREATE TABLE . a single partition is created with the name in the format of "SYS_Pn".. consider the following restrictions: o If you specify the PARTITION BY SYSTEM clause without defining partitions.

refer to Oracle Education website. Objective Section / Subsection Installation and Upgrade Enhancements Install Oracle Database 11g Installation New Features Support Role and Privilege Changes Deprecated Components New Initialization Creation DBCA Enhancements Upgrade your database to Oracle Database 11g Oracle Direct NFS Use online patching Upgrading to Oracle Database 11g Oracle Direct NFS Patching in Oracle Database Control Parameters Affecting Database Storage Enhancements Setup ASM fast mirror resynch Understand scalability and performance enhancements Setup ASM disk group attributes Use various new manageability options Use the md_backup. To know the latest objectives.Summary Sheets . and ASMCMD extensions ASM Fast Mirror Resync Fast Rebalance Miscellaneous ASM New Features Diskgroup Attributes N/A asmcmd Utility Commands Intelligent Infrastructure Enhancements Creating and using AWR baselines Setting AWR Baseline Metric Thresholds Control Automated Maintenance Tasks Using Database Resource Manager New Features Using new scheduler features N/A Setting Metric Thresholds for Baselines Automatic Maintenance Tasks Enhancements in Oracle Database Resource Manager Oracle Scheduler New Features Performance Enhancements ADDM Enhancements Setup Automatic Memory Management Enhancements in statistics collection Partitioning and Storage-Related Enhancements Implement the new partitioning methods Employ Data Compression SQL Access Advisor Overview Page 117 ADDM New Features Automatic Memory Management Changing Statistics Preferences Enhanced Statistics Maintenance Partitioning Improvements Partitioning Improvements Oracle Advanced Compression Option SQL Access Advisor Enhancements Oracle 11g New Features for Administrators . md_restore. This will help you using this document to review your preparation for the exam.Appendix I Mapping Exam 1Z0-050 Objectives to Document Topics The exam 1Z0-050 (titled as Oracle Database 11g: New Features) is the required exam to pass in order to upgrade your Oracle 10g OCP certificate on Oracle DBA to Oracel11g OCP certificate. Be aware that the objectives mentioned here are as of time of writing this document and Oracle might change them. The table below maps the exam objectives to the document topics. Click there on Certification link.

Summary Sheets . md_restore. De-duplication.Create SQL Access Advisor analysis session using PL/SQL SQL Access Advisor Enhancements Using RMAN Enhancements Managing Archive logs Duplicating a Database Back up large files in multiple sections Perform Archival Backups Use the md_backup. and repair ASMCMD extensions Using Flashback and Logminer Configuring an Archived Redo Log Deletion Policy Active Database Duplication The Multisection Backups Creating Archival Backups asmcmd Utility Commands Oracle Flashback-Related New Features Overview of Flashback Data Archive Manage Flashback Data Archive Back-out transactions using Flashback Transaction Working with Logminer Flashback Data Archive Oracle_Flashback_Transaction_Backout N/A Diagnosability Enhancements Setup Automatic Diagnostic Repository Introducing Automatic Diagnostic Repository (ADR) Configuring the ADR Use Support Workbench Run health checks Use SQL Repair Advisor Using The Support Workbench in the OEM Database Health Monitor Using SQL Repair Advisor Database Replay Overview of Workload Capture and Replay Using Workload capture and replay Using the Data Recovery Advisor Overview of Data Recovery Advisor Repairing data failures using Data Recovery Advisor Perform proactive health check of the database Database Replay Database Replay Data Recovery Advisor Data Recovery Advisor Data Recovery Advisor Database Health Monitor Security: New Features Configure the password file to use case sensitive passwords Encrypt a tablespace Configure fined grained access to network services Case-Sensitive Password Files Tablespace Encryption Fine-Grained Access Control for UTL_* Packages Oracle SecureFiles Use Secure File LOBS to store documents with Compression. Caching Use SQL and PL/SQL APIs to access Secure File LOBS Miscellaneous New Features Describe and use the enhanced online table redefinition Enhanced finer grained dependency management SecureFiles Accessing a LOB Using SQL and PL/SQL N/A Online Redefinition Finer-grained Dependency Management Page 118 Oracle 11g New Features for Administrators . Encryption.

Apply the improved table lock mechanism. Create invisible indexes Use Query Result Cache and PL/SQL Result Cache Adaptive Cursor Sharing Temporary Tablespace Enhancements Explicit Locking of Tables Invisible Indexes Server Result Cache Adaptive Cursor Sharing Shrinking Temporary Tablespaces and Tempfiles SQL Performance Analyzer Overview of SQL Performance Analyzer Using SQL Performance Analyzer SQL Plan Management SQL Plan Baseline Architecture Set up SQL Plan Baseline Using SQL Plan Baseline The SQL Performance Analyzer The SQL Performance Analyzer SQL Plan Management SQL Plan Management SQL Plan Management SQL Plan Management Automatic SQL Tuning Setup and modify Automatic SQL Tuning Interpret reports generated by Automatic SQL Tuning SQL Tuning Automation N/A Page 119 Oracle 11g New Features for Administrators .Use Enhanced DDL .Summary Sheets .

/ SET LONG 100000 LONGCHUNKSIZE 10000 LINESIZE 120 PRINT :report /* Method 2 */ SET SERVEROUTPUT ON SET LONG 100000 LONGCHUNKSIZE 10000 LINESIZE 120 declare report clob. begin -. The following examples show how to display CLOB data in SQL Plus session: /* Method 1 */ VAR report clob begin -.. dbms_output...Summary Sheets . end. / Page 120 Oracle 11g New Features for Administrators .assign value to :report or pass it to the OUT parameter .. end.put_line ('Report : ' || report).assign value to REPORT or pass it to the OUT parameter .Appendix II Displaying CLOB Contents in SQL Plus Many Oracle supplied packages used in database administration have OUT parameter of CLOB data type.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->