Sunteți pe pagina 1din 525

Computer Pride Limited

Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
t r a ns
Oracle Database 11g: o n -
Administrations Workshopan II
h a ฺ
m ) u i de
o tG
ilฺIIc• Student
g m tuden Guide
a
Volume

u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

D50079GC12
Edition 1.2
April 2009
D59863
Computer Pride Limited

Authors Copyright © 2009, Oracle. All rights reserved.

James Womack Disclaimer

Tom Best This document contains proprietary information and is protected by copyright and
Donna Keesling other intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered in
James Spiller any way. Except where your use constitutes "fair use" under copyright law, you may
not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Maria Billings
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

license, post, transmit, or distribute this document in whole or in part without the
Gwen Lazenby express authorization of Oracle.

The information contained in this document is subject to change without notice. If you
Technical Contributors find any problems in the document, please report them in writing to: Oracle University,
and Reviewers 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Sharath Bhujani
Restricted Rights Notice
Timothy Chien
Al Flournoy If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Andy Fortunak applicable:
Gerlinde Frenzen
U.S. GOVERNMENT RIGHTS
ble
Joel Goodman The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
fe r a
Magnus Isaksson license agreement and/or the applicable U.S. Government contract.
an s
Pete Jones
n - t r
no
Trademark Notice
Pierre Labrousse
Jerry Lee s a
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
h a eฺ
names may be trademarks of their respective owners.
)
Hakan Lindfors
m i d
Isabelle Marchand
i l ฺ co nt Gu
Srinivas Putrevu
m a de
Andreas Reinhardt
i @ g S tu
Ira Singer
s y uk this
( M a use
Editors
y u ki se to
Arijit Ghosh as en
M
y Narasimhan
Vijayalakshmi l i c
l e
n Narayan
Sta
Amitha
Atanu Raychaudhuri
Richard Wallis

Graphic Designer
Rajiv Chandrabhanu

Publishers
Pavithran S Adka
Nita Brozowski
Jobi Varghese
Giri Venugopal
Computer Pride Limited

Contents
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1 Database Architecture and ASM


Objectives 1-2
The Oracle Database 1-3
Oracle Database Architecture: Overview 1-4
Connecting to the Database 1-5
Oracle Database Server Structures 1-6
Oracle Memory Architecture 1-7
Process Architecture 1-9
ble
Process Structures 1-10
fe r a
Database Storage Architecture 1-12
ans
Logical and Physical Database Structures 1-14
n - t r
Tablespaces and Data Files 1-16
a no
SYSTEM and SYSAUX Tablespaces 1-17 a s
) h i d eฺ
m
co nt Gu
Segments, Extents, and Blocks 1-18
i l ฺ
Database Architecture: Summary of Structural Components 1-19
g ma tude
Automatic Storage Management: Review 1-20
k i@ is S
ASM: General Architecture 1-22
u
a sy se th
Creating an ASM Instance 1-23
i (M to u
ASM Instance Initialization Parameters 1-24
k
a syu cense
Starting Up an ASM Instance 1-25

yM li
SYSASM Role 1-26
nle Accessing an ASM Instance 1-27
Sta Using Enterprise Manager to Manage ASM Users 1-28
Shutting Down an ASM Instance 1-29
ASM Storage: Concepts 1-30
ASM Disk Group 1-31
Failure Group 1-33
Disk Group Mirroring 1-34
Disk Group Dynamic Rebalancing 1-35
Managing Disk Groups 1-36
Creating and Dropping Disk Groups 1-37
Adding Disks to Disk Groups 1-38
ASM Disk Group Compatibility 1-39
ASM Disk Group Attributes 1-41
Using Enterprise Manager to Edit Disk Group Attributes 1-42

iii
Computer Pride Limited

ASM Fast Mirror Resync Overview 1-43


Using EM to Perform Fast Mirror Resync 1-44
Miscellaneous ALTER Commands 1-45
ASMCMD Utility 1-46
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ASM Scalability and Performance 1-48


Summary 1-50
Practice 1 Overview: Database Architecture and ASM 1-51

2 Configuring for Recoverability


Objectives 2-2
Purpose of Backup and Recovery Functionality 2-3
Typical Backup and Recovery Tasks 2-4
Oracle Backup and Recovery Solutions 2-6
Using Recovery Manager 2-7 ble
fe r a
Types of RMAN Commands 2-8
ans
Job Commands: Example 2-9
n - t r
Configuring Your Database for Backup and Recovery Operations 2-10
a no
ARCHIVELOG Mode 2-11
a s
Configuring ARCHIVELOG Mode 2-12 ) h i d eฺ
m
co nt Gu
Configuring Archive Log Destinations 2-14 i
a del ฺ
Guaranteeing Archive Log Success 2-15 m
i @ g S tu
uk
Specifying a Backup Destination 2-17
is
2-18 e th
Specifying a Retention Policysy
( Ma tPolicy:
A Recovery Window iRetention o usExample 2-20
y uk nArea
Using a Flash Recovery
s se 2-21
DefiningM a e
lic Area 2-23
a Flash Recovery
l e y
tan
Defining a Flash Recovery Area Using Enterprise Manager 2-24
S Flash Recovery Area Space Management 2-25
Flash Recovery Area Space Usage 2-27
Monitoring the Flash Recovery Area 2-29
Benefits of Using a Flash Recovery Area 2-30
Summary 2-31
Practice 2 Overview: Configuring for Recoverability 2-32

3 Using the RMAN Recovery Catalog


Objectives 3-2
RMAN Repository Data Storage: Comparison of Options 3-3
Storing Information in the Recovery Catalog 3-4
Reasons to Use a Recovery Catalog 3-5
Creating the Recovery Catalog: Three Steps 3-6

iv
Computer Pride Limited

Configuring the Recovery Catalog Database 3-7


Creating the Recovery Catalog Owner 3-8
Creating the Recovery Catalog 3-9
Managing Target Database Records in the Recovery Catalog 3-10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Registering a Database in the Recovery Catalog 3-11


Using Enterprise Manager to Register a Database 3-12
Registering a Duplicated Database 3-15
Changing the DBID of a Database 3-16
Unregistering a Target Database from the Recovery Catalog 3-17
Cataloging Additional Backup Files 3-18
Recovery Catalog Resynchronization: Concepts 3-20
Manually Resynchronizing the Recovery Catalog 3-21
Using RMAN Stored Scripts 3-22
Creating RMAN Stored Scripts 3-23 ble
Executing RMAN Stored Scripts 3-24 fe r a
ans
Displaying RMAN Stored Script Information 3-25
n - t r
Updating and Deleting RMAN Stored Scripts 3-26
a no
Backing Up the Recovery Catalog 3-27
a s
) h d eฺ
Re-Creating an Unrecoverable Recovery Catalog 3-28
i
m
co nt Gu
i l ฺ
Exporting and Importing the Recovery Catalog 3-29
ma tude
Upgrading the Recovery Catalog 3-30
g
u k i@ is S
Dropping the Recovery Catalog 3-31
sy se th
Using a Virtual Private Catalog 3-32
a
k i (M to u
Creating an RMAN Virtual Private Catalog 3-34

a syu cense
Summary 3-36

yM li
Practice 3 Overview: Using the RMAN Recovery Catalog 3-37

nle
Sta 4 Configuring Backup Specifications
Objectives 4-2
Using RMAN to Create Backups 4-3
Backup Destinations 4-4
Configuring Persistent Settings for RMAN 4-5
Using Enterprise Manager to Configure RMAN Settings 4-6
Control File Autobackups 4-7
Managing Persistent Settings 4-9
Configuring Devices for Backup 4-10
Configuring and Allocating Channels for Use in Backups 4-12
Configuring Backup Optimization 4-13
Summary 4-15
Practice 4 Overview: Configuring Backup Specifications 4-16

v
Computer Pride Limited

5 Using RMAN to Create Backups


Objectives 5-2
Creating Backup Sets 5-3
Creating Image Copies 5-4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Creating a Whole Database Backup 5-6


Saving Backup Space with Unused Block Compression 5-8
RMAN Backup Types 5-9
Fast Incremental Backup 5-11
Enabling Fast Incremental Backup 5-12
Monitoring Block Change Tracking 5-13
Creating Duplexed Backup Sets 5-14
Creating Duplexed Backup Sets Using CONFIGURE BACKUP COPIES 5-15
Creating Duplexed Backup Sets Using BACKUP COPIES 5-16
Creating Backups of Backup Sets 5-17 ble
fe r a
Backing Up Read-Only Tablespaces 5-18
ans
Archival Backups: Concepts 5-19
n - t r
Creating Archival Backups with EM 5-21
a no
Creating Archival Backups with RMAN 5-22
a s
Managing Archival Database Backups 5-23 ) h i d eฺ
m
co nt Gu
Multisection Backups: Overview 5-24
i l ฺ
ma tude
Creating RMAN Multisection Backups 5-25
g
Compressing Backups 5-26
u k i@ is S
sy se th
Encrypting Backups 5-27
a
k i (M to u
Backing Up Recovery Files 5-29

syu cense
Using a Media Manager 5-30
a
yM li
Performing Proxy Copies 5-32
n le
Creating an Oracle-Suggested Backup 5-33
Sta Managing Backups: Reporting 5-34
Managing Backups: Dynamic Performance Views 5-36
Using Enterprise Manager to View Backup Reports 5-37
Managing Backups: Cross-Checking and Deleting 5-38
Summary 5-39
Practice 5 Overview: Creating Backups 5-40

6 Performing User-Managed Backup and Recovery


Objectives 6-2
Restoring and Recovering 6-3
Causes of File Loss 6-4
Critical Versus Noncritical 6-5
Losing a Tempfile 6-6
Recovering from a Tempfile Loss 6-7

vi
Computer Pride Limited

Log Group Status: Review 6-8


Recovering from the Loss of a Redo Log Group 6-9
Clearing a Log File 6-10
Re-Creating Indexes 6-11
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Recovering from a Lost Index Tablespace 6-13


Authentication Methods for Database Administrators 6-14
Re-creating a Password Authentication File 6-15
Comparing Complete and Incomplete Recovery 6-17
Complete Recovery Process 6-18
Incomplete Recovery Process 6-19
Types of Backup and Recovery Practices 6-21
Performing a User-Managed Backup of the Database 6-22
The Need for Backup Mode 6-23
Identifying Files to Manually Backup 6-24 ble
Manually Backing Up a NOARCHIVELOG Database 6-25 fe r a
ans
Manually Backing Up an ARCHIVELOG Database 6-26
n - t r
Backing Up the Control File 6-27
a no
s
Performing User-Managed Complete Database Recovery: Overview 6-28
a
) h i d eฺ
Performing Complete Closed Database Recovery: Overview 6-29
m
co nt Gu
l ฺ
Identifying Recovery-Related Files 6-30
i
ma tude
Restoring Recovery-Related Files 6-31
g
u k i@ is S
Applying Redo Data 6-33
sy se th
Performing Complete Open Database Recovery 6-34
a
k i (M to u
Performing User-Managed Incomplete Recovery: Overview 6-36

a syu cense
Choosing an Incomplete Recovery Method 6-37

yM li
Performing User-Managed Incomplete Recovery 6-38
nle Performing User-Managed Incomplete Recovery: Steps 6-40
Sta User-Managed Time-Based Recovery: Example 6-41
User-Managed Cancel-Based Recovery: Example 6-43
Recovering a Read-Only Tablespace 6-45
Recovering NOLOGGING Database Objects 6-46
Recovering from the Loss of All Control File Copies: Overview 6-47
Recovering the Control File to the Default Location 6-48
Summary 6-49
Practice 6 Overview: Performing User-Managed Recovery 6-50

7 Using RMAN to Perform Recovery


Objectives 7-2
Using RMAN RESTORE and RECOVER Commands 7-3
Performing Recovery Using Enterprise Manager 7-4

vii
Computer Pride Limited

Performing Complete Recovery: Loss of a Noncritical Data File in ARCHIVELOG


Mode 7-5
Performing Complete Recovery: Loss of a System-Critical Data File in
ARCHIVELOG Mode 7-6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Recovering Image Copies 7-7


Recovering Image Copies: Example 7-8
Performing a Fast Switch to Image Copies 7-10
Using SET NEWNAME for Switching Files 7-11
Performing Restore and Recovery of a Database in NOARCHIVELOG Mode 7-12
Creating Restore Points 7-13
Performing Incomplete Recovery 7-14
Performing Recovery with a Backup Control File 7-16
Restoring the Server Parameter File from the Control File Autobackup 7-17
ble
Restoring the Control File from Autobackup 7-18
fe r a
Using Incremental Backups to Recover a Database in NOARCHIVELOG
ans
Mode 7-20
n - t r
Restoring and Recovering the Database on a New Host 7-21
a no
a s
Preparing to Restore the Database to a New Host 7-22
) h i d eฺ
Restoring the Database to a New Host 7-23 m
co nt Gu
Performing Disaster Recovery 7-27 i l ฺ
Summary 7-29 g ma tude
k i@ is S
Practice 7 Overview: Using RMAN to Perform Recovery 7-30
u
a sy se th
8 Using RMAN to Duplicate i t u
(M a Database
o
k
syu cense
Objectives 8-2
a
Using RMAN
y li a Duplicate Database 8-3
M to Create
l e
nUsing a Duplicate Database 8-4
t a
S Creating a Duplicate Database 8-5
Creating an Initialization Parameter File for the Auxiliary Instance 8-6
Specifying Parameters for Control File Naming 8-7
Starting the Instance in NOMOUNT Mode 8-9
Ensuring That Backups and Archived Redo Log Files Are Available 8-10
Allocating Auxiliary Channels 8-11
Using the RMAN DUPLICATE Command 8-12
Understanding the RMAN Duplication Operation 8-13
Specifying Options for the DUPLICATE Command 8-14
Using EM to Clone a Database 8-15
Cloning a Running Database 8-16
Cloning a Database from a Backup 8-20

viii
Computer Pride Limited

Summary 8-21
Practice 8 Overview: Using RMAN to Duplicate a Database 8-22

9 Performing Tablespace Point-in-Time Recovery


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Objectives 9-2
Tablespace Point-in-Time Recovery (TSPITR): Concepts 9-3
Tablespace Point-in-Time Recovery (TSPITR): Terminology 9-4
Tablespace Point-in-Time Recovery: Architecture 9-5
When to Use TSPITR 9-7
Preparing for TSPITR 9-8
Determining the Correct Target Time 9-9
Determining the Tablespaces for the Recovery Set 9-10
Identifying Objects That Will Be Lost 9-11
Performing Basic RMAN TSPITR 9-12 ble
Performing Fully Automated TSPITR 9-13 fe r a
ans
Using Enterprise Manager to Perform TSPITR 9-14
n - t r
RMAN TSPITR Processing 9-15
a no
s
Performing RMAN TSPITR with an RMAN-Managed Auxiliary Instance 9-17
a
) h d eฺ
Performing RMAN TSPITR Using Your Own Auxiliary Instance 9-18
i
m
co nt Gu
Troubleshooting RMAN TSPITR 9-19
i l ฺ
Summary 9-20
g ma tude
u k i@ is S
Practice 9 Overview: Performing TSPITR 9-21

a sy se th
10 Monitoring and
i (M u
Tuning RMAN
t o
k
yu 10-2
Objectives se
a s e n
y M l ic of Backup Sets 10-3
Parallelization

nle Monitoring RMAN Sessions 10-5


Sta Monitoring RMAN Job Progress 10-7
Interpreting RMAN Message Output 10-9
Using the DEBUG Option 10-10
Interpreting RMAN Error Stacks 10-11
Tuning RMAN 10-12
RMAN Multiplexing 10-14
Allocating Disk Buffers: Example 10-15
Allocating Tape Buffers 10-16
Comparing Synchronous and Asynchronous I/O 10-18
Monitoring RMAN Job Performance 10-20
Asynchronous I/O Bottlenecks 10-21
Synchronous I/O Bottlenecks 10-22
Tape Backup Speed 10-23
Tape Subsystem Performance Rules 10-24

ix
Computer Pride Limited

Controlling Tape Buffer Size with BLKSIZE 10-25


Channel Tuning 10-26
Tuning the BACKUP Command 10-28
Tuning RMAN Backup Performance 10-30
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Setting LARGE_POOL_SIZE 10-31


Tuning RMAN Tape Streaming Performance Bottlenecks 10-32
Summary 10-34
Practice 10 Overview: Monitoring and Tuning RMAN 10-35

11 Using Flashback Technology


Objectives 11-2
Flashback Technology 11-3
Flashback Drop and the Recycle Bin 11-4
ble
Recycle Bin 11-5
fe r a
Restoring Tables from the Recycle Bin 11-7
ans
Recycle Bin: Automatic Space Reclamation 11-8
n - t r
Recycle Bin: Manual Space Reclamation 11-9
a no
Bypassing the Recycle Bin 11-10 a s
Querying the Recycle Bin 11-11 ) h i d eฺ
m
co nt Gu
Transactions and Undo 11-12 i l ฺ
ma tude
Guaranteeing Undo Retention 11-13
g
k i@ is S
Preparing Your Database for Flashback 11-14
u
sy se th
Using Flashback Technology to Query Data 11-16
a
k i (M to u
Flashback Query 11-17

syu cense
Flashback Query: Example 11-18
a
yM li
Flashback Version Query 11-19
n le
Using Enterprise Manager to Perform Flashback Version Query 11-20
Sta Flashback Version Query: Considerations 11-21
Flashback Transaction Query 11-22
Using Enterprise Manager to Perform Flashback Transaction Query 11-23
Flashback Transaction Query: Considerations 11-24
Flashback Transaction 11-25
Prerequisites 11-26
Flashing Back a Transaction 11-27
Possible Workflow 11-28
Viewing Data 11-29
Flashback Transaction Wizard 11-30
Choosing Other Back-out Options 11-34
Final Steps Without EM 11-36

x
Computer Pride Limited

Summary 11-37
Practice 11 Overview: Performing Flashback Database 11-38

12 Additional Flashback Operations


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Objectives 12-2
Flashback Table: Overview 12-3
Flashback Table 12-4
Enabling Row Movement on a Table 12-5
Performing Flashback Table 12-6
Flashback Table: Considerations 12-7
Flashback Database 12-8
Flashback Database Architecture 12-9
Configuring Flashback Database 12-10
Configuring Flashback Database Using EM 12-11 ble
Flashback Database: Examples 12-13 fe r a
ans
Performing Flashback Database Using EM 12-14
n - t r
Flashback Database Considerations 12-17
a no
Monitoring Flashback Database 12-18
a s
) h
Monitoring Flashback Database with EM 12-20 i d eฺ
m
co nt Gu
i l ฺ
Guaranteed Restore Points 12-21
ma tude
Flashback Database and Guaranteed Restore Points 12-22
g
u k i@ is S
Flashback Data Archive 12-24
sy se th
Flashback Data Archive Process 12-25
a
k i (M to u
Flashback Data Archive Scenario 12-26

syu cense
Viewing Flashback Data Archives 12-28
a
yM li
Flashback Data Archive DDL Restrictions 12-29

nle Summary 12-30


Sta Practice 12 Overview: Working with Flashback Database 12-31

13 Diagnosing the Database


Objectives 13-2
Automatic Diagnostic Workflow 13-3
Automatic Diagnostic Repository 13-4
The ADR Command-Line Tool, ADRCI 13-5
The V$DIAG_INFO View 13-6
Location for Diagnostic Traces 13-7
Viewing the Alert Log Using Enterprise Manager 13-8
EM Support Workbench: Overview 13-9
Support Workbench and Oracle Configuration Manager 13-10
EM Support Workbench Roadmap 13-11
Problems and Incidents 13-12

xi
Computer Pride Limited

Viewing Critical Error Alerts in Enterprise Manager 13-14


Viewing Problem Details 13-15
Viewing Incident Details 13-16
Creating a Service Request 13-18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Packaging and Uploading Diagnostic Data to Oracle Support 13-19


Tracking the SR 13-20
Implementing Repairs 13-21
Closing Incidents and Problems 13-22
Incident Packaging Configuration 13-23
Custom Packaging: Creating a New Package 13-24
Custom Packaging: Manipulating an Incident Package 13-25
Custom Packaging: Finalizing an Incident Package 13-26
Custom Packaging: Generating a Package 13-27
Custom Packaging: Uploading a Package 13-28 ble
Viewing and Modifying Incident Packages 13-29 fe r a
ans
Health Monitor: Overview 13-30
n - t r
Running Health Checks Manually: EM Example 13-31
a no
s
Running Health Checks Manually: PL/SQL Example 13-32
a
) h
Viewing HM Reports Using the ADRCI Utility 13-33 i d eฺ
m
co nt Gu
SQL Repair Advisor Overview 13-34
i l ฺ
ma tude
Using SQL Repair Advisor from PL/SQL 13-35
g
u k i@ is S
What Is Block Corruption? 13-36
sy se th
Block Corruption Symptoms: ORA-01578 13-37
a
k i (M to u
How to Handle Corruption 13-38

syu cense
Verifying Block Integrity in Real Time: DB_BLOCK_CHECKING 13-39
a
yM li
Block Media Recovery 13-40
le
Prerequisites for Block Media Recovery 13-41
n
Sta The RECOVER...BLOCK Command 13-42
Data Recovery Advisor 13-43
Data Recovery Advisor: RMAN Command-Line Interface 13-44
Listing of Data Failures 13-45
Advising on Repair 13-47
Executing Repairs 13-48
Classifying (and Closing) Failures 13-49
Data Recovery Advisor Views 13-50
Summary 13-51
Practice 13 Overview: Diagnosing the Database 13-52

14 Managing Memory
Objectives 14-2
Memory Management: Overview 14-3

xii
Computer Pride Limited

Oracle Memory Structures 14-4


Buffer Cache 14-6
Using Multiple Buffer Pools 14-8
Shared Pool 14-10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Large Pool 14-11


Java Pool 14-12
Redo Log Buffer 14-13
Automatic Shared Memory Management: Overview 14-14
How ASMM Works 14-15
Enabling Automatic Shared Memory Management 14-16
Behavior of Autotuned SGA Parameters 14-17
Behavior of Manually Tuned SGA Parameters 14-18
Using the V$PARAMETER View 14-19
Modifying the SGA_TARGET Parameter 14-20 ble
Disabling ASMM 14-21 fe r a
ans
Manually Resizing Dynamic SGA Parameters 14-22
n - t r
Using the Memory Advisor to Size the SGA 14-23
a no
Program Global Area (PGA) 14-24
a s
)
Automatic PGA Memory Management 14-26 h i d eฺ
m
co nt Gu
PGA Management Resources 14-27
i l ฺ
ma tude
Using the Memory Advisor to Size the PGA 14-28
g
u k i@ is S
Automatic Memory Management: Overview 14-29
sy se th
Oracle Database Memory Parameters 14-30
a
k i (M to u
Automatic Memory Parameter Dependency 14-31

syu cense
Enabling Automatic Memory Management with EM 14-33
a
yM li
Monitor Automatic Memory Management 14-34

nle Monitoring Automatic Memory Management 14-35


Sta Efficient Memory Usage: Guidelines 14-36
Memory Tuning Guidelines for the Library Cache 14-38
Summary 14-40
Practice 14 Overview: Using AMM to Correct a Memory Allocation Problem 14-41

15 Managing Database Performance


Objectives 15-2
Tuning Activities 15-3
Performance Planning 15-4
Instance Tuning 15-6
Performance Tuning Methodology 15-7
Performance Monitoring 15-8
Performance Tuning Data 15-9
Optimizer Statistics Collection 15-10

xiii
Computer Pride Limited

Oracle Wait Events 15-12


Instance Statistics 15-13
Monitoring Session Performance 15-15
Displaying Session-Related Statistics 15-16
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Displaying Service-Related Statistics 15-17


Troubleshooting and Tuning Views 15-18
Dictionary Views 15-19
Automatic Workload Repository 15-20
SQL Tuning 15-22
SQL Advisors 15-23
Automatic SQL Tuning Results 15-24
Implement Automatic Tuning Recommendations 15-25
SQL Tuning Advisor: Overview 15-26
Using the SQL Tuning Advisor 15-27 ble
SQL Tuning Advisor Options 15-28 fe r a
ans
SQL Tuning Advisor Recommendations 15-29
n - t r
Using the SQL Tuning Advisor: Example 15-30
a no
Duplicate SQL 15-31
a s
SQL Access Advisor: Overview 15-32 ) h i d eฺ
m
co nt Gu
i l ฺ
Typical SQL Access Advisor Session 15-33
Workload Source 15-34
g ma tude
u k i@ is S
Recommendation Options 15-35
sy se th
Reviewing Recommendations 15-37
a
k i (M to u
Database Replay 15-38

syu cense
System Architecture: Capture 15-39
a li
System Architecture: Processing the Workload 15-40
yM
le
System Architecture: Replay 15-41
n
Sta The Big Picture 15-42
Workloads Supported 15-43
Using Enterprise Manager for Workload Capture 15-44
Using Enterprise Manager for Workload Replay 15-45
Summary 15-46
Practice 15 Overview: Monitor Instance Performance 15-47

16 Space Management
Objectives 16-2
Space Management: Overview 16-3
Free Space Management Within Segments 16-4
Types of Segments 16-5
Allocating Extents 16-6
Block Space Management 16-7

xiv
Computer Pride Limited

Row Chaining and Migration 16-8


Proactive Tablespace Monitoring 16-9
Thresholds and Resolving Space Problems 16-10
Monitoring Tablespace Space Usage 16-11
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Shrinking Segments 16-12


Results of Shrink Operation 16-13
Reclaiming Space Within ASSM Segments 16-14
Segment Advisor: Overview 16-15
Segment Advisor 16-16
Implementing Recommendations 16-17
Automatic Segment Advisor 16-18
Manual Segment Shrink Using EM 16-19
Shrinking Segments Using SQL 16-20
Managing Resumable Space Allocation 16-21 ble
Using Resumable Space Allocation 16-22 fe r a
ans
Resuming Suspended Statements 16-24
n - t r
What Operations Are Resumable? 16-26
a no
Transporting Tablespaces 16-27
a s
) h
Concept: Minimum Compatibility Level 16-28 i d eฺ
m
co nt Gu
i l ฺ
Minimum Compatibility Level 16-29
ma tude
Transportable Tablespace Procedure 16-30
g
u k i@ is S
Determining the Endian Format of a Platform 16-31
sy se th
Transportable Tablespaces with Enterprise Manager 16-33
a
k i (M to u
Transporting Databases 16-36

syu cense
Database Transportation Procedure: Source System Conversion 16-37
a
yM li
Database Transportation Procedure: Target System Conversion 16-38

nle Database Transportation: Considerations 16-39


Sta Summary 16-40
Practice 16 Overview: Managing Storage 16-41

17 Managing Resources
Objectives 17-2
Database Resource Manager: Overview 17-3
Database Resource Manager: Concepts 17-4
Why Use Resource Manager 17-5
Accessing Resource Plans 17-7
Default Maintenance Resource Manager Plan 17-8
Example: DEFAULT_PLAN 17-9
Creating a New Resource Plan 17-10
Creating Consumer Groups 17-11
Assigning Users to Consumer Groups 17-12

xv
Computer Pride Limited

Specifying Resource Plan Directives 17-13


Resource Allocation Methods for Resource Plans 17-14
Comparison of EMPHASIS and RATIO 17-15
Active Session Pool Mechanism 17-17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Setting the Active Session Pool 17-18


Specifying Thresholds: Execution Time Limit 17-20
Setting Idle Timeouts 17-21
Resource Consumer Group Mapping 17-22
Activating a Resource Plan 17-24
Database Resource Manager Information 17-25
Monitoring the Resource Manager 17-26
Summary 17-29
Practice 17 Overview: Using the Resource Manager 17-30
ble
18 Automating Tasks with the Scheduler fe r a
ans
Objectives 18-2
n - t r
Simplifying Management Tasks 18-3
a no
A Simple Job 18-4
a s
Key Components and Steps 18-5 ) h i d eฺ
m
co nt Gu
1. Creating a Program 18-6
i l ฺ
ma tude
2. Creating and Using Schedules 18-7
g
u k i@ is S
3. Creating and Running a Job 18-8
sy se th
4. Monitoring a Job 18-9
a
k i (M to u
Using a Time-Based or Event-Based Schedule 18-10

syu cense
Creating a Time-Based Job 18-11
a li
Persistent Lightweight Jobs 18-13
yM
le
Choosing the Right Job 18-14
n
Sta Creating a Single Lightweight Job 18-16
Creating an Event-Based Schedule 18-17
Creating Event-Based Schedules with Enterprise Manager 18-18
Creating an Event-Based Job 18-19
Event-Based Scheduling 18-20
Creating Complex Schedules 18-22
Creating Job Chains 18-23
Example of a Chain 18-25
1. Creating a Chain Object 18-26
2. Defining Chain Steps 18-27
3. Defining Chain Rules 18-28
4. Starting the Chain 18-29
Monitoring Job Chains 18-30

xvi
Computer Pride Limited

Summary 18-31
Practice 18 Overview: Automating Tasks with the Scheduler 18-32

19 Administering the Scheduler


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Objectives 19-2
Advanced Scheduler Features 19-3
Job Classes 19-4
Creating a Job Class 19-6
Windows 19-7
Creating a Window 19-8
Prioritizing Jobs Within a Window 19-10
Creating an Array of Lightweight Jobs 19-11
Creating Lightweight Jobs 19-12
Viewing Lightweight Jobs in Dictionary 19-14 ble
PL/SQL APIs 19-15 fe r a
ans
Generic Scheduler Data Dictionary Views 19-16
n - t r
Summary 19-18
a no
a s
20 Globalization ) h i d eฺ
m
co nt Gu
Objectives 20-2
i l ฺ
ma tude
Globalization Support Features 20-3
g
What Every DBA Needs to Know
u k i@ 20-4is S
sy 20-5
What Is a Character Set?
a e th
M to20-7
Understanding (Unicode
i us
How Arey k sSets
uCharacter e Used? 20-9
a s
Problems toic e n
Avoid 20-10
y M l
nle Another Sample Problem 20-11
Sta Choosing Your Character Set 20-12
Database Character Sets and National Character Sets 20-13
Obtaining Character Set Information 20-14
Specifying Language-Dependent Behavior 20-15
Specifying Language-Dependent Behavior for the Session 20-16
Language-Dependent and Territory-Dependent Parameters 20-17
Specifying Language-Dependent Behavior 20-19
Linguistic Searching and Sorting 20-20
Using Linguistic Searching and Sorting 20-22
Case-Insensitive and Accent-Insensitive Search and Sort 20-24
Support in SQL and Functions 20-25
Linguistic Index Support 20-26
Customizing Linguistic Searching and Sorting 20-27
Implicit Conversion Between CLOB and NCLOB 20-29

xvii
Computer Pride Limited

NLS Data Conversion with Oracle Utilities 20-30


NLS Data Conversion with Data Pump 20-32
Language and Character Set File Scanner (LCSSCAN) 20-33
Setting the Database Time Zone 20-34
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Summary 20-35
Practice 20 Overview: Using Globalization Support 20-36

Appendix A

Index

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

xviii
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Managing Database Performance

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Monitor the performance of sessions and services


• Use the SQL Tuning Advisor to:
– Identify SQL statements that are using the most resources
– Tune SQL statements that are using the most resources
• Use the SQL Access Advisor to tune a workload
• Describe the benefits of Database Replay
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 15 - 2


Computer Pride Limited

Tuning Activities

The three activities in performance management are:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Performance planning
• Instance tuning
• SQL tuning

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tuning Activities k i
a s yu ense
The three facets
M of tuningic
involve performance planning, instance tuning, and SQL tuning.
y l
t a nle system,
• Performance
operating
planning is the process of establishing the environment: the hardware, software,
network infrastructure, and so on.
S
• Instance tuning is the actual adjustment of Oracle database parameters and operating system
(OS) parameters to gain better performance of the Oracle database.
• SQL tuning involves making your application submit efficient SQL statements. SQL tuning is
performed for the application as a whole, as well as for individual statements. At the application
level, you want to be sure that different parts of the application are taking advantage of each
other’s work and are not competing for resources unnecessarily. In this lesson, you learn about
some common actions that you can take to tune specific SQL statements.
Note: For more information about performance tuning, refer to the Oracle Database Performance
Tuning Guide.

Oracle Database 11g: Administration Workshop II 15 - 3


Computer Pride Limited

Performance Planning

• Investment options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• System architecture
• Scalability
• Application design principles
• Workload testing, modeling, and implementation
• Deploying new applications

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performance Planning k i
a s yu ense
y l ic
There are manyMfacets to performance planning. Planning must include a balance between

t a nle the
performance
architecture:
(speed), cost, and reliability. You must consider the investment in your system
hardware and software infrastructure needed to meet your requirements. This, of
S
course, requires analysis to determine the value for your given environment, application, and
performance requirements. For example, the number of hard drives and controllers has an impact on
the speed of data access.
The ability of an application to scale is also important. This means that you are able to handle more
and more users, clients, sessions, or transactions, without incurring a huge impact on overall system
performance. The most obvious violator of scalability is serializing operations among users. If all
users go through a single path one at a time, then as more users are added, there are definitely
adverse effects on performance. This is because more and more users line up to go through that path.
Poorly written SQL also affects scalability. It requires many users to wait for inefficient SQL to
complete; each user competing with the other on a large number of resources that they are not
actually in need of.
The principles of application design can greatly affect performance. Simplicity of design, use of
views and indexes, and data modeling are all very important.

Oracle Database 11g: Administration Workshop II 15 - 4


Computer Pride Limited

Performance Planning (continued)


Any application must be tested under a representative production workload. This requires estimating
database size and workload, and generating test data and system load.
Performance must be considered as new applications (or new versions of applications) are deployed.
Sometimes design decisions are made to maintain compatibility with old systems during the rollout.
A new database should be configured (on the basis of the production environment) specifically for
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

the applications that it hosts.


A difficult and necessary task is testing the existing applications when changing the infrastructure.
For example, upgrading the database to a newer version, or changing the operating system or server
hardware. Before the application is deployed for production in the new configuration, you want to
know the impact. The application will almost certainly require additional tuning. You need to know
that the critical functionality will perform, without errors.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 15 - 5


Computer Pride Limited

Instance Tuning

• Have well-defined goals.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Allocate memory to database structures.


• Consider I/O requirements in each part of the database.
• Tune the operating system for optimal performance of the
database.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Instance Tuning k i
a s yu ense
At the start of any
y M l c
tuning iactivity, it is necessary to have specific goals. A goal such as “Process 500
e
nlwe’ll
sales transactions per minute” is easier to work toward than one that says, “Make it go as fast as you
can,
S t a
and know when it’s good enough.”
You must allocate Oracle database memory suitably for your application to attain optimum
performance. You have a finite amount of memory to work with. Too little memory allotted to
certain parts of the Oracle database can cause inefficient background activity, which you may not
even be aware of without doing some analysis.
Disk I/O is often the bottleneck of a database and, therefore, requires a lot of attention at the outset of
any database implementation.
The operating system configuration can also affect the performance of an Oracle database. For more
information, see the Oracle Database Installation Guide for your particular platform.

Oracle Database 11g: Administration Workshop II 15 - 6


Computer Pride Limited

Performance Tuning Methodology

The tuning steps:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Tune from the top down. Tune:


1. The design
2. The application code
3. The instance
• Tune the area with the greatest potential benefit. Identify
and tune:
– SQL using the greatest resources ble
– The longest waits fe r a
ans
– The largest service times n - t r
• Stop tuning when the goal is met. a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Performance Tuning u k i (M e to u
Methodology
a sya tuning e n s
Oracle has developed
y M l ic methodology based on years of experience. The basic steps are:

t a nletheisOS
1. Check
problem in
statistics and general machine health before tuning the instance to be sure that the
the database. Use the Enterprise Manager database home page.
S2. Tune from the top down. Start with the design, then the application, and then the instance. For
example, try to eliminate the full tables scans causing the I/O contention before tuning the
tablespace layout on disk. This activity often requires access to the application code.
3. Tune the area with the greatest potential benefit. The tuning methodology presented in this
course is simple. Identify the biggest bottleneck and tune it. Repeat this step. All the various
tuning tools have some way to identify the SQL statements, resource contention, or services that
are taking the most time. The Oracle database provides a time model and metrics to automate
the process of identifying bottlenecks. The Advisors available in Oracle Database 11g use
precisely this methodology.
4. Stop tuning when you meet your goal. This step implies that you set tuning goals.
This is a general approach to tuning the database instance and may require multiple passes.

Oracle Database 11g: Administration Workshop II 15 - 7


Computer Pride Limited

Performance Monitoring

Enterprise Manager provides:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Performance overview on the database home page

• Graphs of metrics and details through the Performance tab


ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performance Monitoring k i
a s yu ense
You can respond
y M l ic in performance only if you know the performance has changed. Oracle
to changes
Databasele11g provides several ways to monitor the current performance of the database instance. The
t a
database
n home page of Enterprise Manager (EM) provides a quick check of the health of the instance
S
and the server, with graphs showing CPU usage, active sessions, and SQL response time. The home
page also shows any alerts that have been triggered.
The Performance tab in EM shows several graphs of performance metrics from several directions.
You can see performance in terms of CPU, average active sessions, throughput, I/O, and other
dimensions. From the Performance page, you can follow links to detailed information: including
sessions and individual SQL statements.
The information displayed in EM is based on performance views that exist in the database. You can
access these views directly with SQL*Plus. Occasionally, you may need to access these views for
some detail about the raw statistics.

Oracle Database 11g: Administration Workshop II 15 - 8


Computer Pride Limited

Performance Tuning Data

Type of data gathered:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Cumulative statistics:
– Wait events with time information
– Time model
• Metrics: Statistic rates
• Sampled statistics: Active session history
– Statistics by session
– Statistics by SQL ble
fe r a
– Statistics by service
ans
– Other dimensions n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Performance Tuning u k
Data i (M e to u
a y ens
sserver
The Oracle database
y M l icsoftware captures information about its own operation. Three major types
t a nlecollected: cumulative statistics, metrics, and sampled statistics.
of data are
S
Cumulative statistics are counts and timing information of a variety of events that occur in the
database server. Some are quite important, such as buffer busy waits. Others have little impact on
tuning, such as index block split. The most important events for tuning are usually the ones showing
the greatest cumulative time values. The statistics in Oracle Database 11g are correlated by the use of
a time model. The time model statistics are based on a percentage of DB time, giving them a
common basis for comparison.
Metrics are statistic counts per unit. The unit could be time (such as seconds), transaction, or session.
Metrics provide a base to proactively monitor performance. You can set thresholds on a metric
causing an alert to be generated. For example, you can set thresholds for when the reads per
millisecond exceed a previously recorded peak value or when the archive log area is 95% full.
Sampled statistics are gathered automatically when STATISTICS_LEVEL is set to TYPICAL or
ALL. Sampled statistics allow you to look back in time. You can view session and system statistics
that were gathered in the past, in various dimensions, even if you had not thought of specifying data
collection for these beforehand.

Oracle Database 11g: Administration Workshop II 15 - 9


Computer Pride Limited

Optimizer Statistics Collection

• SQL performance tuning: Depends on collection of accurate


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

statistics
• Optimizer statistics:
– Object statistics
– Operating system statistics
• Ways to collect statistics:
– Automatically: Automatic Maintenance Tasks
– Manually: DBMS_STATS package
ble
– By setting database initialization parameters fe r a
ans
– By importing statistics from another database n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Optimizer Statistics Collectionk i
a s yu ense
Optimizer statistics
y M l ic
are collections of data that are specific details about database objects. These

t a n eThese
statistics lare
statement.
essential for the query optimizer to choose the best execution plan for each SQL
statistics are gathered periodically and do not change between gatherings.
S
The recommended approach to gathering optimizer statistics is to allow the Oracle database to
automatically gather the statistics. The Automatic Maintenance Tasks can be created automatically at
database creation time and is managed by the Scheduler. It gathers statistics on all objects in the
database that have either missing or stale optimizer statistics by default. You can change the default
configuration through the Automatic Maintenance Tasks page.
System statistics describe the system’s hardware characteristics, such as I/O and CPU performance
and utilization, to the query optimizer. When choosing an execution plan, the optimizer estimates the
I/O and CPU resources required for each query. System statistics enable the query optimizer to more
accurately estimate I/O and CPU costs, and thereby choose a better execution plan. System statistics
are collected using the DBMS_STATS.GATHER_SYSTEM_STATS procedure. When the Oracle
database gathers system statistics, it analyzes system activity in a specified period of time. System
statistics are not automatically gathered. Oracle Corporation recommends that you use the
DBMS_STATS package to gather system statistics.

Oracle Database 11g: Administration Workshop II 15 - 10


Computer Pride Limited

Optimizer Statistics Collection (continued)


If you choose not to use automatic statistics gathering, then you must manually collect statistics in all
schemas, including system schemas. If the data in your database changes regularly, you also need to
gather statistics regularly to ensure that the statistics accurately represent characteristics of your
database objects. To manually collect statistics, use the DBMS_STATS package. This PL/SQL
package is also used to modify, view, export, import, and delete statistics.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

You can also manage optimizer and system statistics collection through database initialization
parameters. For example:
• The OPTIMIZER_DYNAMIC_SAMPLING parameter controls the level of dynamic sampling
performed by the optimizer. You can use dynamic sampling to estimate statistics for tables and
relevant indexes when they are not available or are too out of date to trust. Dynamic sampling
also estimates single-table predicate selectivity when collected statistics cannot be used or are
likely to lead to significant errors in estimation.
• The STATISTICS_LEVEL parameter controls all major statistics collections or advisories in
the database and sets the statistics collection level for the database. The values for this parameter
are BASIC, TYPICAL, and ALL. You can query the V$STATISTICS_LEVEL view to ble
determine which parameters are affected by the STATISTICAL_LEVEL parameter. fera
Note: Setting STATISTICS_LEVEL to BASIC disables many automatic features a s is not
nand
t r
recommended. on-
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 15 - 11


Computer Pride Limited

Oracle Wait Events

• A collection of wait events provides information


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

about the sessions or processes that had to wait or must


wait for different reasons.
• These events are listed in the V$EVENT_NAME view.

bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Oracle Wait Events uki
a s y ense
Wait events areM
y c are incremented by a server process or thread to indicate that it had to
statistics ithat
l
a leevent to complete before being able to continue processing. Wait event data reveals
wait for an
nsymptoms
S t
various of problems that might be impacting performance, such as latch contention, buffer
contention, and I/O contention. Remember that these are only symptoms of problems, not the actual
causes.
Wait events are grouped into classes. The wait event classes include: Administrative, Application,
Cluster, Commit, Concurrency, Configuration, Idle, Network, Other, Scheduler, System I/O, and
User I/O.
There are more than 800 wait events in the Oracle database, including free buffer wait,
latch free, buffer busy waits, db file sequential read, and db file
scattered read.
Using EM, you can view wait events by opening the Performance page and viewing the “Average
Active Sessions” graph, as shown in the slide. By clicking the link for a particular wait event class,
you can drill down to the specific wait events by using the Top Activity interface. In this example,
there was a very small set of buffer busy waits.
For a list of the most common Oracle events, refer to the Oracle Database Reference 11g
documentation.

Oracle Database 11g: Administration Workshop II 15 - 12


Computer Pride Limited

Instance Statistics

V$SYSSTAT V$SYSTEM_WAIT_CLASS V$SGASTAT


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• statistic# • wait_class_id • pool


• name • wait_class# • name
• class • wait_class • bytes
• value • total_waits
• stat_id • time_waited

V$EVENT_NAME
V$SYSTEM_EVENT
• event_number
• event
a b le
• event_id
• total_waits
s fer
• total_timeouts tran
• name
• parameter1
• time_waitednon
-
• parameter2 a
s
• average_wait
a
) h ideฺ
• parameter3
• time_waited_micro
• wait_class
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Instance Statistics uki e to
y
as performance s
en problems, statistics must be available. The Oracle database
To effectively M
diagnose
l i c
l ey many types of cumulative statistics for the system, sessions, and individual SQL
instance generates
n
Sta at the instance level. The Oracle database also tracks cumulative statistics on segments
statements
and services. When analyzing a performance problem in any of these scopes, you typically look at
the change in statistics (delta value) over the period of time you are interested in.
Note: Instance statistics are dynamic and are reset at every instance startup. These statistics can be
captured at a point in time and held in the database in the form of snapshots.
Wait Events Statistics
All the possible wait events are cataloged in the V$EVENT_NAME view.
Cumulative statistics for all sessions are stored in V$SYSTEM_EVENT, which shows the total waits
for a particular event since instance startup.
When you are troubleshooting, you need to know whether a process has waited for any resource.
Systemwide Statistics
All the systemwide statistics are cataloged in the V$STATNAME view: Over 400 statistics are
available in Oracle Database 11g.
The server displays all calculated system statistics in the V$SYSSTAT view. You can query this view
to find cumulative totals since the instance started.

Oracle Database 11g: Administration Workshop II 15 - 13


Computer Pride Limited

Instance Statistics (continued)


Example:
SQL> SELECT name, class, value FROM v$sysstat;
NAME CLASS VALUE
------------------------------- ------ ----------
...
table scans (short tables) 64 135116
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

table scans (long tables) 64 250


table scans (rowid ranges) 64 0
table scans (cache partitions) 64 3
table scans (direct read) 64 0
table scan rows gotten 64 14789836
table scan blocks gotten 64 558542
...
Systemwide statistics are classified by the tuning topic and the debugging purpose. The classes
include general instance activity, redo log buffer activity, locking, database buffer cache activity, and
so on. Each of the system statistics can belong to more than one class, so you cannot do a simplebjoin
a le
on V$SYSSTATS.CLASS and V$SYSTEM_WAIT_CLASS.WAIT_CLASS#.
ns fer
You can also view all wait events for a particular wait class by querying
n - tra
V$SYSTEM_WAIT_CLASS, as in this example (with formatting applied): no
s a
SQL> SELECT * FROM V$SYSTEM_WAIT_CLASS
2 WHERE wait_class LIKE '%I/O%';
a
) h uideฺ
m
CLASS_ID CLASS# WAIT_CLASS
a i l ฺco nt G TIME_WAITED
TOTAL_WAITS
---------- ------ ------------
gm S----------- e
ud1119152 -----------
1740759767 8 User @
i I/O t 39038
4108307767 9 y u k th i s
a s System e
I/O 296959 27929
SGA Global Statistics
i ( M to us
The server displays all
y k sememory statistics in the V$SGASTAT view. You can query this
ucalculated
s
a totals
view to find cumulative c enof detailed SGA usage since the instance started, as in the following
M l i
example:ley
n
Sta SQL> POOL
SELECT * FROM v$sgastat;
NAME BYTES
------ ------------------------- ----------
fixed_sga 7780360
buffer_cache 25165824
log_buffer 262144
shared pool sessions 1284644
shared pool sql area 22376876
...
The results shown are only a partial display of the output.
When the STATISTICS_LEVEL parameter is set to BASIC, the value of the
TIMED_STATISTICS parameter defaults to FALSE. Timing information is not collected for wait
events and much of the performance-monitoring capability of the database is disabled. The explicit
setting of TIMED_STATISTICS overrides the value derived from STATISTICS_LEVEL.

Oracle Database 11g: Administration Workshop II 15 - 14


Computer Pride Limited

Monitoring Session Performance

Details of session performance are available in EM:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Monitoring Session Performancei
a s yu ense
Enterprise Manager
y M l ic session detail pages so that you can view the wait events occurring in
provides
individuallesessions. On the Performance tabbed page, click Top Activity to view the summary of all
tan In the lower right corner of the Top Activity page is a listing of the Top Sessions. Click the
sessions.
S
session identifier to view the Session Details page.
The Top Activity page and Session Details page are based on performance view in the database.

Oracle Database 11g: Administration Workshop II 15 - 15


Computer Pride Limited

Displaying Session-Related Statistics

V$STATNAME V$SESSTAT V$SESSION


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• statistic# • sid • sid


• name • statistic# • serial#
• class • value • username
• command
• osuser
• seq#
• event#
V$SESSION_EVENT V$EVENT_NAME • event
• sid • event# • p1/2/3text
• event • name • p1/2/3
a b le
er
• total_waits • parameter1 • p1/2/3raw
• total_timeouts • parameter2 • wait_class
n s f
• parameter3 • wait_time-tra
on
• time_waited
• average_wait
a n
• seconds_in_wait
s
• state
a
) •h ... deฺ
• max_wait
• time_waited_micro
o m u i
• event_id
ilฺc ent G
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Displaying Session-Related
y u ki Statistics
s e
You can display
M as session
current
l i c en information for each user logged on by querying V$SESSION. For
example,le y can use V$SESSION to determine whether a session represents a user session, or was
you
n
Sta by a database server process (BACKGROUND).
created
You can query either V$SESSION or V$SESSION_WAIT to determine the resources or events for
which active sessions are waiting.
You can view user session statistics in V$SESSTAT. The V$SESSION_EVENT view lists
information about waits for an event by a session.
Cumulative values for instance statistics are generally available through dynamic performance views,
such as V$SESSTAT and V$SYSSTAT. Note that the cumulative values in dynamic views are reset
when the database instance is shut down.
The V$MYSTAT view displays the statistics of the current session.
You can also query V$SESSMETRIC to display the performance metric values for all active
sessions. This view lists performance metrics such as CPU usage, number of physical reads, number
of hard parses, and the logical read ratio.

Oracle Database 11g: Administration Workshop II 15 - 16


Computer Pride Limited

Displaying Service-Related Statistics

For n-tier environments, because session statistics are not as


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

helpful, you can see service-level statistics in these views:


• V$SERVICE_EVENT: Aggregated wait counts and wait times
for each service, on a per event basis
• V$SERVICE_WAIT_CLASS: Aggregated wait counts and
wait times for each service on a wait class basis

bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.

(M a u
Displaying Service-Related k i t o
Statistics
a s yu ense
In an n-tier environment
y M l ic there is an application server that is pooling database connections,
where

a le may not provide the information you need to analyze performance. Grouping
viewing sessions
ninto
S t
sessions service names enables you to monitor performance more accurately. These two views
provide the same information that their like-named session counterparts provide, except that the
information is presented at the service level rather than at the session level.
V$SERVICE_WAIT_CLASS shows wait statistics for each service, broken down by wait class.
V$SERVICE_EVENT shows the same information as V$SERVICE_WAIT_CLASS, except that it is
further broken down by event ID.
Enterprise Manager also provides aggregation by service and by module and service. You can click
the legend in each of the views, to view the activity and statistics for each service.
You can define a service in the database by using the DBMS_SERVICE package and use the net
service name to assign applications to a service.

Oracle Database 11g: Administration Workshop II 15 - 17


Computer Pride Limited

Troubleshooting and Tuning Views

Instance/Database Disk
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

V$DATABASE V$DATAFILE
V$INSTANCE V$FILESTAT
V$PARAMETER V$LOG
V$SPPARAMETER V$LOG_HISTORY
V$SYSTEM_PARAMETER V$DBFILE
V$PROCESS V$TEMPFILE
V$BGPROCESS V$TEMPSEG_USAGE
V$PX_PROCESS_SYSSTAT V$SEGMENT_STATISTICS
V$SYSTEM_EVENT
ble
Contention fe r a
Memory V$LOCK ans
n - t r
V$BUFFER_POOL_STATISTICS V$UNDOSTAT o
V$LIBRARYCACHE V$WAITSTAT an
V$SGAINFO V$LATCH has eฺ
m ) i d
V$PGASTAT
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Troubleshooting andu k i (MViews
Tuning t o
a s y ense
some of theicviews you may need to access to determine the cause of performance
The slide lists M
problemsle y l
or analyze the current status of your database. Many of these views show the same data that
isS tanin creating the reports that the Enterprise Manager produces from the Automatic Workload
used
Repository (AWR). In some cases, the raw data is needed to fully diagnose a problem.
For a complete description of these views, refer to the Oracle Database Reference Manual.

Oracle Database 11g: Administration Workshop II 15 - 18


Computer Pride Limited

Dictionary Views

• The following dictionary and special views display object


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

statistics after use of the DBMS_STATS package:


– DBA_TABLES, DBA_TAB_COLUMNS
– DBA_CLUSTERS
– DBA_INDEXES
– DBA_TAB_HISTOGRAMS
• This statistical information is static until you reexecute the
appropriate procedures in DBMS_STATS. e
r a bl
s fe
- t r an
nno
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Dictionary Views k i
a s yu ense
When you needMto look atic
the optimizer statistics of specific database objects in detail, use the
y lwhich
l
DBMS_STATS
n e package, collects statistics and populates columns in some DBA_xxx views.
Sta
DBMS_STATS populates columns in the views concerned with:
• Table data storage within extents and blocks:
- DBA_TABLES
- DBA_TAB_COLUMNS
• Cluster data storage within extents and blocks:
- DBA_CLUSTERS
• Index data storage within extents and blocks, and index usefulness:
- DBA_INDEXES
• Nonindexed and indexed columns data distribution:
- DBA_TAB_HISTOGRAMS
For more information about using the DBMS_STATS package, refer to the Oracle Database
Performance Tuning Guide.
Performing an ANALYZE INDEX … VALIDATE STRUCTURE command populates the
INDEX_STATS and INDEX_HISTOGRAM views that contain statistics for indexes.

Oracle Database 11g: Administration Workshop II 15 - 19


Computer Pride Limited

Automatic Workload Repository

ADDM finds
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

MMON
top problems.

SYSAUX
SGA
6:00 AM
Snapshot 1
In-memory 7:00 AM
Snapshot 2
statistics 8:00 AM e
9:00 AM
Snapshot 3
r a bl
Snapshot 4 s fe
- t r an
n no
s a
) h a eฺ
9:30 AM m i d
i l ฺ co nt Gu
g ma tude
Copyright k
u i@ Oracle.isAllSrights reserved.
sy se th
© 2009,

a
Automatic Workload u k i (M e to u
Repository
The AutomaticM Workload ens (AWR) is a collection of persistent system performance
asy licRepository
ey by SYS. The AWR resides in the SYSAUX tablespace.
statistics lowned
n
AS ta is a set of performance statistics captured at a certain time and stored in the AWR. Each
snapshot
snapshot is identified by a snapshot sequence number (snap_id) that is unique in the AWR. By
default, snapshots are generated every 60 minutes. You can adjust this frequency by changing the
snapshot INTERVAL parameter. Because the database advisors rely on these snapshots, be aware
that adjustment of the interval setting can affect diagnostic precision. For example, if the INTERVAL
is set to 4 hours, you may miss transient events that would be noticeable in 60-minute intervals.
You can use the DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS stored
procedure or Database Control to change the settings that control snapshot collection. In Database
Control, click Automatic Workload Repository in the Statistics Management region of the Server
tabbed page. Then click Edit to make the changes. The stored procedure offers more flexibility in
defining INTERVAL values than does Database Control.
You can take manual snapshots by using Database Control or the
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT stored procedure. Taking manual
snapshots is supported in conjunction with the automatic snapshots that the system generates. Manual
snapshots are expected to be used when you want to capture the system behavior at two specific
points in time that do not coincide with the automatic schedule.

Oracle Database 11g: Administration Workshop II 15 - 20


Computer Pride Limited

Automatic Workload Repository (continued)


Statspack is a bundled utility that provides a subset of the collection and reporting capability of the
AWR. However, there is no supported path to migrate Statspack data into the workload repository.
Also, the workload repository is not compatible with the Statspack schema. Statspack is not
accessible through Enterprise Manager; it requires setup, and does not have automatic retention
settings, or automatic purge. The Statspack utility does provide scripts for setup, automatic snapshot
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

collection, and reporting. Statspack snapshots can be marked for retention, as part of a Statspack
baseline, or purged with provided scripts.
Statspack is documented in the $ORACLE_HOME/rdbms/admin/spdoc.txt file.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 15 - 21


Computer Pride Limited

SQL Tuning

SQL tuning process


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Identify poorly tuned SQL statements.


• Tune the individual statements.
• Tune the application as a whole.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Tuning k i
a s yu ense
Generally, the M
y
tuning effort
l icthat yields the most benefit is SQL tuning. Poorly tuned SQL uses more
resourcesle
and t a n thanresponse
increases
required. This inefficiency prevents scalability, uses more OS and database resources,
time. To tune poorly tuned SQL statements, they must be identified, and then
S
tuned. SQL statements can be tuned individually, but often the solution that optimizes one statement
can hurt the performance of several others.
The SQL statements that use the most resources are by definition the statements in need of tuning.
These are statements that have the longest elapsed time, use the most CPU, or do the most physical
or logical reads.
Tune the individual statements by checking the optimizer statistics, check the explain plan for the
most efficient access path, test alternate SQL constructions, and test possible new indexes,
materialized views, and partitioning.
Test the application as a whole, using the tuned SQL statements. Is the overall performance better?
The methodology is sound, but tedious. Tuning an individual statement is not difficult. Testing the
overall impact of the individual statement tuning on an application can be very difficult.
In Oracle Database 11g, a set of SQL advisors are available to identify and tune statements,
individually or as a set.

Oracle Database 11g: Administration Workshop II 15 - 22


Computer Pride Limited

SQL Advisors
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Advisors k i
a s yu ense
Oracle Database
y M l ic a set of advisors for SQL: the SQL Access Advisor, the SQL Tuning
11g provides

t a n eSQLthestatements.
Advisor, land
high-load
SQL Repair Advisor. The AWR identifies and records statistics about the recent
S
The SQL Tuning Advisor analyzes one or more SQL statements one at a time. It examines statistics,
SQL profiles, indexes, materialized views, and restructured SQL. The SQL Tuning Advisor can be
run manually at any time, but it is run during every maintenance window against the recent high-load
SQL statements. Click Automatic SQL Tuning Results to view and implement the recommendations.
This automatic job can be configured to automatically implement recommended SQL profiles for the
high-load statements.
The SQL Access Advisor considers changes applied to a set of SQL statements and looks for a net
gain in performance. This set can be a hypothetical set of SQL, a historical set, or a manually created
set.
The SQL Repair Advisor is run from the Support Workbench when a SQL statement fails with a
critical error. A critical error also produces an incident. The repair advisor attempts to find and
recommend a SQL patch. If no patch is found, you can continue in the Support Workbench to
package the incident and submit the package to Oracle Support as a Service Request (SR).

Oracle Database 11g: Administration Workshop II 15 - 23


Computer Pride Limited

Automatic SQL Tuning Results


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Automatic SQL Tuning k i
Results
a s yu ense
The AutomaticM
y
SQL Tuning
l ic Task runs by default every night. The Automatic SQL Tuning Results
that t a
were
nleexamined
link shows the result summary page. If you click View Report, each of the distinct SQL statements
can be viewed.
S
Clicking the Configure button displays a page where you can change the defaults of the Automatic
Tuning Task and enable automatic implementation of SQL profiles.

Oracle Database 11g: Administration Workshop II 15 - 24


Computer Pride Limited

Implement Automatic Tuning


Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Implement AutomaticuTuning k i (M Recommendations
t o
a s y ense
If you click View
y M l c the Automatic Tuning Results Summary page, you will see the
Report ion
Automatic
a leSQL Tuning Result Details. You can implement all the recommendations or drill down to
nimplement
view
S t or individual recommendations. On the Recommendations page, you can click the
eyeglass icon on the right to see the differences that implementing a SQL profile will make in the
explain plan.

Oracle Database 11g: Administration Workshop II 15 - 25


Computer Pride Limited

SQL Tuning Advisor: Overview

Comprehensive SQL tuning


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Detect stale or missing


statistics

Tune SQL plan


(SQL profile)

SQL Tuning Add missing index


ble
Advisor
fe r a
ans
Restructure SQL
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
SQL Tuning Advisor:uOverview i (M e to u
The SQL Tuning a sy cisethensprimary driver of the tuning process. It performs several types of
Advisor
analyses:ley
M li
S an
• tStatistics Analysis: Checks each query object for missing or stale statistics, and makes
recommendations to gather relevant statistics.
• SQL Profiling: The optimizer verifies its own estimates and collects auxiliary information to
remove estimation errors. It builds a SQL profile using the auxiliary information and makes a
recommendation to create it. When a SQL profile is created, it enables the query optimizer to
generate a well-tuned plan.
• Access Path Analysis: New indexes are considered if they significantly improve access to each
table in the query. When appropriate, recommendations to create such objects are made.
• SQL Structure Analysis: SQL statements that use bad plans are identified and relevant
suggestions are made to restructure them. The suggested changes can be syntactic as well as
semantic.
The SQL Tuning Advisor considers each SQL statement included in the advisor task independently.
Creating a new index may help a query, but may hurt the response time of DML. So a recommended
index or other object should be checked with the SQL Access Advisor over a workload (a set of SQL
statements) to determine whether there is a net gain in performance.

Oracle Database 11g: Administration Workshop II 15 - 26


Computer Pride Limited

Using the SQL Tuning Advisor

• Use the SQL Tuning Advisor to analyze SQL statements and


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

obtain performance recommendations.


• Sources for SQL Tuning Advisor to analyze:
– Top Activity: Analyzes the top SQL statements currently
active
– SQL Tuning Sets: Analyzes a set of SQL statements you
provide
– Historical SQL (AWR): Analyzes SQL statements from
statements collected by AWR snapshots bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using the SQL Tuning k i
Advisor
a s yu ense
The SQL Tuning M Advisoricruns automatically every night as the Automatic SQL Tuning Task. There
y l
t a
Advisor
ntoleanalyze
may be times when a SQL statement needs immediate tuning action. You can use the SQL Tuning
SQL statements and obtain performance recommendations at any time. Typically,
S
you run this advisor as an ADDM performance-finding action.
Additionally, you can run the SQL Tuning Advisor when you want to analyze the top SQL
statements consuming the most CPU time, I/O, and memory.
Even though you can submit multiple statements to be analyzed in a single task, each statement is
analyzed independently. To obtain tuning recommendations that consider overall performance of a
set of SQL, use the SQL Access Advisor.

Oracle Database 11g: Administration Workshop II 15 - 27


Computer Pride Limited

SQL Tuning Advisor Options


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Tuning Advisor Options k i
a s yu ense
On the Schedule
y M SQL Tuning
l ic Advisor page, you can choose the SQL statements to include and
a nlebeen
change the
you thave
automatic defaults for a tuning task. You can set the source of the SQL statements, and if
granted the ADVISOR system privilege, you can submit the task. Enterprise Manager
S
then creates a tuning task for the SQL Tuning Advisor.
The SQL statement options allow you to choose one or more SQL statements from recent Top
Activity, choose Historical SQL stored in the AWR, or choose from a SQL Tuning Set that you have
already created.
It is important to choose the appropriate scope for the tuning task If you choose the Limited option,
then the SQL Tuning Advisor produces recommendations based on statistics check, access path
analysis, and SQL structure analysis. The Limited option will not make a SQL profile
recommendation. If you choose the Comprehensive option, the SQL Tuning Advisor produces all the
recommendations that the Limited option produces, but it also invokes the optimizer under the SQL
profiling mode to build a SQL profile. With the Comprehensive option, you can also specify a time
limit for the tuning task, which by default is 30 minutes. After you select Run SQL Tuning Advisor,
configure your tuning task using the SQL Tuning Options page.

Oracle Database 11g: Administration Workshop II 15 - 28


Computer Pride Limited

SQL Tuning Advisor


Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
SQL Tuning Advisor Recommendations
a s yu ense
The SQL Tuning
y M l c the task are displayed as soon as the task completes and can also be
Results ifor
e from the Advisor Central page. A summary of the recommendations are displayed.
accessed llater
n review
You
S t a
can and implement individual recommendations. Select the statement and click view.

Oracle Database 11g: Administration Workshop II 15 - 29


Computer Pride Limited

Using the SQL Tuning Advisor: Example


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M Example u
Using the SQL Tuning k i
Advisor: t o
a s yu ense
You can invoke
y M l c Advisor by performing the following steps:
the SQL iTuning
1. ClickleAdvisor Central in the Related Links region on the Database home page.
S an SQL Advisors. The SQL Tuning Advisor Links page appears.
2. tClick
The advisor can be run on one of the following sources:
- Active SQL: Analyzes the Top SQL statements currently active
- SQL Tuning Sets: Analyzes a set of SQL statements you provide
- Historical SQL (AWR): Analyzes SQL captured by snapshots in the AWR
3. Select Active SQL. Select a five-minute interval to analyze by dragging the shaded box over the
target time period. Select one or more statements to analyze during the selected period.
4. Click Run SQL Tuning Advisor. The SQL Tuning Options page appears showing the SQL
statements in the interval. Give your task a name and description, select Comprehensive as the
scope, and select Immediately for start time. Click OK.
5. Navigate back to the Advisor Central page. The status of Advisor Tasks is listed under this
heading in the Results region. Wait until your task status is completed. Check the status by
clicking Refresh in your browser. Select your task and click View Result. The SQL Tuning
Result page appears.
6. Select the SQL statement and click View Recommendations.

Oracle Database 11g: Administration Workshop II 15 - 30


Computer Pride Limited

Duplicate SQL
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
t r a ns
Bind
o n -variable
s a ncandidates
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Duplicate SQL
y u ki se to
Duplicate SQLM as licareenstatements that are different only in the literal values they use or in
statements
l ey Statements that are different each get a separate cursor in the Library Cache.
their formatting.
n
Sta that are duplicates can use the same cursor if the literals are replaced with bind variables,
Statements
and the formatting is made to be the same.
Duplicate SQL statements can be identified by clicking Duplicate SQL on the Performance tabbed
page in the Additional Monitoring Links section. SQL that is determined to be duplicate, except for
formatting or literal differences, is listed together. This helps you determine which SQL in your
application can be consolidated, thus lowering the requirements on the Library Cache and speeding
up the execution of the statement.

Oracle Database 11g: Administration Workshop II 15 - 31


Computer Pride Limited

SQL Access Advisor: Overview


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Workload specification
Recommendations
-SQL statement
-Indexes
-SQL Tuning Set
-Materialized views
-SQL cache contents
-Materialized view logs
-Statistics
-Partitioning
-Schema name e
r a bl
s fe
- t r an
SQL Access nno
Advisor s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
SQL Access Advisor:uOverviewk i (M e to u
a s
sy ccanenrecommend
The SQL Access M Advisor i the proper set of materialized views, materialized view
y l
e
nlwhen
logs, partitioning, and indexes for a given workload. Understanding and using these structures is
S t a
essential optimizing SQL because they can result in significant performance improvements in
data retrieval.
The SQL Access Advisor recommends bitmap, function-based, and B-tree indexes. A bitmap index
offers a reduced response time for many types of ad hoc queries and reduced storage requirements
compared to other indexing techniques. B-tree indexes are most commonly used in a data warehouse
to index unique or near-unique keys.
Another component of the SQL Access Advisor also recommends how to optimize materialized
views so that they can be fast refreshable and take advantage of general query rewrite.
Note: For more information about materialized views and query rewrite, see the Oracle Database
Performance Tuning Guide.

Oracle Database 11g: Administration Workshop II 15 - 32


Computer Pride Limited

Typical SQL Access Advisor Session


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(MSession u
Typical SQL Access Advisor k i t o
a s yu ense
When starting M
y
a SQL Access
l ic Advisor session, you can select Use Default Options and start with a
eset of advisor options that are recommended. Additionally, you can start a task and have it
na lset
predefined
t a
inherit
S of option values as defined by a template or task by selecting “Inherit Options from a
Task or Template.” These include several generic templates designed for general-purpose
environments, OLTP, and data warehousing databases. You can save custom templates from a
previous task and reuse them when needed.
Click Continue to launch the SQL Access Advisor Wizard.
Note: You can access SQL Access Advisor from the Advisor Central page of Database Control.

Oracle Database 11g: Administration Workshop II 15 - 33


Computer Pride Limited

Workload Source
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Workload Source k i
a s yu ense
Use the SQL Access
y M l ic Wizard’s Workload Source page to provide a defined workload that
Advisor
eAccess Advisor to make recommendations. Supported workload sources are:
anl and Recent SQL Activity: Uses the current SQL from the cache as the workload
allows the
•StCurrent
• Use an existing SQL Tuning Set: Enables you to specify a previously created SQL Tuning Set
as the workload source
• Create a Hypothetical Workload from the Following Schemas and Tables: Provides a
schema that allows the advisor to search for dimension tables and produce a workload
The scope of the workload can be further reduced by applying filters that you can access in the Filter
Options section. With these options, you can reduce the scope of the SQL statements that are present
in the workload. The filters are applied to the workload by the advisor to focus the tuning effort.
Possible filter options are:
• Top resource consuming SQL statements
• Users, module identifier, or actions
• Tables

Oracle Database 11g: Administration Workshop II 15 - 34


Computer Pride Limited

Recommendation Options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recommendation Options k i
a s yu ense
Use the Recommendations
y M l icOptions page to choose whether to limit the advisor to recommendations
based onlaesingle access method. Choose Indexes, Materialized Views, Partitioning, or a combination
tanfrom the “Access Structures to Recommend” section. You can choose Evaluation Only to
ofSthose
evaluate only existing access structures. In this mode, the advisor does not generate new
recommendations but comments on the use of existing structures. This is useful to track the
effectiveness of the current index, materialized view, and MV log usage over time.
You can use the Advisor Mode section to run the advisor in one of two modes. These modes affect
the quality of recommendations as well as the length of time required for processing. In
Comprehensive mode, the advisor searches a large pool of candidates resulting in recommendations
of the highest quality. In Limited mode, the advisor performs quickly, limiting the candidate
recommendations.

Oracle Database 11g: Administration Workshop II 15 - 35


Computer Pride Limited

Recommendation Options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.

(M a u
Recommendation Options k i t o
(continued)
a s yu ense
You can choose
y M Advanced
l icOptions to show or hide options that enable you to set space restrictions,
for t a nle Volatility
tuning options,
Workload
and default storage locations. Use the Workload Categorization section to set options
and Workload Scope. You can choose to favor read-only operations or you
S
can consider the volatility of referenced objects when forming recommendations. You can also select
Partial Workload, which does not include recommendations to drop unused access structures, or
Complete Workload, which does include recommendations to drop unused access structures.
Use the Space Restrictions section to specify a hard space limit, which forces the advisor to produce
recommendations only with total space requirements that do not exceed the specified limit.
Use the Tuning Options section to specify options that customize the recommendations made by the
advisor. Use the “Prioritize Tuning of SQL Statements by” drop-down list to prioritize by Optimizer
Cost, Buffer Gets, CPU Time, Disk Reads, Elapsed Time, and Execution Count.
Use the Default Storage Locations section to override the defaults defined for schema and tablespace
locations. By default, indexes are placed in the schema and tablespace of the table they reference.
Materialized views are placed in the schema and tablespace of the user who executed one of the
queries that contributed to the materialized view recommendation.
After you define these parameters, you can schedule and review your tuning task.

Oracle Database 11g: Administration Workshop II 15 - 36


Computer Pride Limited

Reviewing Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Reviewing Recommendations k i
a s yu ense
Using the Advisor
M Centralicpage, you can list all the completed SQL Access Advisor tasks. Select the
y l
l e
one for which
n you want to see the recommendations, and then click the View Result button. Use the
Sta for Task Summary page to get an overview of the advisor findings. The page presents charts
Results
and statistics that provide overall workload performance and query execution time potential
improvement for the recommendations. You can use the page to show statement counts and
recommendation action counts.
To see other aspects of the results for the advisor task, click one of the three other tabs on the page:
Recommendations, SQL Statements, or Details.
The Recommendations page displays a chart and a table that show the top recommendations ordered
by their percentage improvement to the total cost of the entire workload. The top recommendations
have the biggest total performance improvement.
By clicking the Show SQL button, you can see the generated SQL script for the selected
recommendations. You can click the corresponding recommendation identifier in the table to see the
list of actions that need to be performed in order to implement the recommendation. On the Actions
page, you can actually see all the corresponding SQL statements to execute in order to implement the
action. For recommendations that you do not want to implement, keep those check boxes deselected.
Then, click the Schedule Implementation button to implement the retained actions. This step is
executed in the form of a Scheduler job.

Oracle Database 11g: Administration Workshop II 15 - 37


Computer Pride Limited

Database Replay

Database Replay:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Captures production workloads


• Tests with realistic workloads
• Replays the same SQL against the same data in each test

Workload

ble
fe r a
Replay ans
Capture
n - t r
a no
a s
Production ) h i d eฺ Test
m
co nt Gu
database
a i l ฺ database
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Database Replay
y u ki se to
The system is going
M asto change.
l i c enThe hardware must be upgraded, or the operating system, or the
ey or all of them. You have to assure the users that the application will continue to
database lversion,
n
Sta after the upgrade, and often guarantee performance at least as good as it was before the
function
upgrade.
You build a test environment, and test the application with a workload. You make changes and test
again until you are confident that the application is working in the new environment.
This whole process depends on the test workload being representative of the actual production
workload. A single statement in the production workload missing in the test workload could cause
the upgrade to fail in production.
Database Replay captures the actual production workload, and allows you to replay the workload in a
test environment. The replay can be modified to allow for higher throughput, asynchronous
application, and faster or slower replay. Database Replay can also be used to fine-tune by running
exactly the same set of statements repeatedly. You can make changes to the environment and observe
the differences. This capability also allows capture and replay of test cases to resolve errors.
Using actual production workloads allows you to be confident that the testing process is complete
and accurate.

Oracle Database 11g: Administration Workshop II 15 - 38


Computer Pride Limited

System Architecture: Capture


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Capture directory

Shadow capture file


Shadow Shadow Shadow Shadow

Shadow capture file


Recording infrastructure
Database stack Shadow capture file

Shadow capture file


Background Background

ble
fe r a
ans
n - t r
Database
backup a no
a s
) h i d eฺ
Production m
co nt Gu
database i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
System Architecture:uCapturek i (M e to u
a sy there e n s
Start the recording
y M when
l ic are no active sessions, to be sure to capture all SQL. During recording,

t
while a nleproduction
special recording
the
infrastructure built into the RDBMS records data about all external client requests,
workload is running on the system. External requests are any SQL queries,
S
PL/SQL blocks, PL/SQL remote procedure calls, DML statements, DDL statements, object
navigation requests and OCI calls. Background jobs and, in general all internal clients, continue their
work during recording, without being recorded. The end product is that the workload recording
contains all necessary information for replaying the workload as seen by the RDBMS in the form of
external requests.
The recording infrastructure imposes minimal performance overhead (extra CPU, memory, and I/O)
on the recording system. You should, however, plan to accommodate the additional disk space
needed for the actual workload recording.
A backup of the database corresponding to the beginning of the capture is required for replay.
RAC Note: Instances in a RAC environment have access to the common database files. However,
they do not need to share a common general-purpose file system. In such an environment, the
workload recording is written on each instance’s file system during recording. For processing and
replay, all the parts of the workload recording need to be manually copied into a single directory.

Oracle Database 11g: Administration Workshop II 15 - 39


Computer Pride Limited

System Architecture: Processing the Workload


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Capture directory

Process capture files


Shadow capture file

Shadow capture file

Database stack Shadow capture file

Shadow capture file


Background Background

ble
fe r a
ans
n - t r
Database
backup a no
a s
) h i d eฺ
Production m
co nt Gu
database i l ฺ Process

ma tude
capture

g
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k i (M e totheuWorkload
System Architecture:uProcessing
a
The captured workload ns preprocessing to create metadata that are needed to replay the
sy filescerequire
yM
workload.leThe
li
processing includes information about the test system that allows the test system to be
n
Sta from the capture system.
different
The workload capture data is processed and new workload replay–specific metadata files are created.
Only new files are created; no files are modified that were created during the workload capture.
Because of this, you can run the preprocess multiple times on the same capture directory, such as
when the procedure encounters unexpected errors or is canceled.
External client connections are remapped at this stage and any replay parameters can be modified
that affect the replay outcome.
Note: Because processing workload capture can be relatively expensive, best practice is to do that
operation on another system than the production database system.

Oracle Database 11g: Administration Workshop II 15 - 40


Computer Pride Limited

System Architecture: Replay


Replay
system Replay Replay
client client
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Capture directory

Process capture files


Shadow … Shadow Shadow … Shadow
Shadow capture file

Shadow capture file

Database stack Shadow capture file

Shadow capture file


Background Background

ble
fe r a
Test
ans
system
with
n - t r
Database
backup
changes

a no
a s
) h i d eฺ
Test m
co nt Gu
database i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
System Architecture Replayk i
a s yu ense
Before replaying
y M l ic on the replay system, you need to ensure:
the workload

t a nle thecapture.
1. Restore
workload
replay database on a test system to match the capture database at the start of the
S2. Make changes (such as perform an upgrade) to the test system as needed.
3. Copy the workload to a directory available to the replay system.
The workload recording is consumed by a special application called the replay driver, which sends
requests to the RDBMS on which the workload is replayed. The RDBMS on which the workload is
replayed is usually a test system. It is assumed that the database of the replay system is suitable for
the replay of the workload that was recorded. The internal RDBMS clients are not replayed. The
replay driver is a special client that consumes the workload recording and sends appropriate requests
to the test system to make it behave as though the external requests were sent by the clients used
during the recording of the workload. The use of a special driver that acts as the sole external client
to the RDBMS allows for the record and replay infrastructure to be client agnostic.
The replay driver consists of one or more clients that connect to the replay system and sends requests
based on the workload capture. The replay driver equally distributes the workload capture streams
among all the replay clients based on network bandwidth, CPU, and memory capability.

Oracle Database 11g: Administration Workshop II 15 - 41


Computer Pride Limited

The Big Picture


Prechange Production System Postchange Test System

Clients/App servers
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Capture directory Replay


system

Process capture files


Shadow capture file

Shadow capture file

Shadow capture file


Test
Production Shadow capture file system
system with
changes

ble
fe r a
an s
Production
database
Database
backup
Database
n
restore- t r
n o
Can use Snapshot Standby as test system
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
The Big Picture k i
a s yu ense
The significantM
y ic Oracle Database 11g managing system changes is the added confidence
benefit with
l
a n le in the success of performing the change. The record and replay functionality offers
to the business
S t
confidence in the ease of upgrade during a database server upgrade. A useful application of Database
Replay is to test the performance of a new server configuration. Suppose you are utilizing a single-
instance database and want to move to a Real Application Clusters (RAC) setup. You can record the
workload of an interesting period and then set up a RAC test system for replay. During replay, you
can monitor the performance benefit of the new configuration by comparing the performance to the
recorded system.
Database Replay can be used for debugging. You can record and replay sessions emulating an
environment to make bugs more reproducible. Manageability feature testing is another benefit. Self-
managing and self-healing systems need to implement this advice automatically (“autonomic
computing model”). Multiple replay iterations allow testing and fine-tuning of the control strategies’
effectiveness and stability.
The database administrator, or a user with special privileges granted by the DBA, can initiate the
record and replay cycle and has full control of the entire procedure.

Oracle Database 11g: Administration Workshop II 15 - 42


Computer Pride Limited

Workloads Supported

• Captured operations:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

– All SQL (DML, DDL, PL/SQL) with practically all types of


binds
– Full LOB functionality (cursor based and direct OCI)
– Local transactions
– Login/logoff
– Session switching
– Limited PL/SQL RPCs
• Limitations: Operations not captured e
– Direct path load, import/export r a bl
s fe
– OCI-based object navigation (ADTs) and REF binds tran
– Streams, non-PL/SQL-based AQ o n -
– s a n operations
Distributed transactions, remote describe/commit
– Flashback (Database and Query) m)
ha ideฺ
– Shared server i l ฺ co nt Gu
a e
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Workloads Supporteduki e
y
asworkload s
enis further divided into five nonexclusive categories:
The user foreground
M l i c
y Recursive SQL calls and SQL calls from parallel query slaves are not recorded.
1. SQLle calls:
a n
StRecursive SQL calls are regenerated when the user calls are replayed. Parallel query slave calls
are replayed as part of the top-level call that spawned them. All nonrecursive SQL is recorded
and replayed.
2. Login/logoff: Due to security reasons, passwords are not recorded and replayed. Net service
names are recorded and replayed. The name resolution on the test system must resolve all net
service names to a test system.
3. Other non-SQL calls: Remote procedure calls from PL/SQL, distributed transactions, debug
calls, executed using synchronized SCN, remote commit, remote describe, bundled PL/SQL
4. External interactions: Database links, external tables, directory objects, and URLs. These
external references must be remapped to prevent accidental interaction with production systems.
5. Workload from Oracle utilities or features (such as Enterprise Manager, DataPump,
SQL*Loader, Replication)
The last two categories contain essentially SQL or non-SQL calls.
Note that there are several operations that are not captured, as shown in the slide.

Oracle Database 11g: Administration Workshop II 15 - 43


Computer Pride Limited

Using Enterprise Manager for Workload Capture

Start
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Workload recording

Plan

Shutdown - Startup Restricted ble


...
fe r a
a n s
o n -tr
Capture n
Rawacaptured
s
ha iddata
) eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(for
Using Enterprise Manager k i
u nsWorkloade Capture
s y
a workflow e for Database Replay. As shown, the workload capture and
This slide shows
M the
l i c
l ey need to be done only once. The data produced can be used for workload replay
preprocessing
n
ta times. The workload recording has three main steps:
multiple
S1. Planning for capture
2. Preparing for capture
3. Capturing the workload
Enterprise Manager uses the API to perform these operations. You can perform them without using
EM.
After the database has restarted in restricted mode, you begin the capture phase by calling the
START_CAPTURE procedure in the DBMS_WORKLOAD_CAPTURE package. When you execute the
FINISH_CAPTURE procedure, the capture stops, and the database system flushes the capture
buffers and closes all the open workload data files. After finishing the recording, you can request a
report on the capture. This is used for comparison with the report generated through the Replay
Phases.
For more information, see the Oracle Database Performance Tuning Guide.

Oracle Database 11g: Administration Workshop II 15 - 44


Computer Pride Limited

Using Enterprise Manager for Workload Replay

Workload Replay
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Process Capture
Replay Files
& Metadata
Raw captured data
(from production
Initialize Replay
system)
Prepare e
r a bl
s fe
Replay
- t r an
Replay
non
Reports a
Analyze
) ha ideฺ End
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Using Enterprise Manager u e to
ki forsWorkload Replay
s y
a haslfour n
e steps:
The workload M replay i c
l ey replay data
1. Initializing
n
S a
2. tPreparing for replay
3. Replay
4. Replay analysis
All the steps performed by Enterprise Manager can also be done through the PL/SQL API. For
detailed information about the manual steps, see the Oracle Database Performance Tuning Guide.
For details of the DBMS_WORKLOAD_CAPTURE and DBMS_WORKLOAD_REPLAY packages, see
the Oracle Database PL/SQL Packages and Types Reference.

Oracle Database 11g: Administration Workshop II 15 - 45


Computer Pride Limited

Summary

In this lesson, you should have learned how to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Monitor the performance of sessions and services


• Use the SQL Tuning Advisor to:
– Identify SQL statements that are using the most resources
– Tune SQL statements that are using the most resources
• Use the SQL Access Advisor to tune a workload
• Describe the benefits of Database Replay
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 15 - 46


Computer Pride Limited

Practice 15 Overview:
Monitor Instance Performance
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Monitoring Top Services and Sessions


• Using SQL Tuning Advisor
• Using SQL Access Advisor

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 15 - 47


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Space Management

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Describe how the Oracle database server automatically


manages space
• Proactively monitor and manage tablespace space usage
• Use the Segment Advisor
• Reclaim wasted space from tables and indexes by using the
segment shrink functionality
• Manage resumable space allocation a b le
• Describe the concepts of transportable tablespaces and s fer
- t r an
databases on
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 16 - 2


Computer Pride Limited

Space Management: Overview

Space is automatically managed by the Oracle database


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

server. It generates alerts about potential problems and


recommends possible solutions. Features include:
• Oracle Managed Files (OMF)
• Free-space management with bitmaps (“locally managed”)
and automatic data file extension
• Proactive space management (default thresholds and
server-generated alerts) le
a b
• Space reclamation (shrinking segments, online table s fer
redefinition) - t r an
n o n
• Capacity planning (growth reports) a
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Space Management:uOverviewk i (M e to u
a sy Files e n s
With Oracle Managed
M ic (OMF), you can specify operations in terms of database objects
y l
a n le file names. The Oracle database server can manage free space within a tablespace
rather than
t
with
S bitmaps. This is known as a “locally managed” tablespace. In addition, free space within
segments located in locally managed tablespaces can be managed using bitmaps. This is known
as Automatic Segment Space Management. The bitmapped implementation eliminates much
space-related tuning of tables, while providing improved performance during peak loads.
Additionally, the Oracle database server provides automatic extension of data files, so the files
can grow automatically based on the amount of data in the files.
When you create a database, proactive space monitoring is enabled by default. (This causes no
performance impact.) The Oracle database server monitors space utilization during normal space
allocation and deallocation operations and alerts you if the free space availability falls below the
predefined thresholds (which you can override). Advisors and wizards assist you with space
reclamation.
For capacity planning, the Oracle database server provides space estimates based on table
structure and number of rows and a growth trend report based on historical space utilization
stored in the Automatic Workload Repository (AWR).

Oracle Database 11g: Administration Workshop II 16 - 3


Computer Pride Limited

Free Space Management Within Segments

BMB BMB BMB … BMB • Tracked by bitmaps in


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

segments
BMB BMB …
Benefits:
BMB …
• More flexible space
… utilization
• Run-time adjustment

• Multiple process search
… … … … of BMBs ble
fe r a
ans

n - t r
Data n o
block … s a
{
) h a eฺ
m i d
Segment
Extent
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Free Space Management k i
a s yu ense
Free space can
y lic automatically inside database segments. The in-segment free or used
Mbe managed
space n e
is ltracked with bitmaps. To take advantage of this feature, specify Automatic Segment
t
Spacea
S Management, when you create a locally managed tablespace. Your specification then
applies to all segments subsequently created in this tablespace.
Automatic space management segments have a set of bitmap blocks (BMBs) describing the
space utilization of the data blocks in that segment. BMBs are organized in a tree hierarchy. The
root level of the hierarchy, which contains the references to all intermediate BMBs, is stored in
the segment header. The leaves of this hierarchy represent the space information for a set of
contiguous data blocks that belong to the segment. The maximum number of levels inside this
hierarchy is three.
Benefits of using automatic space management include:
• Better space utilization, especially for the objects with highly varying row sizes
• Better run-time adjustment to variations in concurrent access
• Better multi-instance behavior in terms of performance or space utilization
Therefore, less work for you, the DBA.

Oracle Database 11g: Administration Workshop II 16 - 4


Computer Pride Limited

Types of Segments

A segment is a set of extents allocated for a certain logical


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

structure. The different types of segments include:


• Table and cluster segments
• Index segment
• Undo segment
• Temporary segment
Segments are dynamically allocated by the Oracle database
server. bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Types of Segments uki
a s y ense
Table and cluster
y M segments:lic Each nonclustered table has a data segment. All table data is
storedninle
the extents of the table segment. For a partitioned table, each partition has a data
t a
segment.
S Each cluster has a data segment. The data of every table in the cluster is stored in the
cluster’s data segment.
Index segment: Each index has an index segment that stores all of its data. For a partitioned
index, each partition has an index segment.
Undo segment: Oracle Database maintains information to reverse changes made to the database.
This information consists of records of the actions of transactions, collectively known as undo.
Undo is stored in undo segments in an undo tablespace.
Temporary segment: A temporary segment is created by the Oracle database server when a
SQL statement needs a temporary database area to complete execution. When the statement
finishes execution, the extents in the temporary segment are returned to the system for future
use.
The Oracle database server dynamically allocates space when the existing extents of a segment
become full. Because extents are allocated as needed, the extents of a segment may or may not
be contiguous on disk.

Oracle Database 11g: Administration Workshop II 16 - 5


Computer Pride Limited

Allocating Extents

• Searching the data file’s bitmap for the required number of


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

adjacent free blocks


• Sizing extents with storage clauses:
– UNIFORM
– AUTOALLOCATE
• Viewing extent map
• Obtaining deallocation
advice ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Allocating Extents uki
a s y ense
With locally managed
y M lic
tablespaces, the Oracle database server looks for free space to allocate to
a new n
a le by first determining a candidate data file in the tablespace and then searching the
extent
t
data
S file’s bitmap for the required number of adjacent free blocks. If that data file does not have
enough adjacent free space, then the Oracle database server looks in another data file.
Two clauses affect the sizing of extents:
• With the UNIFORM clause, the database creates all extents of a uniform size that you
specified (or a default size) for any objects created in the tablespace.
• With the AUTOALLOCATE clause, the database determines the extent-sizing policy for the
tablespace.
To view the extent map in Enterprise Manager, choose Server > Tablespaces > View Tablespace
> Show Tablespace Contents.
The Oracle database server provides a Segment Advisor that helps you determine whether an
object has space available for reclamation on the basis of the level of space fragmentation within
the object.

Oracle Database 11g: Administration Workshop II 16 - 6


Computer Pride Limited

Block Space Management


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

PCTFREE = 10

FS2

FS3

FS1
FS1
ble
FS2 fe r a
Inserts, t r a ns
FS3 Deletes n -
Deletes
o
updates
s an
FS4 ) ha ideฺ
Full block c o m block
Full G u
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Block Space Management k i
a s yu ense
Space management
y lic the management of free space at the block level. With Automatic
M involves
Segment
a n leSpace Management, each block is divided into four sections, named FS1 (between 0
andt
S 25% of free space), FS2 (25% to50% free), FS3 (50% to 75% free), and FS4 (75% to 100%
free).
Depending on the level of free space in the block, its status is automatically updated. That way,
depending on the length of an inserted row, you can tell whether a particular block can be used
to satisfy an insert operation. Note that a “full” status means that a block is no longer available
for inserts.
In the slide example, the block on the left is an FS3 block because it has between 50% and 75%
free space. After some insert and update statements, PCTFREE is reached (the dashed line) and
it is no longer possible to insert new rows in that block. The block is now considered as a “full”
or FS1 block. The block is considered for insertion again, as soon as its free space level drops
below the next section. In the case above, it gets status FS2 as soon as the free space is more
than 25%.
Note: Large object (LOB) data types (BLOB, CLOB, NCLOB, and BFILE) do not use the
PCTFREE storage parameter.

Oracle Database 11g: Administration Workshop II 16 - 7


Computer Pride Limited

Row Chaining and Migration

Example:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• On update: Row length increases,


exceeding the available free space Old
in the block.
• Data needs to be stored in a new block. Original block
• Original physical identifier of row with pointer
(ROWID) is preserved. to migrated
row
• The Oracle database server needs ble
to read two blocks to retrieve data. fe r a
t r a ns
• The Segment Advisor finds segments n
New- data
o
containing the migrated rows.
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Row Chaining and Migrating
y u ki se to
M as the
In two circumstances, l i c en for a row in a table may be too large to fit into a single data
data
y first case, the row is too large to fit into one data block when it is first inserted. In
block.nInlethe
Stacase, the Oracle database server stores the data for the row in a chain of data blocks (one or
this
more) reserved for that segment. Row chaining most often occurs with large rows, such as rows
that contain a column of data type LONG or LONG RAW. Row chaining in these cases is
unavoidable.
However, in the second case, a row that originally fit into one data block is updated, so that the
overall row length increases, and the block’s free space is already completely filled. In this case,
the Oracle database server migrates the data for the entire row to a new data block, assuming
that the entire row can fit in a new block. The database preserves the original row piece of a
migrated row to point to the new block containing the migrated row. The ROWID of a migrated
row does not change.
When a row is chained or migrated, input/output (I/O) performance associated with this row
decreases because the Oracle database server must scan more than one data block to retrieve the
information for the row.
The Segment Advisor finds the segments containing migrated rows that result from an UPDATE.

Oracle Database 11g: Administration Workshop II 16 - 8


Computer Pride Limited

Proactive Tablespace Monitoring


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Proactive Tablespace k i
Monitoring
a s yu ense
Tablespace disk
y lic is proactively managed by the database in the following ways:
M space usage
a n le the use of database alerts, you are informed when a tablespace runs low on
• Through
t
S available disk space as well as when particular segments are running out of space. You can
then provide the tablespace with more disk space, thus avoiding out-of-space conditions.
• Information gathered is stored in the Automatic Workload Repository (AWR) and is used to
perform growth trend analysis and capacity planning of the database.
To view and modify tablespace information in Enterprise Manager, select Server from the
Database Home page, and then select Tablespaces. Select the tablespace of your choice and
click the Edit button.

Oracle Database 11g: Administration Workshop II 16 - 9


Computer Pride Limited

Thresholds and
Resolving Space Problems
97% full or 5 MB left
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

critical
Alert
85% full or 100 MB left DBA
warning
Resolve space
Locally managed tablespace problem
Resolve space problem by:
• Adding or resizing data file
• Setting AUTOEXTEND ON ble
fe r a
• Shrinking objects s
- t r an
• Reducing UNDO_RETENTION n
a no
• Checking for long-running queries in temporary a s tablespaces
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Thresholds and Resolvingk i
u nSpace e Problems
s y
a are s
edefined either as full or as available space in the tablespace. Critical
Tablespace thresholds
M l i c
l ey thresholds are the two thresholds that apply to a tablespace. The
and warning
n
Sta
DBMS_SERVER_ALERT package contains procedures to set and get the threshold values. When
the tablespace limits are reached, an appropriate alert is raised. The threshold is expressed in
terms of a percentage of the tablespace size or in remaining bytes free. It is calculated in
memory. You can have both a percentage and a byte-based threshold defined for a tablespace.
Either or both of them may generate an alert.
The ideal setting for the warning threshold trigger value results in an alert that is early enough to
ensure that there is enough time to resolve the problem before it becomes critical, but late
enough so that you are not bothered when space is not a problem.
The alert indicates that the problem can be resolved by doing one or more of the following:
• Adding more space to the tablespace by adding a file or resizing existing files, or making an
existing file autoextendable
• Freeing up space on disks that contain any autoextendable files
• Shrinking sparse objects in the tablespace

Oracle Database 11g: Administration Workshop II 16 - 10


Computer Pride Limited

Monitoring Tablespace Space Usage

Check every 10 min.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

97% Critical Cleared


Alert
85% Warning Cleared
Alert

MMON

• Read-only and offline tablespaces: Do not set up alerts.


• Temporary tablespace: Threshold corresponds to space a b le
currently used by sessions. s fer
- t r an
• Undo tablespace: Threshold corresponds to space
n onused by
active and unexpired extents. s a
a
) hon the eฺ
• Autoextensible files: Threshold is based m u i dmaximum file
ฺ c o t G
size. ail en
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Monitoring Tablespace
y u kiSpace s e Usage
The database M as space
tracks l i c n
eutilization while performing regular space management activities.
le y
This information is aggregated every 10 minutes by the MMON process. An alert is triggered
t
whena n
S the threshold for a tablespace has been reached or cleared.
• Alerts should not be flagged on tablespaces that are in read-only mode, or tablespaces that
were taken offline, because there is not much to do for them.
• In temporary tablespaces, the threshold value has to be defined as a limit on the used space
in the tablespace.
• For undo tablespaces, an extent is reusable if it does not contain active or unexpired undo.
For the computation of threshold violation, the sum of active and unexpired extents is
considered as used space.
• For tablespaces with autoextensible files, the thresholds are computed according to the
maximum file size you specified, or the maximum OS file size.

Oracle Database 11g: Administration Workshop II 16 - 11


Computer Pride Limited

Shrinking Segments
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

HWM

1 ALTER TABLE employees SHRINK SPACE COMPACT;

HWM
DML operations and queries can be issued during compaction.
ble
fe r a
2 ALTER TABLE employees SHRINK SPACE; s
- t r an
n no
s a
) h a eฺ
m i d
HWM
DML operations are blocked when the i l ฺHWM Gu
co isntadjusted.
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Shrinking Segmentsuki
a s y ense
The diagram M in the slidelic
describes the two phases of a table shrink operation. The first phase
does the y
lecompaction. During this phase, rows are moved to the left part of the segment as much
as t a n
Spossible. Internally, rows are moved by packets to avoid locking issues. After the rows have
been moved, the second phase of the shrink operation is started. During this phase, the high-
water mark (HWM) is adjusted and the unused space is released.
The COMPACT clause is useful if you have long-running queries that might span the shrink
operation and attempt to read from blocks that have been reclaimed. When you specify the
SHRINK SPACE COMPACT clause, the progress of the shrink operation is saved in the bitmap
blocks of the corresponding segment. This means that the next time a shrink operation is
executed on the same segment, the Oracle database server remembers what has been done
already. You can then reissue the SHRINK SPACE clause without the COMPACT clause during
off-peak hours to complete the second phase.

Oracle Database 11g: Administration Workshop II 16 - 12


Computer Pride Limited

Results of Shrink Operation

• Improved performance and space utilization


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Indexes maintained
• Triggers not executed
• Number of migrated rows may be reduced.
• Rebuilding secondary indexes on IOTs recommended

Index ble
fe r a
ans
n - t r
Table Shrink a no
a s DBA
) h i d eฺ
m
o t Gu
Triggers not executed ilฺc
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Results of Shrink Operationk i
a s yu ense
Shrinking a sparsely
y M l ic segment improves the performance of scan and DML operations
populated
e
on that segment.
nlThis This is because there are fewer blocks to look at after the segment has been
S t a
shrunk. is especially true for:
• Full table scans (fewer and denser blocks)
• Better index access (fewer I/Os on range ROWID scans due to a more compact tree)
Also, by shrinking sparsely populated segments, you enhance the efficiency of space utilization
inside your database because more free space is made available for objects in need.
Index dependency is taken care of during the segment shrink operation. The indexes are in a
usable state after shrinking the corresponding table. Therefore, no further maintenance is
needed.
The actual shrink operation is handled internally as an INSERT/DELETE operation. However,
any DML triggers are not executed because the data itself is not changed.
As a result of a segment shrink operation, it is possible that the number of migrated rows is
reduced. However, you should not always depend on reducing the number of migrated rows after
a segment has been shrunk. This is because a segment shrink operation may not touch all the
blocks in the segment. Therefore, it is not guaranteed that all the migrated rows are handled.
Note: It is recommended to rebuild secondary indexes on an index-organized table (IOT) after a
shrink operation.

Oracle Database 11g: Administration Workshop II 16 - 13


Computer Pride Limited

Reclaiming Space Within ASSM Segments

• Online and in-place operation


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Applicable only to segments residing in ASSM tablespaces


• Candidate segment types:
– Heap-organized tables and index-organized tables
– Indexes
– Partitions and subpartitions
– Materialized views and materialized view logs
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Space Reclamation u k i (ASSM
with
a s y ense
A shrink operation
y c and in-place operation because it does not need extra database
M is anlionline
space ntole
be executed.
t a
S• You cannot execute a shrink operation on segments managed by free lists. Segments in
automatic segment space–managed tablespaces can be shrunk. However, the following
objects stored in ASSM tablespaces cannot be shrunk:
- Tables in clusters
- Tables with LONG columns
- Tables with on-commit materialized views
- Tables with ROWID-based materialized views
- IOT mapping tables
- Tables with function-based indexes
• ROW MOVEMENT must be enabled for heap-organized segments.

Oracle Database 11g: Administration Workshop II 16 - 14


Computer Pride Limited

Segment Advisor: Overview


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Segment Advisor: Overview k i
a s yu ense
The Segment M
y l ic
Advisor identifies segments that have space available for reclamation. It performs

t
(AWR),a nleandbybyexamining
its analysis
sampling
usage and growth statistics in the Automatic Workload Repository
the data in the segment. It is configured to run automatically at regular
S
intervals, and you can also run it on demand (manually). The regularly scheduled Segment
Advisor run is known as the Automatic Segment Advisor.
After the recommendations are made, you can choose to implement the recommendations. The
shrink advisor can be invoked at the segment or tablespace level.
The EM Database Control Console is the interface to the Segment Advisor. You can access the
Segment Advisor from several places within EM:
• Advisor Central page
• Tablespaces page
• Schema object pages
The Database Control Console provides the option to select various inputs and schedule a job
that calls the Segment Advisor to get shrink advice. The Segment Advisor Wizard can be
invoked with no context, in the context of a tablespace, or in the context of a schema object.
The Segment Advisor makes recommendation on the basis of sampled analysis, historical
information, and future growth trends.

Oracle Database 11g: Administration Workshop II 16 - 15


Computer Pride Limited

Segment Advisor
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Segment Advisor uki
a s y ense
From the Server
y lic Tablespaces in the Storage section. On the Tablespaces page, select
M page, select
a n le on which you want to perform the shrink analysis, and then select Run Segment
the tablespace
t
Advisor
S in the Actions drop-down list. Click Go to open the Segment Advisor initial page. You
must choose “comprehensive” or “limited” analysis mode. In comprehensive mode, the analysis
is longer because the advisor is sampling the segments to identify the right targets.
Keep clicking Continue to answer the various questions of the advisor. You end up on the
Segment Advisor: Review page, where you can review the details of your analysis. The Segment
Advisor analysis is run as a scheduled job, so you can review the scheduled task from the
Advisor Central page. When completed, you can review the advisor’s recommendations.
Note: In the Segment Advisor, you can specify the duration of the analysis. This enables you to
limit the time the advisor takes to produce recommendations. Generally speaking, a longer
analysis period produces more comprehensive results. The results are stored in the AWR and can
be viewed later. Use the “Number of days to retain” option to instruct the Oracle database server
how long these results should be preserved before being purged from the AWR.

Oracle Database 11g: Administration Workshop II 16 - 16


Computer Pride Limited

Implementing Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Implementing Recommendationsi
a s yu ense
After the Segment
y M Advisor lic completes its job, you can view the recommendation details and
t a nle them directly.
implement
S Before shrinking a heap-organized table, you must enable row movement on that table.
Note:
You can do this with Database Control from the Options tab on the Edit Table page.

Oracle Database 11g: Administration Workshop II 16 - 17


Computer Pride Limited

Automatic Segment Advisor

The Automatic Segment Advisor:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Is started by a Scheduler job set to run during the default


maintenance window:
– Weeknights, Monday–Friday, from 10:00 PM to 2:00 AM
– Saturday and Sunday, both windows start at 6:00 AM and last
for 20 hours
• Examines database statistics, samples segment data, and
then selects the following objects to analyze: e
– Tablespaces that have exceeded a critical or warning r a bl
ns fe
threshold t r a
o n -
– Segments that have the most activity
s an
a
– Segments that have the highest growth hrate ฺ
m ) u i de
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Automatic Segment u
y ki se to
Advisor
The Automatic M as licAdvisor
Segment en is started by a Scheduler job that is configured to run during
l
the default
n eymaintenance window. The default maintenance window is specified in the Scheduler,
Stais initially defined as follows:
and
• Weeknights, Monday through Friday, from 10:00 PM to 2:00 AM (4 hours each night)
• Weekends, Saturday and Sunday morning at 6:00 AM and lasting for 20 hours each day.
The Automatic Segment Advisor does not analyze every database object. Instead, it examines
database statistics, samples segment data, and then selects the following objects to analyze:
• Tablespaces that have exceeded a critical or warning space threshold
• Segments that have the most activity
• Segments that have the highest growth rate
If an object is selected for analysis but the maintenance window expires before the Segment
Advisor can process the object, the object is included in the next Automatic Segment Advisor
run. You cannot change the set of tablespaces and segments that the Automatic Segment Advisor
selects for analysis. You can, however, enable or disable the Automatic Segment Advisor job,
change the times during which the Automatic Segment Advisor is scheduled to run, or adjust
Automatic Segment Advisor system resource utilization.

Oracle Database 11g: Administration Workshop II 16 - 18


Computer Pride Limited

Manual Segment Shrink Using EM


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Manual Segment Shrink k i
u Using e EM
s y n s
Alternatively M(toaimplementing
l i c e the Segment Advisor recommendations), you can shrink
l
individual
n eysegments associated with specific database objects. For example, from the Database
Sta page, select the Schema folder tab then click the Tables link in the Database Objects
Home
section. On the Tables page, select your table, and then select Shrink Segment in the Actions
drop-down list. Then click the Go button. This brings you to the Shrink Segment page, where
you can choose the dependent segments to shrink. You have the opportunity to compact only or
to compact and release the space. You can also choose the CASCADE option.
When done, click the Continue link. This submits the shrink statements as a scheduled job.

Oracle Database 11g: Administration Workshop II 16 - 19


Computer Pride Limited

Shrinking Segments Using SQL

ALTER … SHRINK SPACE [CASCADE][COMPACT]


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

TABLE [OVERFLOW] INDEX MATERIALIZED VIEW MATERIALIZED VIEW LOG

MODIFY PARTITION MODIFY SUBPARTITION MODIFY LOB

1 ALTER TABLE employees ENABLE ROW MOVEMENT;


e
r a bl
s fe
2 ALTER TABLE employees SHRINK SPACE CASCADE;
- t r an
ALTER TABLE employees MODIFY LOB(resume) (SHRINK
n
no
3 s a
SPACE);
) h a eฺ
m u i d
4 ALTER TABLE employees OVERFLOWฺcSHRINK
l o t SPACE;
G
i
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Shrinking SegmentsuUsingk i (MSQL t o
a s y ense
Because a shrink
y M l ic may cause ROWIDs to change in heap-organized segments, you must
operation

t a nleRow
enable row
segment.
movement on the corresponding segment before executing a shrink operation on that
movement by default is disabled at segment level. To enable row movement, the
S
ENABLE ROW MOVEMENT clause of the CREATE TABLE or ALTER TABLE command is
used. This is illustrated in the first example in the slide.
Use the ALTER command to invoke segment shrink on an object. The object’s type can be one
of the following: table (heap- or index-organized), partition, subpartition, LOB (data and index
segment), index, materialized view, or materialized view log.
Use the SHRINK SPACE clause to shrink space in a segment. If CASCADE is specified, the
shrink behavior is cascaded to all the dependent segments that support a shrink operation, except
materialized views, LOB indexes, and IOT (index-organized tables) mapping tables. The
SHRINK SPACE clause is illustrated in the second example.
In an index segment, the shrink operation coalesces the index before compacting the data.
Example 3 shows a command that shrinks a LOB segment, given that the RESUME column is a
CLOB.
Example 4 shows a command that shrinks an IOT overflow segment belonging to the
EMPLOYEES table.
Note: For more information, refer to the Oracle Database SQL Reference guide.

Oracle Database 11g: Administration Workshop II 16 - 20


Computer Pride Limited

Managing Resumable
Space Allocation
A resumable statement:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Enables you to suspend large operations instead of


receiving an error
• Gives you a chance to fix the problem while the operation is
suspended, rather than starting over
• Is suspended for the following conditions:
– Out of space
– Maximum extents reached bl e
fe r a
– Space quota exceeded
t r a ns
• A resumable statement can be suspended and resumed
o n -
multiple times.
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Managing Resumable u i
kSpace to
Allocation
e
y
as server n s
eprovides
The Oracle database
y M l i c a means for suspending, and later resuming, the execution

t a n eaction instead
of large ldatabase
corrective
operations in the event of space allocation failures. This enables you to take
of the Oracle database server returning an error to the user. After the
S
error condition is corrected, the suspended operation automatically resumes. This feature is
called “resumable space allocation.” The statements that are affected are called “resumable
statements.” A statement executes in resumable mode only when the resumable statement
feature has been enabled for the system or session.
Suspending a statement automatically results in suspending the transaction. Thus all
transactional resources are held through the suspension and resuming of a SQL statement. When
the error condition disappears (for example, as a result of user intervention or perhaps sort space
released by other queries), the suspended statement automatically resumes execution. A
resumable statement is suspended when one of the following conditions occur:
• Out of space condition
• Maximum extents reached condition
• Space quota exceeded condition
A suspension time-out interval is associated with resumable statements. A resumable statement
that is suspended for the time-out interval (the default is 2 hours) reactivates itself and returns
the exception to the user. A resumable statement can be suspended and resumed multiple times.
Note: A maximum extents reached error only happens with dictionary-managed tablespaces.
Oracle Database 11g: Administration Workshop II 16 - 21
Computer Pride Limited

Using Resumable Space Allocation

• Queries, DML operations, and certain DDL operations can


be resumed if they encounter an out-of-space error.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• A resumable statement can be issued through SQL,


PL/SQL, SQL*Loader and Data Pump utilities, or the Oracle
Call Interface (OCI).
• A statement executes in a resumable mode only if its
session has been enabled by one of the following actions:
– The RESUMABLE_TIMEOUT initialization parameter is set to a
nonzero value.
a b le
– An ALTER SESSION ENABLE RESUMABLE statement is sfer
n
issued: -tra on
ALTER SESSION ENABLE RESUMABLE; a n
a s
INSERT INTO sales_new SELECT * FROM
i d eฺ
) h sh.sales;
ALTER SESSION DISABLE RESUMABLE; m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Resumable Space k i
u Allocation
a s y e n se
Resumable space
y lic is possible only when statements are executed within a session that
M allocation
a n le mode enabled. There are two means of enabling and disabling resumable space
has resumable
t
allocation:
S
• Issue the ALTER SESSION ENABLE RESUMABLE command.
• Set the RESUMABLE_TIMEOUT initialization parameter to a nonzero value with an ALTER
SESSION or ALTER SYSTEM statement.
When enabling resumable mode for a session or the database, you can specify a time-out period,
after which a suspended statement errors out if no intervention has taken place. The
RESUMABLE_TIMEOUT initialization parameter indicates the number of seconds before a time-
out occurs. You can also specify the time-out period with the following command:
ALTER SESSION ENABLE RESUMABLE TIMEOUT 3600;
The value of TIMEOUT remains in effect until it is changed by another ALTER SESSION
ENABLE RESUMABLE statement, it is changed by another means, or the session ends. The
default time-out interval when using the ENABLE RESUMABLE TIMEOUT clause to enable
resumable mode is 7,200 seconds, or 2 hours.

Oracle Database 11g: Administration Workshop II 16 - 22


Computer Pride Limited

Using Resumable Space Allocation (continued)


You can also give a name to resumable statements. For example:
ALTER SESSION ENABLE RESUMABLE TIMEOUT 3600
NAME 'multitab insert';
The name of the statement is used to identify the resumable statement in the DBA_RESUMABLE
and USER_RESUMABLE views.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

For example:
SELECT name, sql_text FROM user_resumable;

NAME SQL_TEXT
--------------- --------------------------------------------
multitab insert INSERT INTO oldsales SELECT * FROM sh.sales;
To automatically configure resumable statement settings for individual sessions, you can create
and register a database-level LOGON trigger that alters a user’s session. The trigger issues
commands to enable resumable statements for the session, specifies a time-out period, and
associates a name with the resumable statements issued by the session. a b le
s fer
Because suspended statements can hold up some system resources, users must beagranted n the
tr allocation
RESUMABLE system privilege before they are allowed to enable resumable n
o -
space and
execute resumable statements.
s an
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 16 - 23


Computer Pride Limited

Resuming Suspended Statements


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1 SQL statement

Full table

2 Suspended

Continue
SQL 3 Optionally 4 ble
operation
fe r a
ans
n - t r
5 Table AFTER
a no
with free
space
SUSPEND
triggerm)
has ideฺ Abort

i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Resuming Suspending k iStatements
a s yu ense
Example: M
y statementlic encounters an error saying the table is full.
e
1. An lINSERT
n
S2.taThe INSERT statement is suspended, and no error is passed to client.
3. Optionally, an AFTER SUSPEND trigger is executed.
4. Optionally, the SQLERROR exception is activated to abort the statement.
5. If the statement is not aborted and free space is successfully added to the table, the INSERT
statement resumes execution.
Detecting a Suspended Statement
When a resumable statement is suspended, the error is not raised to the client. In order for
corrective action to be taken, the Oracle database server provides alternative methods for
notifying users of the error and for providing information about the circumstances.

Oracle Database 11g: Administration Workshop II 16 - 24


Computer Pride Limited

Resuming Suspended Statements (continued)


Possible Actions During Suspension
When a resumable statement encounters a correctable error, the system internally generates the
AFTER SUSPEND system event. Users can register triggers for this event at both the database
and schema level. If a user registers a trigger to handle this system event, the trigger is executed
after a SQL statement has been suspended. SQL statements executed within an AFTER
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SUSPEND trigger are always nonresumable and are always autonomous. Transactions started
within the trigger use the SYSTEM rollback segment. These conditions are imposed to overcome
deadlocks and reduce the chance of the trigger experiencing the same error condition as the
statement.
Within the trigger code, you can use the USER_RESUMABLE or DBA_RESUMABLE views, or
the DBMS_RESUMABLE.SPACE_ERROR_INFO function to get information about the
resumable statements.
When a resumable statement is suspended:
• The session invoking the statement is put into a wait state. A row is inserted into
a b le
V$SESSION_WAIT for the session with the EVENT column containing “statement
s fer
suspended, wait error to be cleared”.
- t r an
• An operation-suspended alert is issued on the object that needs addition
n onresources for the
suspended statement to complete. s a
Ending a Suspended Statement
a
) h uideฺ
m
When the error condition is resolved (for example, ias
a lฺca oresult
e n t
of G
DBA intervention or perhaps
gm Sstatement
sort space released by other queries), the suspended
@ t ud automatically resumes execution
and the “resumable session suspended”kalert
u i is cleared.
is
s y t h
A suspended statement can be forced
( M se the SERVERERROR exception by using the
a touactivate
DBMS_RESUMABLE.ABORT()
u to
ki seprocedure. This procedure can be called by a DBA, or by the
user who issued athe y
s statement.
e n If the suspension time-out interval associated with the resumable
statement is M l i c
y reached, the statement aborts automatically and an error is returned to the user.
n le
Sta

Oracle Database 11g: Administration Workshop II 16 - 25


Computer Pride Limited

What Operations Are Resumable?

The following operations are resumable:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Queries: SELECT statements that run out of temporary


space (for sort areas)
• DML: INSERT, UPDATE, and DELETE statements
• The following DDL statements:
— CREATE TABLE ... AS SELECT
— CREATE INDEX
— ALTER INDEX ... REBUILD
a b le
— ALTER TABLE ... MOVE PARTITION
s fer
— ALTER TABLE ... SPLIT PARTITION
- t r an
— ALTER INDEX ... REBUILD PARTITION n on
ALTER INDEX ... SPLIT PARTITION as a

CREATE MATERIALIZED VIEW m)


h ideฺ

u o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to
What Operations Are
y u kResumable?
s e
The followingM as licare
operations enresumable:
l ey SELECT statements that run out of temporary space (for sort areas) are candidates
• Queries:
n
Stafor resumable execution. When using OCI, the OCIStmtExecute() and
OCIStmtFetch() calls are candidates.
• DML: INSERT, UPDATE, and DELETE statements are candidates. The interface used to
execute them does not matter; it can be OCI, SQLJ, PL/SQL, or another interface. Also,
INSERT INTO...SELECT from external tables can be resumable.
• DDL: The following statements are candidates for resumable execution:
- CREATE TABLE ... AS SELECT
- CREATE INDEX
- ALTER INDEX ... REBUILD
- ALTER TABLE ... MOVE PARTITION
- ALTER TABLE ... SPLIT PARTITION
- ALTER INDEX ... REBUILD PARTITION
- ALTER INDEX ... SPLIT PARTITION
- CREATE MATERIALIZED VIEW

Oracle Database 11g: Administration Workshop II 16 - 26


Computer Pride Limited

Transporting Tablespaces

• Cross-platform transportable tablespaces:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

– Simplify moving data between data warehouse and data


marts
– Allow database migration from one platform to another
• Supported platforms include:
Solaris[tm] OE (32-bit) HP-UX (64-bit) Microsoft Windows IA (64-bit)

Solaris[tm] OE (64-bit) HP Tru64 UNIX IBM zSeries Based Linux

ble
Microsoft Windows IA (32-bit) HP-UX IA (64-bit) Linux 64-bit for AMD
fe r a
Linux IA (32-bit) Linux IA (64-bit) Apple Mac OS ans
n - t r
AIX-Based Systems (64-bit) HP Open VMS no
Microsoft Windows 64-bit AMD
a
a s
IBM Power Based Linux HP IA Open VMS ) h
Solaris x86 and
i d eฺAMD64
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transporting Tablespacesk i
a s yu ense
TransportableM
y licis the fastest way for moving large volumes of data between two
tablespace

a le
Oraclendatabases. Using transportable tablespaces, Oracle data files (containing table data,
S t
indexes, and almost every other Oracle database object) can be directly transported from one
database to another. Furthermore, like import and export, transportable tablespaces provide a
mechanism for transporting metadata in addition to transporting data.
You can use the transportable tablespace feature to move data across platform boundaries. This
simplifies the distribution of data from a data warehouse environment to data marts, which often
run on smaller platforms. It also allows a database to be migrated from one platform to another
by rebuilding the dictionary and transporting the user tablespaces.
Moving data using transportable tablespaces is much faster than performing either an
export/import or unload/load of the same data. This is because the data files containing all of the
actual data are just copied to the destination location, and you use Data Pump to transfer only the
metadata of the tablespace objects to the new database.
To be able to transport data files from one platform to another, you must ensure that both the
source system and the target system are running on one of the supported platforms (see slide).
Note: The cross-platform transportable tablespace feature requires both platforms to be using the
same character sets.

Oracle Database 11g: Administration Workshop II 16 - 27


Computer Pride Limited

Concept: Minimum Compatibility Level

• Both source and target databases must have COMPATIBLE


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

set to 10.0.0 or higher.


• Data file headers are platform-aware.
• Before transporting, make sure that all read-only and offline
files are platform-aware.

ble
Read/ Read/
fe r a
write write s
- t r an
n
no
Read- Read- Read/s a Read-
only only h a ฺ
) writeuide only
m
COMPATIBLE=9.2.0 a ฺco nt G
ilCOMPATIBLE=10.0.0
g m tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Concept: Minimum Compatibility i
u nse Level
s y
atarget ldatabases
e need to advance their database COMPATIBLE initialization
Both source and M i c
parameter
n l eyto 10.0.0 or greater before they can use the cross-platform transportable tablespace
Sta
feature.
When data files are first opened under Oracle Database 10g or 11g with COMPATIBLE set to
10.0.0 (or greater), the files are made platform-aware. This is represented by the check marks
in the diagram. Each file identifies the platform that it belongs to. These files have identical on-
disk formats for file header blocks that are used for file identification and verification. Read-
only and offline files get the compatibility advanced only after they are made read/write or are
brought online. This implies that tablespaces that are read-only in databases before Oracle
Database 10g must be made read/write at least once before they can use the cross-platform
transportable feature.

Oracle Database 11g: Administration Workshop II 16 - 28


Computer Pride Limited

Minimum Compatibility Level


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Minimum Compatibility Setting


Source Database Target Database
Transport Scenario
Databases on the same platform 8.0 8.0
Tablespace with different database block 9.0 9.0
size than the target database
Databases on different platforms 10.0 10.0 ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Minimum Compatibility k i Level
a s yu ense
When you create
y lic
M a transportable tablespace set, Oracle Database computes the lowest

a n le level at which the target database must run. This is referred to as the compatibility
compatibility
t
level
S of the transportable set. Beginning with Oracle Database 11g, a tablespace can always be
transported to a database with the same or higher compatibility setting, whether the target
database is on the same or a different platform. The database signals an error if the compatibility
level of the transportable set is higher than the compatibility level of the target database.
The above table shows the minimum compatibility requirements of the source and target
tablespace in various scenarios. The source and target database need not have the same
compatibility setting.
When data files are first opened, each file identifies the platform that it belongs to. These files
have identical on-disk formats for file header blocks that are used for file identification and
verification. Read-only and offline files get the compatibility advanced only after they are made
read/write or are brought online.

Oracle Database 11g: Administration Workshop II 16 - 29


Computer Pride Limited

Transportable Tablespace Procedure

Source Make tablespaces read-only.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Use Data Pump to extract metadata.

Target
uses the same No
endian format?
Convert data files
by using RMAN.
Yes
ble
fe r a
Ship data files and dump file to target. ans
n - t r
n o
Use Data Pump to import metadata. s a
) h a eฺ
m i d
Target Make tablespaces c
l ฺ o t Gu
read/write.
i
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespace k i
u nProcedure
a s y e se
To transport aM
y licfrom one platform to another (source to target), data files belonging to
tablespace

a n le set must be converted to a format that can be understood by the target or


the tablespace
S t
destination database. Although with Oracle Database, disk structures conform to a common
format, it is possible for the source and target platforms to use different endian formats (byte
ordering). When going to a different endian platform, you must use the CONVERT command of
the RMAN utility to convert the byte ordering. This operation can be performed on either the
source or the target platforms. For platforms that have the same endian format, no conversion is
needed.
The slide graphic depicts the possible steps to transport tablespaces from a source platform to a
target platform. However, it is possible to perform the conversion after shipping the files to the
target platform. The last two steps must be executed on the target platform.
Basically, the procedure is the same as when using previous releases of the Oracle database
server except when both platforms use different endian formats. It is assumed that both
platforms are cross-transportable compliant.
Note: Byte ordering can affect the results when data is written and read. For example, the 2-byte
integer value 1 is written as 0x0001 on a big-endian system (such as Sun SPARC Solaris) and
as 0x0100 on a little-endian system (such as an Intel-compatible PC).

Oracle Database 11g: Administration Workshop II 16 - 30


Computer Pride Limited

Determining the Endian Format


of a Platform
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SELECT tp.endian_format
FROM v$transportable_platform tp, v$database d
WHERE tp.platform_name = d.platform_name;

ble
fe r a
Source Target ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Determining the Endian k i
u nse of a Platform
Format
s y
a lice
You can query MV$TRANSPORTABLE_PLATFORM to determine whether the endian ordering is
y
the sameleon both platforms. V$DATABASE has two columns that can be used to determine your
n
Staplatform name and platform identifier. Run the query below for a comprehensive list of
own
supported platforms and their endian formats:
SQL> SELECT * FROM V$TRANSPORTABLE_PLATFORM;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- -------------------------------- --------------
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
10 Linux IA (32-bit) Little
6 AIX-Based Systems (64-bit) Big
3 HP-UX (64-bit) Big
5 HP Tru64 UNIX Little
4 HP-UX IA (64-bit) Big
11 Linux IA (64-bit) Little
15 HP Open VMS Little

Oracle Database 11g: Administration Workshop II 16 - 31


Computer Pride Limited

Determining the Endian Format of a Platform (continued)


PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- -------------------------------- --------------
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
13 Linux 64-bit for AMD Little
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

16 Apple Mac OS Big


12 Microsoft Windows 64-bit for AMD Little
17 Solaris Operating System (x86) Little
18 IBM Power Based Linux Big
19 HP IA Open VMS Little
20 Solaris Operating System (AMD64) Little

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 16 - 32


Computer Pride Limited

Transportable Tablespaces with


Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespacesk i
u nswith e Enterprise Manager
s y
a canlibe eused to implement transportable tablespaces. From the Database
Enterprise Manager
M c
home n l eyclick the Data Movement folder tab, and then click Transport Tablespaces under the
page,
Sta Database Files section. Select “Generate a transportable table set” and provide the login
Move
credentials for the oracle user, and then click Continue. On the Select Tablespaces page, add
the tablespaces you want to transport from the displayed list by clicking the Tablespace button,
and then clicking Add. Near the bottom of the page, you must select the level of containment
checking to be done before the tablespaces are processed. The containment check looks for
object dependencies within the tablespaces. When you have finished, click Next. Wait a few
moments while the containment check runs. Address any issues found by the check before
continuing.

Oracle Database 11g: Administration Workshop II 16 - 33


Computer Pride Limited

Transportable Tablespaces with


Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespacesk i
u nswith e Enterprise Manager (continued)
s y
a Characteristics
e
On the Destination
y M l i c page, you must supply the destination platform and character

a n le the Destination Database Platform section, select the operating system of the
sets. Under
S t
destination machine from the drop-down list. If the destination platform is different from the
source platform, Enterprise Manger will perform a data conversion. Continue to the Destination
Character Set section of the page and choose the destination character set and national character
set from the drop-down lists. These character sets must be compatible with the source sets.
When you click Next to continue, Enterprise Manager checks the compatibility of the character
sets. If the chosen character sets are flagged as incompatible, you will be returned back to the
Destination Characteristics page to correct your selections.

Oracle Database 11g: Administration Workshop II 16 - 34


Computer Pride Limited

Transportable Tablespaces with


Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespaces k i
u nswith e Enterprise Manager (continued)
s y
apage, supplye a meaningful description for the default job name. You can also
On the ScheduleM l i c
y the job immediately or schedule it for later execution. When you have made your
l
choosento estart
Sta click Next to continue. On the review page, you can verify your choices before
selections,
submitting the job for execution. Click the Submit Job button if the entries are correct. Click the
Back button to correct any incorrect entries.

Oracle Database 11g: Administration Workshop II 16 - 35


Computer Pride Limited

Transporting Databases

• Generalize the transportable tablespace feature.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Data subsets can easily be distributed from a data


warehousing environment to data marts, which are usually
on smaller platforms.
• A database can be migrated from one platform to another
very quickly.

Platform X Platform Y ble


Same “endianness”
fe r a
ans
n - t r
a no
Database files transfer as
m ) h uideฺ
o G database
Existing database
a ilฺc entNew
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Transporting Databases
y u ki se to
You can use the
s centablespace feature to migrate a database to a different platform by
atransportable
y databaselion the destination platform and performing a transport of all the user
M
creatinglaenew
n You cannot transport the SYSTEM tablespace. Therefore, objects such as sequences,
Sta
tablespaces.
PL/SQL packages, and other objects that depend on the SYSTEM tablespace are not transported.
You must either create these objects manually on the destination database, or use Data Pump to
transport the objects that are not moved by transportable tablespace.
To transport databases from one platform to another, you must ensure that both the source
system and the target system are running on one of the platforms that are listed in
V$TRANSPORTABLE_PLATFORM and that both have the same endian format. For example,
you can transport a database running on Linux IA (32-bit) to one of the Windows platforms.
If one or both of the databases uses Automatic Storage Management (ASM), you may need to
use the DBMS_FILE_TRANSFER package to FTP the files.
Unlike transportable tablespace, where there is a target database to plug data into, this feature
creates a new database on the target platform. The newly created database contains the same
data as the source database. Except for things such as database name, instance name, and
location of files, the new database also has the same settings as the source database.
Note: Transporting database is faster than using Data Pump to move data.

Oracle Database 11g: Administration Workshop II 16 - 36


Computer Pride Limited

Database Transportation Procedure:


Source System Conversion
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Open database in READ ONLY mode


and COMPATIBLE=10.0.0 or higher.

Ship
Read- Read- Read- Read-
only only files only only
CONVERT
DATABASE
ble
TO PLATFORM
fe r a
ans
n - t r
o
Source
s an
Target
system ha systemฺ
ide
)
m
c nt Gu
o
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Database Transportation k i
u Procedure:
e Source System Conversion
s y
a licyour n s
e database, you must open it in READ ONLY mode. Then use
Before you can
M transport
RMAN n l eyconvert the necessary data files of the database.
to
Sta you do the conversion on the source platform, the RMAN CONVERT DATABASE
When
command generates a script containing the correct CREATE CONTROLFILE RESETLOGS
command that is used on the target system to create the new database. The CONVERT
DATABASE command then converts all identified data files so that they can be used on the
target system. You then ship the converted data files and the generated script to the target
platform. By executing the generated script on the target platform, you create a new copy of
your database.
Note: The source database must be running with the COMPATIBLE initialization parameter set
to 10.0.0 or higher. All identified tablespaces must have been READ WRITE at least once
since the time that COMPATIBLE was set to 10.0.0 or higher.

Oracle Database 11g: Administration Workshop II 16 - 37


Computer Pride Limited

Database Transportation Procedure:


Target System Conversion
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Open database in READ ONLY mode


and COMPATIBLE=10.0.0 or higher

CONVERT
DATABASE Read- Ship Read- Read- Read-
ON DESTINATION only only only only
files
PLATFORM
ble
fe r a
Source Target ans
tr
system on-
system
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Database Transportationu e to Target System Conversion
ki Procedure:
y
as licyour s
en database, you must open it in READ ONLY mode. Then use
Before you can
M transport
RMAN n l eyconvert the necessary data files of the database.
to
Sta you do the conversion on the target platform, the CONVERT DATABASE command
When
(which is executed on the source system) generates only two scripts used on the target system to
convert the data files, and to re-create the control files for the new database. Then, you ship the
identified data files and both scripts to the target platform. After this is done, execute both
scripts in the right order. The first one uses the existing RMAN CONVERT DATAFILE
command to do the conversion, and the second issues the CREATE CONTROLFILE
RESETLOGS SQL command with the converted data files to create the new database.
Note: The source database must be running with the COMPATIBLE initialization parameter set
to 10.0.0 or higher. All identified tablespaces must have been READ WRITE at least once
since COMPATIBLE was set to 10.0.0 or higher.

Oracle Database 11g: Administration Workshop II 16 - 38


Computer Pride Limited

Database Transportation: Considerations

• Create the password file on the target platform.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Transport the BFILEs used in the source database.


• The generated PFILE and transport script use OMF.
• Use DBNEWID to change the DBID.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Database Transportation: k i
u nConsiderations
a s y e se
Redo logs, control
y c tempfiles are not transported. They are re-created for the new
M files,liand
database
a n leon the target platform. As a result, the new database on the target platform must be
t
opened
S with the RESETLOGS option.
If a password file is used, it is not transported and you need to create it on the target platform.
This is because the types of file names allowed for the password file are OS specific. However,
the output of the CONVERT DATABASE command lists all the usernames and their system
privileges, and advises to re-create the password file and add entries for these users on the target
platform.
The CONVERT DATABASE command lists all the directory objects and objects that use BFILE
data types or external tables in the source database. You may need to update these objects with
new directory and file names. If BFILEs are used in the database, you have to transport the
BFILEs.
The generated PFILE and transport script use Oracle Managed Files (OMF) for database files. If
you do not want to use OMF, you must modify the PFILE and transport script.
The transported database has the same DBID as the source database. You can use the DBNEWID
utility to change the DBID. In the transport script as well as the output of the CONVERT
DATABASE command, you are prompted to use the DBNEWID utility to change the database ID.

Oracle Database 11g: Administration Workshop II 16 - 39


Computer Pride Limited

Summary

In this lesson, you should have learned how to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Use the Oracle database server to automatically manage


space
• Proactively monitor and manage tablespace space usage
• Use the Segment Advisor
• Reclaim wasted space from tables and indexes by using the
segment shrink functionality
• Manage resumable space allocation a b le
• Describe the concepts of transportable tablespaces and s fer
- t r an
databases on
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 16 - 40


Computer Pride Limited

Practice 16 Overview:
Managing Storage
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Using threshold alerts to proactively manage tablespaces


• Using the Segment Advisor to shrink space
• Viewing alerts and alert history in SQL*Plus and Enterprise
Manager

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 16 - 41


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Managing Resources

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to do the


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

following:
• Configure the Database Resource Manager
• Access and create resource plans
• Create consumer groups
• Specify directives for allocating resources to consumer
groups
• Map consumer groups to plans a b le
• Activate a resource plan s fer
- t r an
• Monitor the Resource Manager non a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 17 - 2


Computer Pride Limited

Database Resource Manager: Overview

Use the Resource Manager to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Manage mixed workload


• Control system performance

Database
Resource Manager
More resources e
OLTP users
r a bl
s fe
DSS users
Fewer resources - t r an
n
no
Batch users s a
h a eฺ Oracle
Least resourcesm) i d
i l ฺ co nt Gu database
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Database Resource u k
Manager: to u
i (M eOverview
a sy Resource
e n s
By using the Database
y M lic Manager (also called the Resource Manager), you have more
le the allocation of machine resources than is normally possible through operating
controlnover
a
t
system
S resource management alone. If resource management decisions are made by the
operating system, it can lead to problems such as:
• Excessive overhead resulting from operating system context switching of Oracle database
server processes when the number of server processes is high
• Suspension of a database server process that is holding a latch
• Unequal distribution of resources among all Oracle database processes, and an inability to
prioritize one task over another
• Inability to manage database-specific resources, such as parallel execution servers and
active sessions
The Database Resource Manager controls the distribution of resources among various sessions
by controlling the execution schedule inside the database. By controlling which sessions run and
for how long, the Database Resource Manager can ensure that resource distribution matches the
plan directive and, therefore, the business objectives. With the Database Resource Manager, you
can guarantee groups of users a minimum amount of processing resources regardless of the load
on the system and the number of users.

Oracle Database 11g: Administration Workshop II 17 - 3


Computer Pride Limited

Database Resource Manager: Concepts

User groups or sessions


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Resource
consumer with similar resource needs
group
A blueprint for resource
allocation among resource
consumer groups (one
Resource plan
active plan)

ble
Specifies how a resource iss fe r a
divided among the resource
- t r an
on the
consumer groupsn(within
Resource plan s a
scope of allocation
directives
a
) h uideฺ
methods)
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Database Resource u
y ki seConcepts
Manager:
as lby
AdministeringMsystems i c n the Database Resource Manager involves the use of resource
eusing
n l ey consumer groups, and resource plan directives.
plans, resource
ta
ASresource consumer group defines a set of users or sessions that have similar requirements for
using system and database resources.
A resource plan specifies how the resources are distributed among various resource consumer
groups. The Database Resource Manager also allows for creation of plans within plans, called
subplans.
Resource plan directives specify how a particular resource is shared among consumer groups or
subplans. You associate resource consumer groups and subplans with a particular resource plan
through plan directives.
Resource allocation methods determine what policy to use when allocating for any particular
resource. Resource allocation methods are used by resource plans and resource consumer
groups.

Oracle Database 11g: Administration Workshop II 17 - 4


Computer Pride Limited

Why Use Resource Manager

• You can manage database and operating system resources,


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

such as:
– CPU usage
– Degree of parallelism
– Number of active sessions
– Undo generation
– Operation execution time
– Idle time e
r a bl
• You can also specify criteria that, if met, cause the automatic
n s fe
switching of sessions to another consumer group. -tra
n on
s a
a
) h uideฺ
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Why Use Resource Manager
y u ki se to
The DatabaseM as liManager
Resource c en provides several means of allocating resources:
• CPU l y
eMethod: Enables you to specify how CPU resources are allocated among consumer
t a n
S groups and subplans
• Degree of Parallelism Limit: Enables you to control the maximum degree of parallelism
for any operation within a consumer group
• Active Session Pool with Queuing: Allows you to limit the number of concurrent active
sessions for a consumer group or subplan. If a group exceeds the maximum allowed number
of sessions, new sessions are placed in a queue where they wait for an active session to
complete. You can also specify a time limit on how long a session will wait before exiting
with an error.
• Undo Pool: Enables you to control the total amount of undo that can be generated by a
consumer group or subplan. Whenever the total undo space exceeds the amount specified
by UNDO_POOL, no further INSERT, UPDATE, or DELETE commands are allowed until
undo space is freed by another session in the same group or the undo pool is increased for
the consumer group. If the consumer group’s quota is exceeded during the execution of a
DML statement, the operation aborts and returns an error. Queries are still allowed, even if
a consumer group has exceeded its undo threshold.

Oracle Database 11g: Administration Workshop II 17 - 5


Computer Pride Limited

Why Use Resource Manager (continued)


• Execution Time Limit: Allows you to specify a maximum execution time allowed for an
operation. The Oracle database uses cost-based optimizer statistics to estimate how long an
operation will take. If it is longer than the maximum time allowed
(MAX_EST_EXEC_TIME), the operation returns an error and is not started. If a resource
consumer group has more than one plan directive with MAX_EST_EXEC_TIME specified,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

the Resource Manager chooses the most restrictive of all incoming values.
• Idle Time Limit: Enables you to specify an amount of time for which a session can be idle,
after which it will be terminated (MAX_IDLE_TIME). You can further restrict the Resource
Manager to terminate only those sessions that are blocking other sessions
(MAX_IDLE_TIME_BLOCKER).
• Consumer Group Switching: The initial consumer group is the group that a session would
be in had it just logged in. The top call is defined as treating an entire PL/SQL block as one
call or, similarly, treating SQL statements that are issued separately by the client as separate
calls. This functionality is mostly beneficial for three-tier applications where the middle-tier
server implements session pooling. In this case, the middle tier tends to do one call foraan b le
end user and then use the same session for a call for a different end user. Therefore, f r
ethe
s
n affect the
anot
boundaries of work are really calls, and the actions of a prior end user should- t r
next end user. You can create a plan directive, so that the Resource n on automatically
Manager
switches the user back to the initial consumer group at the end a sofathe top call.
) h uand ฺ
deSWITCH_TIME
Note: You cannot specify both the SWITCH_TIME_IN_CALL
o m i
parameters within the same directive. The SWITCH_TIME G
ilฺc ent parameter is primarily intended
a
@ gm Stud
for client/server applications, while the SWITCH_TIME_IN_CALL parameter is for three-
tier applications. ki is
a syu se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 17 - 6


Computer Pride Limited

Accessing Resource Plans

Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

and PL/SQL

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Accessing ResourceuPlans k i (M e to u
a y ens
sManager
Using Enterprise
y M lic
l e
n Manager Database Control provides an easy-to-use graphical interface for
Enterprise
S t a
configuring resource plans, consumer groups, and so on. Select EM > Server, and then the item
you want to work with.
Using the DBMS_RESOURCE_MANAGER Package
This PL/SQL package comprises many procedures, including the following:
• CREATE_PLAN: Names a resource plan and specifies its allocation methods
• UPDATE_PLAN: Updates a resource plan’s comment
• DELETE_PLAN: Deletes a resource plan and its directives

Oracle Database 11g: Administration Workshop II 17 - 7


Computer Pride Limited

Default Maintenance Resource Manager Plan

SQL> show parameter resource_manager_plan


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NAME TYPE VALUE


---------------------- ------- ------------------------------------------
resource_manager_plan string SCHEDULER[0x2843]: DEFAULT_MAINTENANCE_PLAN

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
Default MaintenanceuResource
o u Plan
i (M e tManager
a sy centaskss
The automatedMmaintenance
li rely on the Resource Manager being enabled during the
y
le windows. When a maintenance window opens, the
maintenance
t a n resource manager plan is automatically set to control the
S
DEFAULT_MAINTENANCE_PLAN
amount of CPU used by automated maintenance tasks. To be able to give different priorities to
each possible task during a maintenance window, various consumer groups are assigned to
DEFAULT_MAINTENANCE_PLAN. The hierarchy between groups and plans is shown in the
slide.
For high priority tasks:
• Optimizer Statistics Gathering automatic task is assigned to the
ORA$AUTOTASK_STATS_GROUP consumer group.
• Segment Advisor automatic task is assigned to the ORA$AUTOTASK_SPACE_GROUP
consumer group.
• Automatic SQL Tuning automatic task is assigned to the ORA$AUTOTASK_SQL_GROUP
consumer group.
Note: If need be, you can manually change the percentage of CPU resources allocated to the
various automated maintenance task consumer groups inside
ORA$AUTOTASK_HIGH_SUB_PLAN.

Oracle Database 11g: Administration Workshop II 17 - 8


Computer Pride Limited

Example: DEFAULT_PLAN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Allocation Methods
Resource Consumer
Group MGMT_P1 MGMT_P2 MGMT_P3

SYS_GROUP 100% 0% 0%

OTHER_GROUPS 0% 90% 0%

ORA$AUTOTASK_SUB_PLA 0% 5% 0%
N
ble
0% 5% 0% fe r a
ORA$DIAGNOSTICS
ans
n - t r
For automated
a no
maintenance tasks
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Example: DEFAULT_PLAN k i
a s yu ense
The DEFAULT_PLAN
y M ic
lresource plan is one of the default plans provided for you. It contains

a n lefor the following provided consumer groups:


directives
t
S• SYS_GROUP: The initial consumer group for the SYS and SYSTEM users
• OTHER_GROUPS: Used for all sessions that belong to consumer groups that are not part of
the active resource plan. There must be a plan directive for OTHER_GROUPS in any active
plan.
• ORA$AUTOTASK_SUB_PLAN: A group with lower priority than SYS_GROUP and
OTHER_GROUPS in this plan
• ORA$DIAGNOSTICS: A group in this plan with the same priority as the
ORA$AUTOTASK_SUB_PLAN. The low priority of the ORA$ groups prevents any
automated maintenance work from consuming excessive amounts of system resources.
The initial consumer group of a user is the consumer group to which any session created by that
user initially belongs. If you have not set the initial consumer group for a user, the user’s initial
consumer group will automatically be DEFAULT_CONSUMER_GROUP.
The DEFAULT_PLAN and associated resource consumer groups can be used or not used. It can
be a template for new resource plans; it can be modified or deleted. Use it as appropriate for
your environment.

Oracle Database 11g: Administration Workshop II 17 - 9


Computer Pride Limited

Creating a New Resource Plan


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating a New Resource k i
u nPlan
a s y e se
To create a new
y licneed to configure several Resource Manager objects.
M plan, you
le > Server > Plans, and then click Create or choose “Create Like” and click Go.
SelectnEM
a
t
S Scheduler can automatically change the Resource Manager plan at the Scheduler window
The
boundaries. Deselect the default Automatic Plan Switching Enabled check box if this option is
unacceptable.

Oracle Database 11g: Administration Workshop II 17 - 10


Computer Pride Limited

Creating Consumer Groups


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

bl e
fe r a
t r a ns
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
o n -
CONSUMER_GROUP => 'APPUSER',
s an
MGMT_MTH => 'ROUND-ROBIN',
) ha ideฺ
COMMENT => '');
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Creating Consumer u
y ki se to
Groups
To manage a M as consumer
resource l i c en group, select EM > Server > Consumer Groups. Choose the
l eyyou want to perform. You can create a new resource consumer group or you can
actionnthat
Sta a resource consumer group from the results list and choose one of the actions from the
select
Actions drop-down list.
Use the Resource Consumer Groups page to create or edit the consumer group and description,
and to select users assigned to the group. You can add or delete members to the Selected Users
table.
The General property sheet (shown in the slide) is one of the two pages that make up the Create
Resource Consumer Group and Edit Resource Consumer Group pages. You can define or edit
which database roles are associated with the specified resource consumer group by moving to
the other property sheet (Roles).
You specify a resource allocation method for the distribution of CPU among sessions in the
consumer group. “Round Robin” scheduling ensures that sessions are fairly executed. Therefore,
the default allocation method is Round Robin. The “Run to Completion” allocation method
specifies that sessions with the largest active time are scheduled ahead of other sessions. The
equivalent functionality is achieved by the
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP procedure with the MGMT_MTH
option.
Oracle Database 11g: Administration Workshop II 17 - 11
Computer Pride Limited

Assigning Users to Consumer Groups


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Assigning Users to Groups i
a s yu ense
Users should M
y licto resource consumer groups. The user’s default consumer group is the
be assigned
le any session created by that user initially belongs. If it is not set for a user, the
one tonwhich
a
t
user’s
S initial consumer group defaults to DEFAULT_CONSUMER_GROUP.
You must directly grant to the user, or to PUBLIC, the switch privilege to a consumer group
before it can be the user’s default consumer group. The switch privilege cannot come from a role
granted to that user.
DBMS_RESOURCE_MANAGER.SET_INITIAL_CONSUMER_GROUP (
user => 'PM', consumer_group => 'APPUSER' );
The DBMS_RESOURCE_MANAGER_PRIVS package contains the procedure to assign resource
consumer groups to users. Granting the switch privilege to a user enables the user to switch to a
different consumer group.
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP (
grantee_name => 'PM',
consumer_group => 'APPUSER',
grant_option => FALSE );

Oracle Database 11g: Administration Workshop II 17 - 12


Computer Pride Limited

Specifying Resource Plan Directives

1 2 3 4 5 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Specifying ResourceuPlan k i (MDirectives
t o
se to create the resource plan or resource consumer groups,
sy cenManager
If you do not useaEnterprise
you must first li
y Mcreate a pending area. This is a scratch area that enables you to stage your
n l e
Sta and to validate them before they are made active.
changes
In Enterprise Manager, there are several property pages, which you can use for specifying plan
directives:
1. On the General page, associate consumer groups with plans and specify how much CPU
each consumer group or subplan gets with the MGMT_MTH value.
2. Specify a parallel degree limit to control the maximum degree of parallelism for any
operation within a consumer group.
3. You can control the maximum number of concurrently active sessions allowed within a
consumer group. An entire parallel execution session is counted as one active session.
4. You can control the amount of total undo that can be generated by a consumer group.
5. You can specify threshold values, such as execution time limit (in seconds), I/O limit (in
MB), and I/O request limit (in number of requests).
6. You can specify an amount of time that a session can be idle, after which it will be
terminated. You can further restrict such termination to only those sessions that are
blocking other sessions.
Note: The following slides provide further details about directives using the tab numbers
indicated in this slide. Refer to this slide when you see “Directive Tab n” on subsequent slides.

Oracle Database 11g: Administration Workshop II 17 - 13


Computer Pride Limited

Resource Allocation Methods for Resource Plans

Parameter Possible Values


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

(Comments)
MGMT_MTH EMPHASIS, RATIO

Allocating CPU usage

PARALLEL_DEGREE_LIMIT_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE

Limiting degree of parallelism of any operation

ble
ACTIVE_SESS_POOL_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE
fe r a
ans
Limiting number of active sessions, queuing inactive ones
n - t r
QUEUING_MTH FIFO_TIMEOUT a no
a s
h
) sessioni d eฺ
Controlling queues, how inactive sessions enter active m
co nt Gu
pool
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Resource AllocationuMethods k i (M efortoResource Plans
s y
a methods n s
e determine how the Resource Manager allocates a particular
Resource allocation
M l i c
resource
n l etoya resource consumer group or resource plan. You specify values for the following
Sta allocation methods when creating the resource plan.
resource
There are two ways of specifying the CPU distribution with the MGMT_MTH parameter:
• EMPHASIS is the default method for single-level plans. It is also used for multilevel plans
that use percentages to specify how CPU is distributed among consumer groups.
• RATIO is for single-level plans that use ratios to specify how CPU is distributed.

PARALLEL_DEGREE_LIMIT_MTH limits the maximum degree of parallelism of any


operation. This method can be specified only for resource consumer groups, not subplans. The
PARALLEL_DEGREE_LIMIT_ABSOLUTE method is the only possible value, specifying how
many processes may be assigned to an operation. If there are multiple plan directives referring to
the same subplan or consumer group, the minimum of all the possible values is used as the
parallel degree limit for that subplan or consumer group.
The ACTIVE_SESS_POOL_MTH parameter limits the number of active sessions. All other
sessions are inactive and wait in a queue to be activated. The only value (that is, the only
available method) for this parameter is ACTIVE_SESS_POOL_ABSOLUTE, which is its
default value.
QUEUING_MTH controls the order in which queued inactive sessions execute. FIFO_TIMEOUT
is the default and only method available.
Oracle Database 11g: Administration Workshop II 17 - 14
Computer Pride Limited

Comparison of EMPHASIS and RATIO


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

EMPHASIS RATIO

The value specifies the maximum The value specifies a number that indicates
percentage of CPU resources a the ratio of CPU resources to be allocated to
consumer group can use. the consumer group.
You can allocate resources for up to 8 You can specify values for only one level.
different levels.
The sum of percentages at any given You must use integer values, but there is no
level must be less than or equal to 100. limit on the sum of values.
ble
Default value is NULL. Default value is NULL. fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.

(M a u
Comparison of EMPHASIS k i and t o
a s yu ense RATIO
The CPU allocation
y M methodlic EMPHASIS determines how much emphasis is given to sessions in
different
a n leconsumer groups in a resource plan. CPU usage is assigned levels from 1 through 8,
t
with
S Level 1 having the highest priority. Percentages specify how to allocate CPU to each
consumer group at each level.
The following rules apply for the EMPHASIS resource allocation method:
• CPU resources are distributed at a given level on the basis of the specified percentages. The
percentage of CPU specified for a resource consumer group is a maximum for how much
that consumer group can use at a given level.
• Consumer resources that are not used at a given level are made available to consumer
groups at the next level. For example, if the consumer groups at Level 1 use only 60% of
the available resources, the additional 40% is made available to consumer groups at
Level 2.
• The sum of percentages at any given level must be less than or equal to 100.
• Any levels that have no plan directives explicitly specified have a default of 0% for all
subplans or consumer groups.
• The EMPHASIS resource allocation method avoids starvation problems, where consumers
with lower priorities are not given the opportunity to run.

Oracle Database 11g: Administration Workshop II 17 - 15


Computer Pride Limited

Comparison of EMPHASIS and RATIO (continued)


The RATIO policy is a single-level CPU allocation method. Instead of percentages, you specify
numbers corresponding to the ratio of CPU you want to give to the consumer group. For
example, given three consumer groups OLTP_USERS, DSS_USERS, and BATCH_USERS, you
can specify the following ratios:
• OLTP_USERS: 4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• DSS_USERS: 3
• BATCH_USERS: 2
• OTHER: 1

This is similar to saying that OLTP users should get 40% of the resources, DSS users should get
30% of the resources, BATCH users should get 20% of the resources, and all other consumer
groups should get 10% of the available resources.
If there are no consumers in the OTHER or DSS_USERS consumer groups currently utilizing
CPU resources, then the OLTP_USERS consumer group would get two-thirds of the available
resources and the BATCH_USERS consumer group would get the other third.
b le
fe ra
a ns
o n -tr
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
ley
n
Sta

Oracle Database 11g: Administration Workshop II 17 - 16


Computer Pride Limited

Active Session Pool Mechanism


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Sess4 Sess5 p001 p002 p003


Sess10
Sess3 Sess8
Sess9
Sess1 Sess2 Sess6 Sess7
DSS a b le
active s fer
r an
session
- t
OLTP users DSS userss a
non queue
Active_sess_pool_P1=5 ) ha ideฺ
Active_sess_pool_P1=3
m Gu
ฺ c o t
a il e n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
ki se to
Active Session PooluMechanism
y
s cPool
aSession
Using the Active en feature, you can control the maximum number of concurrently
M l i
activen l ey per resource consumer group. With this functionality, a DBA can indirectly
sessions
Sta the amount of resources that any resource consumer group uses because resource
control
consumption is proportional to the number of active sessions. Using an active session pool can
help to reduce the number of servers taking resources in the system, thus avoiding inefficient
paging, swapping, and other resource depletion (such as memory) resulting from attempting to
run too many jobs simultaneously.
After the Active Session Pool is filled with active sessions, the Resource Manager queues all
subsequent sessions attempting to become active until other active sessions complete or become
inactive. An active session is one currently involved in a transaction, query, or parallel
operation. Individual parallel slaves are not counted as sessions; the entire parallel operation
counts as one active session.
There is only one queue per resource consumer group and the queuing method is first in, first out
(FIFO) with a timeout. The queue is implemented as a memory structure and cannot be queried
directly.

Oracle Database 11g: Administration Workshop II 17 - 17


Computer Pride Limited

Setting the Active Session Pool


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

50

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Setting the Active Sessionk i
u nPool
a s y e se
You can easily
y Mconfigurelicthe Active Session Pool settings for a resource plan by using Enterprise
t a nle
Manager.
S
Example, if you limit the Maximum Number of Active Sessions to 50 for the APPUSER
consumer group:
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.update_plan_directive(
plan => 'DEFAULT_PLAN',
group_or_subplan => 'APPUSER',
new_comment => '',
new_cpu_p1 => NULL, new_cpu_p2 => NULL, new_cpu_p3 => 60,
new_cpu_p4 => NULL, new_cpu_p5 => NULL, new_cpu_p6 => NULL,
new_cpu_p7 => NULL, new_cpu_p8 => NULL,
new_parallel_degree_limit_p1 => NULL,
new_switch_io_reqs => NULL,
new_switch_io_megabytes => NULL,
new_active_sess_pool_p1 => 50,
new_queueing_p1 => NULL,
(continued)
Oracle Database 11g: Administration Workshop II 17 - 18
Computer Pride Limited

Setting the Active Session Pool (continued)


new_switch_group => '',
new_switch_time => NULL,
new_switch_estimate => false,
new_max_est_exec_time => NULL,
new_undo_pool => NULL,
new_max_idle_time => NULL,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

new_max_idle_blocker_time => NULL,


new_switch_time_in_call => NULL);
dbms_resource_manager.submit_pending_area();
END;

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 17 - 19


Computer Pride Limited

Specifying Thresholds:
Execution Time Limit
• The Database Resource Manager can estimate the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

execution time of an operation proactively.


• You can specify a maximum estimated execution time for an
operation at the resource consumer group level.
• Operation does not start if the estimate is longer than
MAX_EST_EXEC_TIME. (ORA-07455)
• The benefit of this feature is the elimination of the
exceptionally large job that uses too many system e
resources. r a bl
s fe
• The default is UNLIMITED. - t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Specifying Threshold: k i
u nse Time Limit
Execution
s y
a maximum e estimated execution time any operation can take at any given time
You can define Mthe l i c
y resource plan directive’s MAX_EST_EXEC_TIME parameter. When this
l
by setting
n ethe
Sta is set, the Database Resource Manager estimates the time a specific job will take. If
parameter
the operation’s estimate is more than MAX_EST_EXEC_TIME, then the operation does not start
and the ORA-07455 error is issued. This eliminates any exceptionally large jobs that would
utilize too many system resources.
If a resource consumer group has more than one plan directive referring to it, it may have more
than one MAX_EST_EXEC_TIME. The Database Resource Manager then chooses the most
restrictive of all incoming values.
The estimated execution time for a given statement is calculated using the statistics from the
cost-based optimizer.

Oracle Database 11g: Administration Workshop II 17 - 20


Computer Pride Limited

Setting Idle Timeouts


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

a b le
DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVEfer
(PLAN => 'DAY_PLAN', t r a ns
GROUP_OR_SUBPLAN => 'APPUSER', non
-
COMMENT => 'Limit Idle Timeas a
Example',
NEW_MAX_IDLE_TIME => 600, m ) h uideฺ
o
NEW_MAX_IDLE_BLOCKER_TIME
a ilฺc ent=>G 300);
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Setting Idle Timeouts
y u ki se to
as plan’s
You use the resource
M l i c enIdle Time tab to set the maximum idle timeouts for a resource plan.
“Max n l
IdleeyTime (sec)” and “Max Idle Time if Blocking Another Session (sec)” are the
Sta equivalents of the NEW_MAX_IDLE_TIME and NEW_
respective
MAX_IDLE_BLOCKER_TIME resource directives in the
DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE procedure. They are both
specified in seconds.
NEW_MAX_IDLE_TIME specifies the time that a session is neither executing nor waiting for
I/O. When the session exceeds the specified limit, the PMON process forcibly kills the session
and cleans up its state. In addition to limiting the maximum idle time for a session, you can also
limit the amount of time that an idle session can block another session. You impose this limit by
setting the NEW_MAX_IDLE_BLOCKER_TIME resource directive to the number of seconds to
allow a session to be idle while blocking another session. You can also specify a value of
UNLIMITED to indicate that no maximum time has been set. The default is NULL, which means
unlimited. These settings give you a more granular control than profiles, whose single value
cannot distinguish between blocking and nonblocking sessions.
In the slide example, the PMON process kills sessions that are idle for longer than 600 seconds.
The PMON process also kills sessions that are idle for more than 300 seconds and are blocking
other sessions. PMON checks these limits once every minute and if it finds a session that has
exceeded one of the limits, it forcibly kills the session and cleans up all its resources.
Oracle Database 11g: Administration Workshop II 17 - 21
Computer Pride Limited

Resource Consumer Group Mapping


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Resource ConsumeruGroup k i (M Mapping
t o
a s y ense
You can configure
y l ic
M the Database Resource Manager to automatically assign consumer groups to
sessionsle
by providing mappings between session attributes and consumer groups. Further, you
cant a n
S prioritize the mappings so as to indicate which mapping has precedence in case of conflicts.
There are two types of session attributes: login attributes and run-time attributes. The login
attributes (the last five in the Attribute Mappings list shown in the slide) are meaningful only at
session login time, when the Database Resource Manager determines the initial consumer group
of the session. In contrast, a session that has already logged in can later be reassigned to another
consumer group on the basis of its run-time attributes.
From the Database Control home page, navigate to the Server tabbed page, and then click the
Resource Consumer Group Mappings link in the Resource Manager section. For each of the
attributes, set up a mapping that consists of a way to identify a session (for example, username),
and a consumer group. Add or remove rows for each of the resource consumer group categories,
as required, and enter text identifying the user, client, module, or service in the corresponding
group. You can establish a priority ordering between conflicting mappings of the attributes by
using the Priorities tab. You can set the priority from the most important to the least important
by using the navigational arrows (as highlighted). The mappings at the top of the list have the
highest priority.
Using EM Database Control, you can easily view the SQL generated from your actions by
clicking the Show SQL button.
Oracle Database 11g: Administration Workshop II 17 - 22
Computer Pride Limited

Resource Consumer Group Mapping (continued)


Example to give the Client OS User a higher priority than the Client Program:
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.set_consumer_group_mapping(
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

dbms_resource_manager.oracle_user,
'SCOTT',
'LOW_GROUP'
);
dbms_resource_manager.set_consumer_group_mapping_pri(
EXPLICIT => 1, SERVICE_MODULE_ACTION => 2,
SERVICE_MODULE => 3,
MODULE_NAME_ACTION => 4,
MODULE_NAME => 5,
SERVICE_NAME => 6,
ORACLE_USER => 7, ble
CLIENT_OS_USER => 8, fe r a
ans
CLIENT_PROGRAM => 9,
n - t r
no
CLIENT_MACHINE => 10
);
s a
h a
dbms_resource_manager.submit_pending_area();
) eฺ
m i d
co nt Gu
END;
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 17 - 23


Computer Pride Limited

Activating a Resource Plan


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

EM > Server > Settings (in the Resource Manager section) e


r a bl
s fe
- t r an
n
no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Activating a Resource k i
Plan
a s yu ense
You can use the
y lic of Enterprise Manager to manage resource plans. To activate a plan,
M Plans page
select n
a leplan you want to make active, choose Activate from the Actions drop-down list, and
the
t
then
S click Go. The plan you selected is then made the current top plan for the instance.
Using the RESOURCE_MANAGER_PLAN Initialization Parameter
The plan for an instance is defined using the RESOURCE_MANAGER_PLAN database
initialization parameter. This parameter specifies the top plan to be used for this instance. If no
plan is specified, the Resource Manager is not activated for the instance.
You can activate, deactivate, or change the current top plan by using an ALTER SYSTEM
statement. When a resource plan is changed using this command, the change takes effect
instantly.
If the parameter is set in a parameter file, and the plan specified is not defined in the database,
then the database cannot be opened with that parameter file. The following error is returned:
ORA-07452: specified resource manager plan does not exist in
the data dictionary
If this error is encountered, the parameter must be modified to show a correct value before the
instance can be restarted.

Oracle Database 11g: Administration Workshop II 17 - 24


Computer Pride Limited

Database Resource Manager Information

View Name Information


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DBA_RSRC_PLANS Plans and status

DBA_RSRC_PLAN_DIRECTIVES Plan directives

DBA_RSRC_CONSUMER_GROUPS Consumer groups

DBA_RSRC_CONSUMER_GROUP_PRIVS Users/roles

DBA_RSRC_GROUP_MAPPINGS Consumer group mapping


ble
fe r a
DBA_RSRC_MAPPING_PRIORITY Mapping priority
ans
n - t r
DBA_USERS Column
a no
s
initial_rsrc_consumer_group
a
Users/roles ) h i d eฺ
DBA_RSRC_MANAGER_SYSTEM_PRIVS m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Database Resource u k
Manager to u
i (M eInformation
a sy views e n s
Several data dictionary
y M lic are available to check the resource plans, consumer groups, and

a n le that are declared in the instance. This section discusses some useful information
plan directives
t
that
S can be obtained from these views. For more detailed information about the contents of each
of these views, refer to the Oracle Database Reference manual.
Use the following query to obtain information about resource plans defined in the database:
SQL> SELECT plan, num_plan_directives, status, mandatory
2 FROM dba_rsrc_plans;
PLAN NUM_PLAN_DIRECTIVES STATUS MAN
-------------- ------------------- --------- ---
DEFAULT_PLAN 3 ACTIVE NO
INTERNAL_QUIESCE 2 ACTIVE YES
INTERNAL_PLAN 1 ACTIVE YES
BUGDB_PLAN 4 ACTIVE NO
MAILDB_PLAN 3 ACTIVE NO
MYDB_PLAN 3 ACTIVE NO
A status of ACTIVE indicates that the plan has been submitted and can be used, whereas a status
of PENDING shows that the plan has been created, but is still in the pending area.
If the mandatory column is assigned a value of YES, then the plan cannot be deleted.

Oracle Database 11g: Administration Workshop II 17 - 25


Computer Pride Limited

Monitoring the Resource Manager


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Monitoring the Resource k i
u Manager
a s y e n se
You can monitor
y lic
M the functioning of the Database Resource Manager at the session level. It is

t a nlewith Automatic Database Diagnostic Monitor (ADDM).


integrated
S are different ways to manage and monitor the Resource Manager by using EM Database
There
Control. On the Server tabbed page, click the Statistics link in the Resource Manager section.
The Resource Manager Statistics page displays a grouping of statistics and charts that depict the
current state of the active resource plan. You can view the statistics for the currently active plan.
For Resource Usage, you can view “CPU Consumed,” “I/O Requests per Second,” and
“Megabytes of I/O Issued per Second.” Another chart displays “Resource Manager Induced
Waits.” Then there are statistics for “Queued Sessions,” “Automatic Reprioritization,” and idle
time.

Oracle Database 11g: Administration Workshop II 17 - 26


Computer Pride Limited

Monitoring the Resource Manager

• V$SESSION: Contains the resource_consumer_group


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

column that shows the current group for a session


• V$RSRC_PLAN: A view that shows the active resource plan
• V$RSRC_CONSUMER_GROUP: A view that contains statistics
for all active groups

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Monitoring the Resource k i
u Manager e (continued)
s y
a lice n s
CPU Utilization M
There n l
are eaty least three different views in the system that can provide you with information about
a utilization inside the Oracle database:
StCPU
the
• V$RSRC_CONSUMER_GROUP shows CPU utilization statistics on a per consumer group
basis, if you are running the Oracle Database Resource Manager. This view displays data
related to currently active resource consumer groups.
• V$SYSSTAT shows the Oracle database CPU usage for all sessions. The statistic “CPU
used by this session” shows the aggregate CPU used by all sessions.
• V$SESSTAT shows the Oracle database CPU usage per session. You can use this view to
determine which particular session is using the most CPU.
The V$RSRC_CONSUMER_GROUP View
The following is a quick description of some of the columns in this view:
• name: Name of the consumer group
• active_sessions: Number of currently active sessions in this consumer group
• execution_waiters: Number of active sessions waiting for a time slice
• requests: Cumulative number of requests executed in this consumer group
• cpu_wait_time: Cumulative amount of time that sessions waited for CPU
• consumed_cpu_time: Cumulative amount of CPU time consumed by all sessions

Oracle Database 11g: Administration Workshop II 17 - 27


Computer Pride Limited

Monitoring the Resource Manager (continued)


There is no view that shows the Active Session Pool queue directly, but you can get some
information from:
• V$SESSION: The current_queue_duration column shows how long a session has
been queued, or 0 (zero) if the session is not currently queued.
• V$RSRC_CONSUMER_GROUP: The queue_length column shows the number of
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

sessions currently queued per consumer group.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 17 - 28


Computer Pride Limited

Summary

In this lesson, you should have learned how to do the following:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Configure the Database Resource Manager


• Access and create resource plans
• Create consumer groups
• Specify directives for allocating resources to consumer
groups
• Map consumer groups to plans
• Activate a resource plan a b le
s fer
• Monitor the Resource Manager ran n -t
o
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 17 - 29


Computer Pride Limited

Practice 17 Overview:
Using the Resource Manager
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Creating a resource consumer group


• Specifying CPU resource allocation directives for consumer
groups
• Associating users with a resource consumer group
• Activating a resource plan
• Testing in SQL*Plus
• Deactivating a resource plan ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 17 - 30


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Automating Tasks with the Scheduler

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Simplify management tasks by using the Scheduler


• Create a job, program, and schedule
• Monitor job execution
• Use a time-based or event-based schedule for executing
Scheduler jobs

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 18 - 2


Computer Pride Limited

Simplifying Management Tasks


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Performing a series Running a dequeue


Replicating table data
of month-end procedure as soon
via materialized
tasks on the last as a message is
day of each month enqueued view refreshes

Running a daily Computing table


job to back up and index statistics
database twice a day
bl e
fe r a
t r a ns
Starting the batch
Generating an
o n - an
Rebuilding
load as soon as the file
hourly report on n when
aindex
invalid server
h a s
finishedฺ rebuilding
arrives on the file system access attempts ) e
idcurrent index
the
o m G u
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Simplifying Managementy u ki Tasks
s e
Many tasks inM asOraclelicenvironment
the en need job-scheduling capabilities. Routine database
l
maintenancee y
t a n and application logic require jobs to be scheduled and run periodically. Business-
S
to-business (B2B) applications require scheduling for their business events. DBAs need to
schedule regular maintenance jobs in specified time windows.
The Oracle database provides advanced scheduling capabilities through the database Scheduler,
which is a collection of functions and procedures in the DBMS_SCHEDULER package. The
Scheduler can be invoked in any SQL environment, or through Enterprise Manager (EM).
The Scheduler enables database administrators and application developers to control when and
where various tasks take place in the database environment. These tasks can be time consuming
and complicated; using the Scheduler, you can manage and plan these tasks.
Scheduler jobs can be started based on time or when a specified event occurs, and the Scheduler
can raise events when a job’s state changes (for example, from RUNNING to COMPLETE). You
can also use a named series of programs that are linked together for a combined objective.

Oracle Database 11g: Administration Workshop II 18 - 3


Computer Pride Limited

A Simple Job
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

WHEN

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
WHAT m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
A Simple Job
a syu cense
A job has twoM
y li
key components: action, “what” needs to be done and schedule, “when” action
l e
occurs.nThe “what” is expressed in the Command region of the screenshot shown in the slide and
the
a
Stjob_type and job_action parameters. The job shown in the slide is also represented
by the following code. The “what” portion is enclosed in the top box while the “when” portion is
defined in the second box.
BEGIN
sys.dbms_scheduler.create_job(
job_name => '"HR"."CREATE_LOG_TABLE_JOB"',
job_type => 'PLSQL_BLOCK', job_action => 'begin
execute immediate (''create table session_history(
snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)''); end;',
start_date => systimestamp at time zone 'America/New_York',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Create the SESSION_HISTORY table',
auto_drop => FALSE, enabled => TRUE);
END;
A job is also defined by “when” the desired action needs to take place. The “when” is expressed
in a “schedule,” which can be based on time (see the start_date parameter) or events, or be
dependent on the outcome of other jobs.
Oracle Database 11g: Administration Workshop II 18 - 4
Computer Pride Limited

Key Components and Steps

To simplify management tasks with the Scheduler, perform the


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

following steps:
1. Create a program.
2. Create and use a schedule.
3. Create and submit a job.
4. Monitor a job.
Job
Program Schedule
attributes
ble
fe r a
ans
Job
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
Arguments
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Key Components and
a syu Key e n se
Steps

y ic
The SchedulerMoffers a lmodularized approach for managing tasks within the Oracle database. By
breakingl e
n down a task into its components, such as time, location, and database object, the
S t a
Scheduler offers you an easier way to manage your database environment. The Scheduler uses
three basic components:
• A job specifies what needs to be executed and when. For example, the “what” could be a
PL/SQL procedure, a native binary executable, a Java application, or a shell script. You can
specify the program (what) and schedule (when) as part of the job definition, or you can use
an existing program or schedule instead. You can use arguments for a job to customize its
run-time behavior.
• A schedule specifies when and how many times a job is executed. A schedule can be based
on time or an event. You can define a schedule for a job by using a series of dates, an event,
or a combination of the two, along with additional specifications to denote repeating
intervals. You can store the schedule for a job separately and then use the same schedule for
multiple jobs.
• A program is a collection of metadata about a particular executable, script, or procedure.
An automated job executes some task. Using a program enables you to modify the job task,
or the “what,” without modifying the job itself. You can define arguments for a program,
enabling users to modify the run-time behavior of the task.

Oracle Database 11g: Administration Workshop II 18 - 5


Computer Pride Limited

1. Creating a Program
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

BEGIN
ble
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name => 'CALC_STATS2',
fe r a
program_action =>
ans
'HR.UPDATE_HR_SCHEMA_STATS',
n - t r
program_type =>
a no
'STORED_PROCEDURE',
a s
enabled => TRUE);
) h i d eฺ
END;
m
co nt Gu
/
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
1. Creating a Program
a syu cense
M
Use the CREATE_PROGRAM
y li procedure to create a program. Creating a program is an optional
l e
part ofnusing the Scheduler. You can also encode the action to be performed within an
Sta
anonymous PL/SQL block in the CREATE_JOB procedure. By creating the program separately,
you can define the action once, and then reuse this action within multiple jobs. This enables you
to change the schedule for a job without having to re-create the PL/SQL block. You can also
customize the job by specifying argument values.
To create a program in your own schema, you need the CREATE JOB privilege. A user with the
CREATE ANY JOB privilege can create a program in any schema.
A program is created in a disabled state by default (unless the enabled parameter is set to
TRUE). A disabled program cannot be executed by a job until it is enabled. You can specify that
a program should be created in the enabled state by specifying a value of TRUE for enabled.
The program action is a string specifying a procedure, executable name, or a PL/SQL
anonymous block, depending on what program_type is set to.
If you have a procedure called UPDATE_HR_SCHEMA_STATS that collects the statistics for the
hr schema, then you can create a program to call this procedure.
In Enterprise Manager, click Programs in the Oracle Scheduler region of the Server page. Click
Create.

Oracle Database 11g: Administration Workshop II 18 - 6


Computer Pride Limited

2. Creating and Using Schedules


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE(
ble
schedule_name => 'stats_schedule',
fe r a
start_date => SYSTIMESTAMP,
ans
end_date => SYSTIMESTAMP + 30,
n - t r
repeat_interval =>
a no
'FREQ=HOURLY;INTERVAL=1',
a s
comments => 'Every hour');
) h i d eฺ
END; m
co nt Gu
/ i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
2. Creating and Using
a syu Schedules
e n se
M (instead
By using a schedule
y lic of specifying the execution times for a job within the job
l e
definition),
n you can manage the scheduled execution of multiple jobs without having to update
S t a
multiple job definitions. If a schedule is modified, then each job that uses that schedule
automatically uses the new schedule.
Use the CREATE_SCHEDULE procedure in the DBMS_SCHEDULER PL/SQL package to create
a schedule.
The start_date represents the date on which the schedule becomes active. The schedule
cannot refer to any dates before this date. The schedule is not valid after the end_date.
You can schedule repeated executions by supplying a calendaring expression for
repeat_interval. This calendaring expression is used to generate the next date of the
schedule. Dates falling after the end_date time are not included in the schedule.
In the example in the slide, a schedule named STATS_SCHEDULE is created, specifying a
repeat interval of every hour (starting now) and continuing for 30 days. For more information
about calendaring expressions, refer to the Oracle Database Administrator’s Guide.
You can use Enterprise Manager to create schedules, as shown in the slide.

Oracle Database 11g: Administration Workshop II 18 - 7


Computer Pride Limited

3. Creating and Running a Job


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
syu ceanJob
3. Creating and Running
a se
M
A job is a combination
y lofi a schedule and a description of what to do, along with any additional
l
arguments e
n that are required by the job.
t a
S program or “Command” can be a pre-created PL/SQL or Java program, an anonymous
The
PL/SQL block, or an executable that is run from the operating system’s command line.
The schedule for a job can be a predefined schedule (created with the
DBMS_SCHDULER.CREATE_SCHEDULE procedure) or defined as part of the job creation.
The schedule specifies attributes about when the job is run, such as:
• A start time, which defines when the job is picked for execution and an end time, which
specifies the time after which the job is no longer valid and is not scheduled any more
• An expression specifying a repeating interval for the job
• A complex schedule created by combining existing schedules
• A condition or change in state, called an event, that must be met before the job is started
There are many attributes that you can set for a job. Attributes control how the job executes.
To run a job in Enterprise Manager, click the Server folder tab, then select Jobs from the Oracle
Scheduler section.

Oracle Database 11g: Administration Workshop II 18 - 8


Computer Pride Limited

4. Monitoring a Job
SELECT job_name, status, error#, run_duration
FROM USER_SCHEDULER_JOB_RUN_DETAILS;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

JOB_NAME STATUS ERROR# RUN_DURATION


---------------- ------ ------ ------------
GATHER_STATS_JOB SUCCESS 0 +000 00:08:20
PART_EXCHANGE_JOB FAILURE 6576 +000 00:00:00

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
4. Monitoring a Jobyu
a
M li
The DBA_SCHEDULER_JOB_RUN_DETAILS
y view has a row for each job instance. Each row
containsl e
n information about the job execution for that instance.
S t a
[DBA|ALL]_SCHEDULER_JOB_RUN_DETAILS views have the following columns:
• LOG_ID: The unique identifier of the log entry
• LOG_DATE: The time stamp of the log entry
• OWNER: The job owner
• JOB_NAME: The name of the job
• STATUS: The status of the job execution
• ERROR#: The number of the first error encountered
• REQ_START_DATE: The time at which the job was scheduled to start
• ACTUAL_START_DATE: The time at which the job was actually started
• RUN_DURATION: The duration of execution of the job
• INSTANCE_ID: The instance upon which the job ran
• SESSION_ID: The session the job ran within
• SLAVE_PID: The process ID of the slave process used to perform the job execution
• CPU_USED: The amount of CPU used for the job run
• ADDITIONAL_INFO: Additional information about the job run

Oracle Database 11g: Administration Workshop II 18 - 9


Computer Pride Limited

Using a Time-Based or
Event-Based Schedule
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Schedule
ble
fe r a
ans
n - t r
Time
a no Event
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Using a Time-Based
a e nse
syuorcEvent-Based Schedule
M
To specify a time-based
y lischedule for a job, you can specify either a calendaring expression or a
l
date-time e
n expression. When using a calendaring expression, the next start time for a job is
S t a
calculated using the repeat interval and the start date of the job. When using date-time
expressions, the specified expression determines the next time that the job should run. If no
repeat interval is specified, the job runs only once on the specified start date.
If a job uses an event-based schedule, the job runs when the event is raised. At a high level, an
event can be viewed as a change in state. An event occurs when a Boolean condition changes its
state from FALSE to TRUE, or TRUE to FALSE.
The Scheduler uses Oracle Streams Advanced Queuing (AQ) to raise and consume events.
Note: The Scheduler does not guarantee that a job executes on the exact time because the system
may be overloaded and thus resources may be unavailable.

Oracle Database 11g: Administration Workshop II 18 - 10


Computer Pride Limited

Creating a Time-Based Job

Example: Create a job that calls a backup script every night at


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

11:00, starting tonight.

BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'HR.DO_BACKUP',
job_type => 'EXECUTABLE',
job_action =>
'/home/usr/dba/rman/nightly_incr.sh',
a b le
start_date=> SYSDATE,
s fer
repeat_interval=>'FREQ=DAILY;BYHOUR=23',
- t r an
/* next night at 11:00 PM o*/
n n
s a
comments => 'Nightly incremental backups');
END;
a
) h uideฺ
m
/ lฺco t G ai den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Creating a Time-Based
y u kiJobse to
M as lprocedure
Use the CREATE_JOB i c en of the DBMS_SCHEDULER package to create a job. Jobs are
l ey by default and they become active and scheduled only when they are explicitly
createdndisabled
Sta All job names are of the form: [schema.]name.
enabled.
You should use SYSTIMESTAMP and specify a time zone so that when the time changes
because of daylight saving time, your job adjusts its execution time automatically.
By default, a job is created in the current schema. You can create a job in another schema
by specifying the name of the schema, as shown in the example in the slide. The job owner is the
user in whose schema the job is created, whereas the job creator is the user who created the job.
Jobs are executed with the privileges of the job owner. The national language support (NLS)
environment of the job when it runs is the same as that present at the time the job was created.
The job_type parameter indicates the type of task to be performed by the job. The possible
values are:
• PLSQL_BLOCK: An anonymous PL/SQL block
• STORED_PROCEDURE: A named PL/SQL, Java, or external procedure
• EXECUTABLE: A command that can be executed from the operating system (OS)
command line

Oracle Database 11g: Administration Workshop II 18 - 11


Computer Pride Limited

Creating a Time-Based Job (continued)


The job_action parameter can be the name of the procedure to run, the name of a script or
operating system command, or an anonymous PL/SQL code block, depending on the value of
the job_type parameter.
In the example in the slide, job_type is specified as EXECUTABLE and job_action is the
full OS-dependent path of the desired external executable plus optionally any command-line
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

arguments.
An external job is a job that runs outside the database. All external jobs run as a low-privileged
guest user, as has been determined by the database administrator while configuring external job
support. Because the executable is run as a low-privileged guest account, you should verify that
it has access to necessary files and resources. Most, but not all, platforms support external jobs.
For platforms that do not support external jobs, creating or setting the attribute of a job or a
program to type EXECUTABLE returns an error.
Refer to your Oracle database platform-specific documentation for more information about
configuring the environment to run external programs with the Scheduler. ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 18 - 12


Computer Pride Limited

Persistent Lightweight Jobs

Persistent lightweight jobs:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Reduce the overhead and time required to start a job


• Have a small footprint on disk for the job metadata and also
for storing run-time data
• Are created from a job template, making it easy to create
many jobs quickly

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
Lightweight Jobs yu
a
There are some
y li that have a need to create hundreds of jobs a second. With regular
Mcustomers
l
jobs each e
n job creates a database object describing the job, modifying several tables and creating
t a
S in the process. The overhead associated with this type of job need is substantial. In the
redo
Oracle Database Scheduler, there is a persistent lightweight job. The goal of a lightweight job is
to reduce the overhead and time required to start a job. A minimal amount of metadata is created
for the job. This reduces the time required and redo created when the job starts.
The lightweight job has a small footprint on disk for the job metadata and also for storing run-
time data. The small footprint on disk also makes load-balancing possible in RAC environments.
The lightweight job is always created from a job template. The job template can be a stored
procedure or a program. The stored procedure holds all the information needed for the job. A
few job attributes may be set such as job arguments.
Job templates are created using the DBMS_SCHEDULER.CREATE_PROGRAM procedures.

Oracle Database 11g: Administration Workshop II 18 - 13


Computer Pride Limited

Choosing the Right Job

• Regular jobs:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

– Offer the maximum flexibility but incur some overhead in


create/drop performance
– Require the job database object to be
created and dropped
• Persistent lightweight jobs:
– Involve less overhead as they
do not have the requirement of
creating a database object a b le
– Require the use of a template s fer
- t r an
on
– Inherit their privileges from the parent job templates
n
– Are most useful when the DBA needs to create s a a large
a ฺ
number of jobs in a very short time m) h uide
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Choosing the Right y u
Jobki se to
M
The advantages aands disadvantages
l i c en of the types of jobs are as follows:
l ey job offers the maximum flexibility but does incur significant overhead in
• Anregular
Stacreate/drop performance. A job can be created with a single command. The user has fine-
grained control of the privileges on the job. A program or a stored procedure owned by
another user can be used. A regular job requires the job database object to be created and
dropped. This action updates several tables and the associated redo. If users are creating a
relatively small number of jobs that run infrequently, then they should choose regular jobs.
• A persistent lightweight job has a significant improvement in create and drop time
because it does not have the overhead of creating a database object. Every lightweight job is
created from a job template, which is stored as a program. Because persistent lightweight
jobs write state information to disk at run time, only a small improvement is expected in the
execution. There are several limitations to persistent lightweight jobs.
- The user cannot set privileges on these jobs—they inherit their privileges from the
parent job template.
- The use of a template is mandatory; it is not possible to create a fully self-contained
persistent lightweight job.
- Only certain job attributes are available to be set, such as JOB_ARGUMENTS.

Oracle Database 11g: Administration Workshop II 18 - 14


Computer Pride Limited
Choosing the Right Job (continued)
Lightweight jobs are most useful when users need to create a large number of jobs in a very
short time (about 10–100 jobs a second) and they have a library of programs (job templates)
available that they can use.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 18 - 15


Computer Pride Limited

Creating a Single
Lightweight Job
BEGIN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_lightweight_job1',
program_name => 'MY_PROG',
repeat_interval => 'FREQ=DAILY;BY_HOUR=9',
end_time => '30-APR-07 04.00.00 AM CST',
job_style => 'LIGHTWEIGHT');
END;
/

BEGIN
ble
DBMS_SCHEDULER.CREATE_JOB (
fe r a
job_name => 'my_lightweight_job2',
ans
program_name => 'MY_PROG',
n - t r
schedule_name => 'MY_SCHED',
a no
job_style => 'LIGHTWEIGHT');
a s
END;
) h i d eฺ
/ m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Lightweight
a syuJobs e n se
M
The DBMS_SCHEDULER
y licpackage has updated several packages to allow the lightweight jobs to
l
be createde
n with a minimum of new code. Lightweight jobs have very few parameters that can be
S t a
specified: job arguments and schedule. The rest of the metadata for the job is inherited from the
job template, including privileges. The template for a lightweight job must be a PL/SQL block
or a stored procedure. Lightweight jobs must be created through PL/SQL using the
DBMS_SCHEDULER package; the JOB_STYLE argument is not available in EM. In the first
example, MY_PROG is the job template, and the schedule is created as part of the CREATE_JOB
method. In the second example, the schedule is applied from a named schedule.
A simple template could look like this:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name=>'"SYSTEM"."MY_PROG"',
program_action=>
'DECLARE time_now DATE;
BEGIN
SELECT SYSDATE INTO time_now FROM DUAL;
END;',
program_type=>'PLSQL_BLOCK',
enabled=>TRUE);
END;
Oracle Database 11g: Administration Workshop II 18 - 16
Computer Pride Limited

Creating an Event-Based Schedule

To create an event-based job, you must set:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• A queue specification (where your application enqueues


messages to start a job)
• An event condition (same syntax as an Oracle Streams AQ
rule condition) that if TRUE starts the job

Oracle Database
ble
fe r a
t r a ns
n -
Scheduler
o
s an
Event ADT
) ha ideฺ
Application
(Abstract
c o mQueueGu
Data Type) a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Creating an Event-Based u ki Schedulee to
y
as based n
eon s
M
Jobs can be triggered
y l i c events. An application can notify the Scheduler to start a job by
l
enqueuing e
n a message onto an Oracle Streams queue. A job started in this way is referred to as an
S t a
event-based job. To create an event-based job, you must set the following two additional
attributes with the CREATE_JOB procedure:
• queue_spec: A queue specification that includes the name of the queue where your
application enqueues messages to raise job start events, or in the case of a secure queue, the
<queue_name>, <agent_name> pair
• event_condition: A conditional expression based on message properties that must
evaluate to TRUE for the message to start the job. You can include user data properties in
the expression, provided that the message payload is a user-defined object type, and that
you prefix object attributes in the expression with tab.user_data.
You can either specify queue_spec and event_condition as in-line job attributes, or
create an event-based schedule with these attributes and then create a job that references this
schedule.

Oracle Database 11g: Administration Workshop II 18 - 17


Computer Pride Limited

Creating Event-Based Schedules


with Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Event-Based
a e nse with Enterprise Manager
syu cSchedules
M page
The Create Schedule
y li enables you to choose between a standard, time-based schedule and
l e
an event-based
n schedule. If you choose an event-based schedule, then the interface changes and
t a
S can specify the queue name, agent name, and event condition, in addition to the other
you
schedule attributes.
Note: The Scheduler runs the event-based job for each occurrence of an event that matches
event_condition. However, events that occur while the job is already running are ignored;
the event gets consumed, but does not trigger another run of the job.
References
• See the Oracle Streams Advanced Queuing User’s Guide and Reference for information
about how to create queues and enqueue messages.
• For more information about Oracle Streams AQ rules and event conditions, see the
DBMS_AQADM.ADD_SUBSCRIBER procedure in the Oracle Database PL/SQL Packages
and Types Reference 11 manual.

Oracle Database 11g: Administration Workshop II 18 - 18


Computer Pride Limited

Creating an Event-Based Job

Example: Create a job that runs if a batch load data file arrives
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

on the file system before 9:00 AM.

BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'ADMIN.PERFORM_DATA_LOAD',
job_type => 'EXECUTABLE',
job_action => '/home/usr/dba/rman/report_failure.sh',
start_date => SYSTIMESTAMP,
event_condition =>
event_condition => 'tab.user_data.object_owner
'tab.user_data.object_owner ==
a b le
''HR''
''HR'' and
and tab.user_data.object_name
tab.user_data.object_name == ''DATA.TXT''
''DATA.TXT'' s fer
and
and tab.user_data.event_type
tab.user_data.event_type == ''FILE_ARRIVAL''
''FILE_ARRIVAL''
- t r an
and
and tab.user_data.event_timestamp ', non
tab.user_data.event_timestamp << 99 ',
queue_spec
queue_spec => 'HR.LOAD_JOB_EVENT_Q'); s a
=> 'HR.LOAD_JOB_EVENT_Q');
END; ) ha deฺ m u i
o G
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Creating an Event-Basedy u ki Job s e
s cen
ainformation
M
To specify event
y li as job attributes, you use an alternate syntax of CREATE_JOB that
includesl e
n the queue_spec and event_condition attributes. The job can include event
S t a
information in-line as job attributes or can specify event information by pointing to an event
schedule. The example shown in the slide uses an in-line, event-based schedule.
The example in the slide shows a job that is started when a file arrives on the operating system,
as long as the file arrives before 9:00 AM. Assume that the message payload is an object with
four attributes named object_owner, object_name, event_type, and
event_timestamp.
The example uses a user-defined event. Therefore, before this job can be started, when the file
arrives on the file system, a program or procedure must enqueue the event object type with the
proper information into the specified event queue. The HR.LOAD_JOB_EVENT_Q queue must
be of the same type as the event object type used for notifying the Scheduler of an event
occurrence. That is, the HR.LOAD_JOB_EVENT_Q queue must be a typed queue where the
type has four attributes named object_owner, object_name, event_type, and
event_timestamp.
For more information about how to create queues and enqueue messages, refer to the Oracle
Streams Advanced Queuing User’s Guide and Reference documentation.

Oracle Database 11g: Administration Workshop II 18 - 19


Computer Pride Limited

Event-Based Scheduling

Event types:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• User- or application-generated events


• Scheduler-generated events
Events raised by Scheduler jobs:
• JOB_STARTED • JOB_SCH_LIM_REACHED
• JOB_SUCCEEDED • JOB_DISABLED
• JOB_FAILED • JOB_CHAIN_STALLED
• JOB_BROKEN • JOB_ALL_EVENTS
ble
• JOB_COMPLETED • JOB_RUN_COMPLETED
fe r a
ans
• JOB_STOPPED • JOB_OVER_MAX_DUR
n - t r
Example of raising an event:
a no
a s
DBMS_SCHEDULER.SET_ATTRIBUTE('hr.do_backup', ) h i d eฺ
'raise_events', DBMS_SCHEDULER.JOB_FAILED); m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
syu cense
Event-Based Scheduling
a
You can create
y Ma job thatli directly references an event as the means to start the job, instead of
l
assigning e
n a schedule to the job. There are two types of events:
t a
S• User- or application-generated events: An application can raise an event to be consumed
by the Scheduler. The Scheduler reacts to the event by starting a job. An example of such
events: a running job completes; a file arrives on the file system; an account within the
database is locked; and the inventory reaches a low threshold.
• Scheduler-generated events: The Scheduler can raise an event to indicate state changes
that occur within the Scheduler itself. For example, the Scheduler can raise an event when a
job starts, when a job completes, when a job exceeds its allotted run time, and so on. The
consumer of the event is an application that performs some action in response to the event.
You can configure a job so that the Scheduler raises an event when the job’s state changes. You
do this by setting the raise_events job attribute. By default, a job does not raise any state
change events until you alter the raise_events attribute for a job. To alter this attribute, you
must first create the job by using the CREATE_JOB procedure and then use the
SET_ATTRIBUTE procedure to modify the attribute’s default value. The example shows that
the hr.do_backup job is altered, so that it raises an event if the job fails.

Oracle Database 11g: Administration Workshop II 18 - 20


Computer Pride Limited

Event-Based Scheduling (continued)


After you enable job state change events for a job, the Scheduler raises these events by
enqueuing messages onto the default event queue SYS.SCHEDULER$_EVENT_QUEUE.
The default Scheduler event queue is a secure queue. Depending on your application, you may
have to configure the queue to enable certain users to perform operations on it. See the Oracle
Streams Concepts and Administration documentation for information about secure queues.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

The default Scheduler event queue is intended primarily for Scheduler-generated events. Oracle
does not recommend the use of this queue for user applications, or user-defined events.

Event Type Description


JOB_STARTED The job is started.
JOB_SUCCEEDED The job is successfully completed.
JOB_FAILED The job failed, either by raising an error or by
abnormally terminating.
a b le
JOB_BROKEN The job is disabled and changed to the BROKEN
s fer
state, because it exceeded the number of failures
- t r an
defined by the MAX_FAILURES job attribute.
n on
JOB_COMPLETED a the values
The job is completed, because itsreached
a
) h uidejobฺ
set by the MAX_RUNS or END_DATE
attributes. m
co nt G
a i l ฺ
JOB_STOPPED The job is stopped
g m bytuadcall e to the STOP_JOB
u k i@ is S
procedure.
JOB_SCH_LIM_REACHED sThe
a th limit is reached. The job is not
y job’seschedule
i ( t o usbecause the delay in starting the job
M started,
s y uk nseexceeded the value of the SCHEDULE_LIMIT job
M a lice attribute.
l ey
JOB_DISABLED
n The job is disabled by the scheduler or by a call to
S t a the SET_ATTRIBUTE procedure.
JOB_CHAIN_STALLED A job running a chain is put into the
CHAIN_STALLED state. A running chain becomes
stalled if there are no steps running or scheduled to
run and the chain EVALUATION_INTERVAL is
set to NULL. The chain waits for manual
intervention.
JOB_ALL_EVENTS JOB_ALL_EVENTS is not an event, but a
constant, that provides an easy way for you to
enable all events.
JOB_OVER_MAX_DUR The job has run over the maximum time it was set
to be allowed to run.
JOB_RUN_COMPLETED A job run is completed. It either failed, succeeded,
or is stopped.

Oracle Database 11g: Administration Workshop II 18 - 21


Computer Pride Limited

Creating Complex Schedules


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

INCLUDE EXCLUDE INTERSECT


ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating Complex y k
u nsei
a s Schedules
c e database. When you create schedules, they are automatically
A schedule isM i
an objectlin the
l
saved.nYoueycan use combinations of schedules to create more complex schedules. By combining
Sta you can add specific dates to or exclude specific dates from a calendaring expression.
schedules,
You can use the following options when defining the repeat interval for a schedule:
• INCLUDE: Adds a list of dates to the calendaring expression results
• EXCLUDE: Removes a list of dates from the calendaring expression results
• INTERSECT: Uses only the dates that are common to two or more schedules

When creating schedules to be used in combinations, you can code the list of dates by including
hard-coded dates of the form [YYYY]MMDD or by including named schedules created with the
CREATE_SCHEDULE procedure. For example, you can specify a list of dates by using the
following values for the repeat interval of a schedule:
0115,0315,0325,0615,quarter_end_dates,1215
This string represents the dates January 15, March 15, March 25, June 15, December 15, and the
list of dates specified by the QUARTER_END_DATES schedule.
If you do not specify the optional year component for hard-coded dates in your schedule, the
dates are included for every year.

Oracle Database 11g: Administration Workshop II 18 - 22


Computer Pride Limited

Creating Job Chains

1. Create a chain object.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2. Define chain steps.


3. Define chain rules.
4. Starting the chain:
Job chain
– Enable the chain.
– Create a job that points to the chain.

ble
Job fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Job Chains
a syu cense
A chain is a named
y li of programs that are linked together for a combined objective. This is
M series
l e
knownnas “dependency scheduling.” An example of a chain may be the following:
Sta
Run program A and then program B, but only run program C if programs A and B complete
successfully, otherwise run program D.
Each position within a chain of interdependent programs is referred to as a step. Typically, after
an initial set of chain steps has started, the execution of successive steps depends on the
completion of one or more previous steps. To create and use a chain, you complete the following
steps in order. All procedures mentioned are part of the DBMS_SCHEDULER package, unless
noted otherwise.
1. Create a chain by using the CREATE_CHAIN procedure. The chain name can be
optionally qualified with a schema name (for example, myschema.myname).
2. Define (one or more) chain steps. Defining a step gives it a name and specifies what
happens during the step. Each step can point to one of the following:
- A program
- Another chain (a nested chain)
- An event
You define a step that points to a program or nested chain by calling the
DEFINE_CHAIN_STEP procedure.

Oracle Database 11g: Administration Workshop II 18 - 23


Computer Pride Limited

Creating Job Chains (continued)


To define a step that waits for an event to occur, you use the
DEFINE_CHAIN_EVENT_STEP procedure. Procedure arguments can point to an event
schedule or can include an in-line queue specification and event condition. A step that
points to an event waits until the specified event is raised. If the event occurs, the step
completes successfully.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

3. After creating the chain object, you define chain rules. Chain rules define when steps run,
and define dependencies between steps. Each rule has a condition and an action:
- If the condition evaluates to TRUE, the action is performed. The condition can contain
any syntax that is valid in a SQL WHERE clause. Conditions are usually based on the
outcome of one or more previous steps. For example, you may want one step to run if
the two previous steps succeeded, and another to run if either of the two previous steps
failed.
- The action specifies what is to be done as a result of the rule being triggered.
A typical action is to run a specified step. Possible actions include starting or stopping
a step. You can also choose to end the execution of the job chain, returning eitheraabl
e
value or a step name and error code. s fer
All rules added to a chain work together to define the overall behavior of-the t r n When
achain.
the job starts and at the end of each step, all rules are evaluated to see
n n action or actions
owhat
occur next. You add a rule to a chain with the DEFINE_CHAIN_RULE s a procedure. You call
h a ฺ
this procedure once for each rule that you want to add to) the chain.
m u i de
4. Starting the chain involves two actions:
a i l ฺco nt G
- Enable a chain with the ENABLE procedure.
g m t(A u e is always created disabled, so
dchain
you can add steps and rules to the
k S it is executed by any job.) Enabling an
i@chainisbefore
u h
t an error.
sy not sreturn
already enabled chain does
a e
u a job of type 'CHAIN'. The job action must refer to
- To run a chain, you
k i (Mmust tcreate
o
yu You scan
the chain name.
s n e use either event-based or time-based schedules for this job.
M a lice
le y
n
Sta

Oracle Database 11g: Administration Workshop II 18 - 24


Computer Pride Limited

Example of a Chain
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Dependency scheduling

START
Job Load_data_evt 1 Do_bulk_load 2

Stop_when_
disk_full_evt 5 3
Schedule Rebuild_indx

ble
fe r a
an4 s
END -
Run_reports t r
non
(HR.GEN_REPORTS)
a
has
BULK_LOAD_CHAIN
) i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
Example of a Chainyu
a
As an example
y li consider all the tasks and conditions that occur during a bulk data
Mof a chain,
l e
load. First,
n you must have data to load. Then load the data, observing the file system to make
t a
S that you do not run out of space during the load. After the data load completes, you need to
sure
rebuild the indexes defined on the updated tables. Then you run reports against the newly loaded
data. The slide shows an example of dependency scheduling.

Oracle Database 11g: Administration Workshop II 18 - 25


Computer Pride Limited

1. Creating a Chain Object


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1 ble
2 fe r a
3 ans
n - t r
4
5 a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s u cense
1. Creating a ChainyObject
a
On the ServerM
y li Chains from the Oracle Scheduler region. On the Scheduler Chains
page, select
l
page, you e
n can create or edit a job chain. On the Create Chain page, you must enter the name and
t a
S of the job chain. You can then choose whether the newly created job chain should be
owner
enabled or not. You can enable the chain at a later time.
PL/SQL example:
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => 'bulk_load_chain',
rule_set_name => NULL, evaluation_interval => NULL,
comments => 'Load data and run reports');
After naming the job chain and optionally providing a description, you enter the job chain steps,
one at a time. You can create job chain steps of the following type:
• A step that runs a program (PROGRAM)
• A step that is another job chain (SUBCHAIN)
• A step that uses a stored event-based schedule (EVENT_SCHEDULE)
Only one program can run during a step. Every step in a chain must be defined before the chain
can be enabled and used.

Oracle Database 11g: Administration Workshop II 18 - 26


Computer Pride Limited

2. Defining Chain Steps


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP (
1
chain_name => 'bulk_load_chain',
step_name => 'load_data_evt',
event_condition => 'tab.user_data.object_owner =
''HR'' and tab.user_data.object_name =
''DATA.TXT'' and tab.user_data.event_type =
''FILE_ARRIVAL'' ',
queue_spec => 'HR.LOAD_JOB_EVENT_Q');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
2 le
chain_name => 'bulk_load_chain', a b
step_name => 'do_bulk_load', s fer
program_name => 'hr.load_data_prog); - t r an
DBMS_SCHEDULER.DEFINE_CHAIN_STEP ( n o n
chain_name => 'bulk_load_chain', s a 3
step_name => 'rebuild_indx',
a
) h uideฺ
m
ฺco t G
program_name => 'hr.rebuild_indexes');
ail den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
2. Defining Chain Steps
y u ki se to
M as licestep
1. The load_data_evt
n
uses an event-based schedule. The load_data_evt step waits
for l e y
t a n a FILE_ARRIVAL event to be placed in HR.LOAD_JOB_EVENT_Q. This event notifies
S the Scheduler that the DATA.TXT data file has arrived on the file system. Because
queue_spec does not include an agent name, the specified queue is not a secure queue.
2. The do_bulk_load step performs a bulk data load into the schema tables.
3. The rebuild_indx step rebuilds the indexes for the tables following a data load.
4. The run_reports step runs a report against the new data. HR.GEN_REPORTS is another
job chain.
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'bulk_load_chain',
step_name => 'run_reports',
program_name => 'hr.gen_reports');
5. The stop_when_disk_full_evt step ends the chain execution if the system runs out
of disk space.
DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP (
chain_name => 'bulk_load_chain',
step_name => 'stop_when_disk_full_evt'
event_schedule_name => 'disk_full_sched')
Chain steps can also be created in Enterprise Manager. On the Create Chains page, navigate to
the Steps section and make your entries.
Oracle Database 11g: Administration Workshop II 18 - 27
Computer Pride Limited

3. Defining Chain Rules


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
syu cense
3. Defining Chain Rules
a
After you have
y Mspecifiedli the job chain steps, you can create rules for the job chain. Chain rules
l e
definenwhen steps run, and define dependencies between steps. Each rule has a condition and an
Sta If the condition evaluates to TRUE, the action is performed. The condition can also
action.
contain the Scheduler’s chain syntax.
To create a rule in EM, you click the Create button in the Rules region.
When entering the rule conditions, character strings should be entered in single quotation marks.
The graphical user interface (GUI) automatically escapes the quotation marks as needed when
executing the commands.
PL/SQL Example
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'bulk_load_chain',
condition => 'TRUE',
action => 'START load_data_evt,stop_when_disk_full_evt',
rule_name => 'dataload_rule1',
comments => 'start the chain');
Note: This PL/SQL example differs from the EM one in that it uses a user-defined rule name,
whereas the EM example shows the default generated name.

Oracle Database 11g: Administration Workshop II 18 - 28


Computer Pride Limited

4. Starting the Chain


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

BEGIN
DBMS_SCHEDULER.ENABLE ('bulk_load_chain');
END;
/

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'bulk_load_chain_job',
job_type => 'CHAIN',
a b le
job_action => 'bulk_load_chain',
s fer
repeat_interval => 'freq=daily;byhour=7;
- t r an
byminute=5;bysecond=0',
n on
enabled => TRUE);
s a
END;
) a
h ideฺ
/ o m Gu
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
4. Starting the Chain y u ki se to
After you have M as licreating
finished c en and modifying the job chain, you enable it by calling the
l y
eprocedure or enabling it from the Chains page in Enterprise Manager.
ENABLE
t a n
S run a chain, you must create a job. Set the job_type to 'CHAIN' and the job action to the
To
name of the job chain you want to execute. The rest of the arguments are configured as you
would configure them for any other type of job. Alternatively, the job calling the job chain can
be created and enabled using Enterprise Manager.

Oracle Database 11g: Administration Workshop II 18 - 29


Computer Pride Limited

Monitoring Job Chains


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
tra ns
[DBA | ALL | USER]_SCHEDULER_CHAINS
n -
[DBA | ALL | no
USER]_SCHEDULER_CHAIN_RULES
a
a s
[DBA | ALL | h eฺ
USER]_SCHEDULER_CHAIN_STEPS
) i d
[DBA | ALL | o m Gu
USER]_SCHEDULER_RUNNING_CHAINS
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Monitoring Job Chainsy u ki se to
M as licen view contains information about the chain owner and name;
The ALL_SCHEDULER_CHAINS
the rule
n l eyname and rule set owner for the chain; the number of rules; the number of steps;
set
Sta or not the chain is enabled; whether or not the chain uses an evaluation interval; and
whether
whether or not the chain uses a user-defined rule set.
The ALL_SCHEDULER_CHAIN_RULES view displays information such as the name and
owner of the chain for which the rule was defined; the rule name, owner, and condition; and the
action to be performed if the condition evaluates to TRUE.
The ALL_SCHEDULER_CHAIN_STEPS displays information such as the name and owner of
the chain for which the step was created; the step name; the program name and owner; whether
the step should be skipped or not; and whether or not the step should be paused after it
completes.
The ALL_SCHEDULER_RUNNING_CHAINS view contains information such as the chain
name and owner; the name and owner of the job that points to the chain; the name of the steps in
the chain and their current state; errors encountered by the chain step; the time at which the
chain step started and ended; how long it took the step to complete; and the name of the job
running the step, if it is currently executing.

Oracle Database 11g: Administration Workshop II 18 - 30


Computer Pride Limited

Summary

In this lesson, you should have learned how to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Simplify management tasks by using the Scheduler


• Create a job, program, and schedule
• Monitor job execution
• Use a time-based or event-based schedule for executing
Scheduler jobs

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 18 - 31


Computer Pride Limited

Practice 18 Overview:
Automating Tasks with the Scheduler
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Creating a job that runs a program outside the database


• Creating a program and a schedule
• Creating a job that uses a program and a schedule
• Create a lightweight job
• Monitoring job runs

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Note
a syu cense
This practice M i
y uses both lEnterprise Manager Database Control and SQL*Plus.
n l e
Sta

Oracle Database 11g: Administration Workshop II 18 - 32


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Administering the Scheduler

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Incorporate advanced Scheduler concepts


– Windows
– Window groups
– Job classes
– Consumer groups
• Use job chains to perform a series of related tasks
• Use advanced Scheduler concepts to prioritize jobs ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Objectives k i
a s yu ense
For information
y licvarious Scheduler components and their interaction, see the Oracle
M about the
t a nleAdministrator’s Guide.
Database
S detailed information about the DBMS_SCHEDULER package, see the Oracle Database
For
PL/SQL Packages and Types Reference.

Oracle Database 11g: Administration Workshop II 19 - 2


Computer Pride Limited

Advanced Scheduler
Features
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Resource Resource Window


consumer group plan group

Job chain Job class Window

ble
fe r a
Program Job Schedule ans
n - t r
a no
a s
) h i d eฺ
Arguments Arguments
c o m Time
G u Event

ail den t
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
ki se to
Advanced ScheduleruConcepts
y
Using advanced
s cefeatures,
aScheduler n you can exercise more control over various aspects of
y M l i
a n le such as job windows and prioritizing jobs. These advanced features are summarized
scheduling,
t
below,
S and are discussed in detail in the following slides.
• A window is represented by an interval of time with a well-defined beginning and end, and
is used to activate different resource plans at different times. This allows you to change
resource allocation during a time period such as time of day or time of the sales year.
• A window group represents a list of windows, and allows for easier management of
windows. You can use a window or window group as the schedule for a job to ensure that
the job runs only when a window and its associated resource plan are active.
• A job class defines a category of jobs that share common resource usage requirements and
other characteristics. A job class groups jobs into larger entities.
• A resource consumer group associated with the job class determines the resources that are
allocated to the jobs in the job class.
• A resource plan enables users to prioritize resources (most notably CPU) among resource
consumer groups.

Oracle Database 11g: Administration Workshop II 19 - 3


Computer Pride Limited

Job Classes

Job classes provide a way to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Assign the same set of attribute values to member jobs


• Set the service attribute of a job class to a desired database
service name
• Set resource allocation for member jobs
• Create the link between the Database Resource Manager
and the Scheduler
• Group jobs for prioritization ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Job Classes k i
a s yu ense
Job classes provide
y M a way licto assign the same set of attribute values to member jobs. Each job
a n le a set of attributes, such as logging level. When you assign a job to a job class, the
class specifies
jobt
S inherits those attributes. For example, you can specify the same policy for purging log
entries for all payroll jobs. In addition, job classes provide a way to:
• Set the service attribute of a job class to a desired database service name. This determines
the instances in a Real Application Clusters environment that run the member jobs, and
optionally the system resources that are assigned to member jobs.
• Set resource allocation for member jobs. Job classes provide the link between the Database
Resource Manager and the Scheduler, because each job class can specify a resource
consumer group as an attribute. Member jobs then belong to the specified consumer group,
and are assigned resources according to settings in the current resource plan. Alternatively,
you can leave the resource_consumer_group attribute as NULL and set the service
attribute of a job class to a desired database service name. That service can in turn be
mapped to a resource consumer group. If both the resource_consumer_group and
service attributes are set, and the designated service maps to a resource consumer group, the
resource consumer group named in the resource_consumer_group attribute takes
precedence.

Oracle Database 11g: Administration Workshop II 19 - 4


Computer Pride Limited

Job Classes (continued)


• Group jobs for prioritization. Within the same job class, you can assign priority values of
1–5 to individual jobs so that if two jobs in the class are scheduled to start at the same time,
the one with the higher priority takes precedence. This ensures that you do not have a less
important job preventing the timely completion of a more important one. If two jobs have
the same assigned priority value, the job with the earlier start date takes precedence. If no
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

priority is assigned to a job, its priority defaults to 3.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 19 - 5


Computer Pride Limited

Creating a Job Class


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

bl e
fe r a
EXECUTE DBMS_SCHEDULER.CREATE_JOB_CLASS(-t-ra
ns
job_class_name => 'ADMIN_JOBS', - no
n
s a
) h a
resource_consumer_group => 'DAYTIME_JOBS',
e ฺ -

o m u id
logging_level => DBMS_SCHEDULER.LOGGING_OFF) -
ilฺc
service_name => RACDB1; t G
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating a Job Classuki
a s y ense
You can use the
y ic
M CREATE_JOB_CLASS
l procedure of the DBMS_SCHEDULER package to
e class. A class always belongs to the sys schema. To create a class, you must have
create a ljob
n
the t a
S MANAGE SCHEDULER privilege.
After a job class has been created, you can specify jobs as members of this job class when you
create the jobs, or after the jobs are created, by using the SET_ATTRIBUTE procedure of the
DBMS_SCHEDULER package.
If you are using Enterprise Manager Database Control, use the Job Class page to create or edit a
job class that you will assign to a job. Enter the name of the job class and the resource consumer
group with which this job class is associated. You can select the resource consumer group by
using the search function.
There is a default job class named DEFAULT_JOB_CLASS that is created with the database. If
a job is not associated with a job class, then the job belongs to this default job class.
If a resource consumer group is not specified when a job class is created, the job class maps to
the DEFAULT_CONSUMER_GROUP resource consumer group. Jobs in the default job class or in
a job class associated with the default resource consumer group may not be allocated enough
resources to complete their tasks when the Resource Manager is enabled.
In addition, you can assign a job class an affinity to a specific service in a RAC environment.

Oracle Database 11g: Administration Workshop II 19 - 6


Computer Pride Limited

Windows

• The priority of jobs can change over a period of time.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Windows can start jobs or change resource allocation


among jobs for various time periods of the day, week, and so
on.
• Windows work with job classes to control resource
allocation.
• A job that runs within a window has
resources allocated to it according le
a b
to the consumer group of its job
s fer
class and the resource plan of
- t r an
the window. non a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Windows
y u ki se to
The priority of
M as canlichange
jobs c en over a period of time. For example, you might want to allocate a
l ey of the database resources to data warehouse loading jobs at night and allocate a
high percentage
n
Sta percentage of the resources during the day to the application jobs. To accomplish this,
higher
you can change the database resource plan by using a Scheduler window.
You create windows to automatically start jobs or to change resource allocation among jobs
during various time periods of the day, week, and so on. A window is represented by an interval
of time with a well-defined beginning and end, such as “from 12:00 AM to 6:00 AM.”
Windows work with job classes to control resource allocation. Each window specifies the
resource plan to activate when the window opens (becomes active), and each job class specifies
a resource consumer group or specifies a database service, which can map to a consumer group.
A job that runs within a window, therefore, has resources allocated to it according to the
consumer group of its job class and the resource plan of the window.

Oracle Database 11g: Administration Workshop II 19 - 7


Computer Pride Limited

Creating a Window

Create a window for the month of December that uses the


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

END_OF_YEAR resource plan and is active every night from


6:00 PM to 6:00 AM Eastern Standard Time (EST).

BEGIN
DBMS_SCHEDULER.CREATE_WINDOW(
window_name => 'DEC_NIGHTS',
resource_plan => 'END_OF_YEAR',
start_date => '01-DEC-07 06.00.00 PM EST',
a b le
repeat_interval => 'FREQ=DAILY; BYHOUR=18',
s fer
duration => '0 12:00:00',
- t r an
end_date => '31-DEC-07 06.00.00 AM EST',
n on
comments => 'Every day at 6:00 PM');
s a
END; a
) h uideฺ
/ o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Creating a Window uki e
y s
asif it islicineeffect.
n Only one window can be in effect at any given time. In the
A window is M open
example l y in the slide:
eshown
n
S• taThe window opens (becomes active) at 6:00 PM on December 1, 2007
• The duration, specified as an INTERVAL DAY TO SECOND data type, indicates that the
window closes at 6:00 AM on December 2, 2007
• The next time the window opens is calculated using the value for REPEAT_INTERVAL,
which evaluates to 6:00 PM on December 2, 2007
• At 6:00 AM on December 31, 2007, the window closes and is disabled. While the
DEC_NIGHTS window is open, the resources allocated to the jobs are determined by the
guidelines specified in the END_OF_YEAR resource plan.

Oracle Database 11g: Administration Workshop II 19 - 8


Computer Pride Limited

Creating a Window
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Creating a Window (continued) i
a s yu ense
Windows canM
y lic using Enterprise Manager (EM). From the Database home page,
also be created
click the
a n leServer tab, and then click Windows under the Oracle Scheduler section. The example
t
inSthe slide creates the same window as the DBMS_SCHEDULER.CREATE_WINDOW procedure
illustrated in the previous slide.

Oracle Database 11g: Administration Workshop II 19 - 9


Computer Pride Limited

Prioritizing Jobs Within a Window


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Job Priority

Job1 Job2 Job1 1

APPL_JOBS Job2 2
Job3
Job3 3
OTHER
ble
Job4 Job5 Job4 5
fe r a
ans
ADMIN_JOBS Job5
n2- t r
a no
Daytime window a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Prioritizing Jobs Within k i
u nWindow
a
a s y e se
When creating
y c in a database, you need a way to align the job processing with your
Mmultiplelijobs
business
a n lerequirements and specify which jobs have the highest priority. For a particular window,
yout
S may have several classes of jobs running, each with its own priority.
Job classes are used to categorize jobs. The job class maps to a resource consumer group. The
active resource plan determines the resources allocated to each resource consumer group, and
thus to each job class.
There are two levels at which jobs can be prioritized: at the class level and at the job level.
• The first prioritization is at the class level, using resource plans. Prioritization among jobs
of different classes is done purely on a class resource allocation basis.
• The second prioritization is within the class, using the job priority attribute of the job.
Prioritization levels are relevant only when two jobs within the same class are supposed to start
at the same time. The job with the higher priority starts first.
Prioritization is not guaranteed for jobs in different job classes. For example, a high-priority job
in the APPL_JOBS job class might not get started before a low-priority job in the
ADMIN_JOBS job class, even if they share the same schedule. If the APPL_JOBS job class has
a lower level of resource available, then the high-priority job in that class has to wait for
resources to become available, even if there are resources available to lower-priority jobs in a
different job class.
Oracle Database 11g: Administration Workshop II 19 - 10
Computer Pride Limited

Creating an Array of
Lightweight Jobs
1. Declare variables of types sys.job and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

sys.job_array:
DECLARE
newjob sys.job;
newjobarr sys.job_array;

2. Initialize the job array:

BEGIN
newjobarr := SYS.JOB_ARRAY();
ble
fe r a
s
tran
3. Size the job array to hold the number of jobs needed:
n -
o
newjobarr.EXTEND(100); s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
ki se toJobs
Creating an Array ofuLightweight
y
A more efficient
s to create
away c en a set of jobs is the use of a job array. This also applies to
M l i
l eyjobs. The job array type and CREATE_JOBS procedure are new to the
lightweight
n
Sta
DBMS_SCEHDULER packager in Oracle Database 11g.
In the example in the slide, 100 job specifications are created in a job array and submitted to the
job queue in a single transaction. Notice that for a lightweight job there is a very limited amount
of information needed. In the example, the start_time parameter defaults to NULL, so the
job is scheduled to start immediately. The example continues on the next page.
1. Declare the variable to hold a job definition and a job array variable.
2. Initialize the job array using the SYS.JOB_ARRAY constructor. This creates a place for
one job in the array.
3. Set the size of the array to the number of expected jobs.
Note: If the array is very small, the performance will not be significantly better than submitting
a single job.

Oracle Database 11g: Administration Workshop II 19 - 11


Computer Pride Limited

Creating Lightweight Jobs

4. Place jobs in the job array:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

FOR i IN 1..100 LOOP


newjob := SYS.JOB(job_name => 'LWTJK'||to_char(i),
job_style => 'LIGHTWEIGHT',
job_template => 'MY_PROG',
enabled => TRUE );
newjobarr(i) := newjob;
END LOOP;

5. Submit the job array as one transaction: ble


fe r a
ans
DBMS_SCHEDULER.CREATE_JOBS(newjobarr,
n - t r
'TRANSACTIONAL');
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating Lightweight k i
Jobs
a s yu ense
M job andlicplace it in the array. In the slide example, the only difference is the
4. Create each
y
name
a n leof the job. The start_time variable of the job is omitted and it defaults to NULL,
t
S indicating that the job will run immediately.
5. Use the CREATE_JOBS procedure to submit all the jobs in the array as one transaction.
The full code of this example is:
DECLARE
newjob sys.job;
newjobarr sys.job_array;
BEGIN
-- Create an array of JOB object types
newjobarr := sys.job_array();

-- Allocate sufficient space in the array


newjobarr.extend(100);

-- Add definitions for jobs


FOR i IN 1..100 LOOP
-- Create a JOB object type
newjob := sys.job(job_name => 'LWTJK' || to_char(i),
job_style => 'LIGHTWEIGHT',
job_template => 'PROG_1',
enabled => TRUE );
Oracle Database 11g: Administration Workshop II 19 - 12
Computer Pride Limited

Creating Lightweight Jobs (continued)


-- Add job to the array
newjobarr(i) := newjob;
END LOOP;

-- Call CREATE_JOBS to create jobs in one transaction


DBMS_SCHEDULER.CREATE_JOBS(newjobarr, 'TRANSACTIONAL');
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

END;
/

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 19 - 13


Computer Pride Limited

Viewing Lightweight Jobs in Dictionary

View lightweight jobs in *_SCHEDULER_JOBS:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> SELECT job_name, job_style, program_name


2 FROM USER_SCHEDULER_JOBS;

JOB_NAME JOB_STYLE PROGRAM_NAME


----------------- ----------- -------------------
LWTJX LIGHTWEIGHT PROG_3

View job arguments with *_SCHEDULER_JOB_ARGS:


ble
SQL> select job_name, argument_name, argument_type, value
fe r a
n s
tra
2 FROM USER_SCHEDULER_JOB_ARGS;
n -
JOB_NAME ARGUMENT_NAME ARGUMENT_TYPE VALUE a no
a s
---------- -------------- --------------
VARCHAR2om)
h eฺ
----------
i d
LWTJX ARG1
i l ฺ c nt GuTEST_VALUE

g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Viewing LightweightuJobs k to u
i (Min eDictionary
The changes to a sy ceviews
dictionary
ns to support lightweight are small.
li
y M jobs are
l e
• Lightweight
n visible through the same views as regular jobs are:
t a
S DBA_SCHEDULER_JOBS, ALL_SCHEDULER_JOBS, and USER_SCHEDULER_JOBS.
• Arguments to lightweight jobs are visible through the same views as those of regular jobs:
DBA_SCHEDULER_JOB_ARGS, ALL_SCHEDULER_JOB_ARGS, and
USER_SCHEDULER_JOB_ARGS.
• Because lightweight jobs are not database objects, they are not visible through the
DBA_OBJECTS, ALL_OBJECTS, and USER_OBJECTS views.

Oracle Database 11g: Administration Workshop II 19 - 14


Computer Pride Limited

PL/SQL APIs

• Methods that work on lightweight jobs:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

– CREATE_JOB
– CREATE_JOBS
– SET_ATTRIBUTE
– GET_ATTRIBUTE
– SET_JOB_ARGUMENT_VALUE
– RESET_JOB_ARGUMENT_VALUE
– e
bl
STOP_JOB, DROP_JOB
– RUN_JOB · fe r a
ans
• Methods that do not apply to lightweight jobs: n - t r
– SET_JOB_ANYDATA_VALUE a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
PL/SQL APIs k i
a s yu ense
Lightweight jobs
y ic modified and dropped using DBMS_SCHEDULER APIs. Most calls
M are created
l
a n le regular jobs work on lightweight jobs. The methods SET_ATTRIBUTE,
to manipulate
S t
GET_ATTRIBUTE, SET_JOB_ARGUMENT_VALUE, RESET_JOB_ARGUMENT_VALUE,
STOP_JOB, DROP_JOB, and RUN_JOB work with lightweight jobs. The
SET_JOB_ARGUMENT_VALUE procedure can be used to set arguments of lightweight jobs but
only if the arguments are of type VARCHAR2. The job-related DBMS_SCHEDULER calls that do
not apply to lightweight jobs are SET_JOB_ANYDATA_VALUE because lightweight jobs
cannot take ANYDATA arguments.

Oracle Database 11g: Administration Workshop II 19 - 15


Computer Pride Limited

Generic Scheduler Data Dictionary Views

Useful views for managing the Scheduler:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• *_SCHEDULER_JOBS: Shows all jobs, enabled as well as


disabled
• *_SCHEDULER_SCHEDULES: Shows all schedules
• *_SCHEDULER_PROGRAMS: Shows all programs
• *_SCHEDULER_RUNNING_JOBS: Shows state information
about all jobs that are currently being run
• *_SCHEDULER_JOB_LOG: Shows all state changes made to ble
jobs fe ra
t r a ns
• *_SCHEDULER_JOB_RUN_DETAILS: Shows all completed o n -
n
job runs sa ha ideฺ
m Gu)
ฺ c o t
a il e n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Scheduler Data Dictionary
y u ki Views
s e
s cefor
is aacontainer
The job table M
n all the jobs, with one table per database. The job table stores
l i
l eyfor all jobs such as the owner name or the level of logging. You can find this
information
n
Sta
information in the *_SCHEDULER_JOBS views.
Jobs are database objects, and can, therefore, accumulate and take up too much space. To avoid
this, job objects are automatically dropped by default after completion. This behavior is
controlled by the auto_drop job attribute.
There are many views available to the DBA and privileged users that provide essential operating
information regarding the scheduler, jobs, schedules, windows, and so on. These views include:
• *_SCHEDULER_PROGRAM_ARGS: Shows all arguments defined for all programs as well as
the default values if they exist
• *_SCHEDULER_JOBS: Shows all jobs, enabled as well as disabled
• *_SCHEDULER_RUNNING_CHAINS: Shows all chains that are running
• *_SCHEDULER_CHAIN_STEPS: Shows all steps for all chains
• *_SCHEDULER_CHAINS: Shows all chains
• *_SCHEDULER_CHAIN_RULES: Shows all rules for all chains
• *_SCHEDULER_GLOBAL_ATTRIBUTE: Shows the current values of Scheduler attributes
• *_SCHEDULER_JOB_ARGS: Shows all set argument values for all jobs
• *_SCHEDULER_JOB_CLASSES: Shows all job classes

Oracle Database 11g: Administration Workshop II 19 - 16


Computer Pride Limited

Scheduler Data Dictionary Views (continued)


• *_SCHEDULER_WINDOWS show all windows.
• *_SCHEDULER_JOB_RUN_DETAILS show all completed (failed or successful) job runs.
• *_SCHEDULER_WINDOW_GROUPS show all window groups.
• *_SCHEDULER_WINGROUP_MEMBERS show the members of all window groups, one row
for each group member.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• *_SCHEDULER_JOB_LOG show all state changes made to jobs.


• *_SCHEDULER_CREDENTIALS show all credentials.
• *_SCHEDULER_JOB_ROLES show all jobs by database role.

Note: In the views listed above, the asterisk at the beginning of a view name can be replaced
with DBA, ALL, or USER.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 19 - 17


Computer Pride Limited

Summary

In this lesson, you should have learned how to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Incorporate advanced Scheduler concepts


– Windows
– Window groups
– Job classes
– Consumer groups
• Use job chains to perform a series of related tasks
• Use advanced Scheduler concepts to prioritize jobs ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 19 - 18


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Globalization

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Determine a correct database character set that meets your


business requirements
• Obtain globalization support configuration information
• Customize language-dependent behavior for the database
and individual sessions
• Specify different linguistic sorts for queries
• Retrieve data that matches a search string ignoring case or able
accent differences s fer
n a
o n -tr
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Objectives
y u ki se to
as see
For more information,
M l i c ethen Oracle Database Globalization Support Guide.
n l ey
Sta

Oracle Database 11g: Administration Workshop II 20 - 2


Computer Pride Limited

Globalization Support Features

• Language support
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Territory support
• Character set support
• Linguistic sorting
• Message support French Japanese
• Date and time formats data data
• Numeric formats
ble
• Monetary formats
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Globalization Support k i
Features
a s yu ense
Different countries
y ic
M andlgeographies dictate different cultural conventions that directly affect

a n le Globalization support ensures that utilities and error messages, sort order, and date,
data formats.
t
time,
S monetary, numeric, and calendar conventions automatically adapt to the native language.
Users can interact, store, process, and retrieve data in their native languages and formats:
• Time zones can be used to support daylight saving time.
• National calendars such as Gregorian, Japanese, Imperial, and Thai Buddha are supported.
• Currency symbols reflect the local economy and ISO conventions. Credit and debit symbols
also differ from location to location.
Oracle’s globalization support is implemented with Oracle NLS Runtime Library (NLSRTL).
NLSRTL provides a comprehensive suite of language-independent functions that allow proper
text and character processing and language convention manipulations. The behavior of these
functions for a specific language and territory is governed by a set of locale-specific data that is
identified and loaded at run time.
You can control the language-dependent operations by using several parameters and
environment variables on both the client and the server sides. The server and the client may run
in the same or different locations. When the client and the server use different character sets, the
Oracle database handles character set conversion automatically.

Oracle Database 11g: Administration Workshop II 20 - 3


Computer Pride Limited

What Every DBA Needs to Know

• What is a character set?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• How are character sets used?


• Problems to avoid
• Choosing your character set
• Obtaining character set information
• Specifying language-dependent behavior
• Using linguistic searching and sorting
ble
• Using data conversion
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 20 - 4


Computer Pride Limited

What Is a Character Set?

The Oracle database supports different classes of character-


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

encoding schemes:
• Single-byte character sets
– 7-bit
– 8-bit
• Multibyte character sets, including Unicode

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
What Is a Character u k
Set?i (M e to u
When computer a sy cprocess
systems e ns characters, they use numeric codes instead of the graphical
li
y Mof the character.
l e
representation
n An encoded character set maps numeric codes to characters that
aS t a
computer or terminal can display and receive. The Oracle database currently supports about 30
encoded character sets, but many more languages and territories (about 100). This is possible
because Unicode is a universal character set, which encompasses most major scripts of the
modern world.
Different character sets support different character repertoires. Because character sets are
typically based on a particular writing script, they can support more than one language.
However, script-based character sets are restricted in the sense that they are limited to groups of
languages based on similar scripts. Universal character sets encompass most major scripts of the
modern world and provide a more useful solution to multilingual support. For information about
the Unicode standards, see the Web site at http:www.unicode.org.
The Oracle database provides different classes of encoding schemes:
• Single-byte
• Varying-width multibyte
• Universal

Oracle Database 11g: Administration Workshop II 20 - 5


Computer Pride Limited

What Is a Character Set? (continued)


Single-Byte Character Sets
In a single-byte character set, each character occupies one byte. Single-byte 7-bit encoding
schemes can define up to 128 (27) characters; single-byte 8-bit encoding schemes can define up
to 256 (28) characters.
Examples of Single-Byte Schemes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

7-bit character set:


• American Standard Code for Information Interchange (ASCII) 7-bit American
(US7ASCII)
8-bit character set:
• International Organization for Standards (ISO) 8859-1 West European (WE8ISO8859P1)
• DEC 8-bit West European (WE8DEC)
• Extended Binary Coded Decimal Interchange Code (EBCDIC) Code Page 1144 8-bit Italian
(I8EBCDIC1144)
Note: ASCII-based character sets are supported only on ASCII-based platforms. Similarly, ale
b
e r
you can use an EBCDIC-based character set only on EBCDIC-based platforms.
a n sf
Multibyte Character Sets o n -tr
A varying-width multibyte character set is represented by one or more
n per character.
abytes
s
hasupport. ฺ multibyte
Multibyte character sets are commonly used for Asian language ) i d eSome
encoding schemes use the value of the most significant m Gu whether a byte represents
cobit tonindicate
i l ฺ
a a character. t
a single byte or is part of a series of bytes representing
g m u d e However, other character-
encoding schemes differentiate single-byte
k i s St characters. A shift-out control code,
@fromimultibyte
u
sent by a device, indicates that anyysuccessive
s thbytes are double-byte characters until a shift-in
a
code is encountered. Shift-sensitive e
us schemes are used primarily on IBM platforms.
M toencoding
i (
s y uk nsMultibyte
Examples of Varying-Width e Schemes
• Shift-JISM a e
lic (JA16SJIS)
16-bit Japanese
• MS l e y
t a n Windows Code Page 950 with Hong Kong Supplementary Character Set HKSCS-2001
S (ZHT16HKSCS)
• Unicode 4.0 UTF-8 Universal character set (AL32UTF8)

Oracle Database 11g: Administration Workshop II 20 - 6


Computer Pride Limited

Understanding Unicode

AL32UTF8 AL16UTF16
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

c 63 0063
á C3 91 Supplementary 00E1
characters
t 74 0074
EE AA 9E A89E
F0 9D 84 9E D834 DD1E
d 64 0064 ble
fe r a
ö C3 B6 00F6 ans
n - t r
o
D0 A4 an
0424
s
h a eฺ
) byte sequences
Encoding: Representing characters with m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Understanding Unicode k i
a s yu ense
Unicode is a universal
y M lic character set that enables information from any language to be
encoded
le a single character set. Unicode provides a unique code value for every character,
storednusing
a
S t
regardless of the platform, program, or language.
The Unicode standard has been adopted by many software and hardware vendors. Many
operating systems and browsers now support Unicode. Unicode is required by standards such as
XML, Java, JavaScript, LDAP, and WML. It is also synchronized with the ISO/IEC 10646
standard.
AL32UTF8 Encoding
AL32UTF8 encoding is the 8-bit encoding of Unicode. It is a variable-width type of encoding
and also a strict superset of ASCII. A strict superset means that each and every character in 7-bit
ASCII is available in AL32UTF8 with the same corresponding codepoint value.
One Unicode character can be 1, 2, 3, or 4 bytes in this encoding. Characters from the European
scripts are represented in either 1 or 2 bytes; characters from most Asian scripts are represented
in 3 bytes, whereas supplementary characters are represented in 4 bytes.

Oracle Database 11g: Administration Workshop II 20 - 7


Computer Pride Limited

Understanding Unicode (continued)


AL16UTF16 Encoding
AL16UTF16 encoding is the 16-bit encoding of Unicode.
One Unicode character can be 2 to 4 bytes in this encoding. Characters from both European
(including ASCII) and most Asian scripts are represented in 2 bytes. Supplementary characters
are represented in 4 bytes. AL16UTF16 is the main Unicode encoding that is used by both
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Microsoft Windows 2000 and Windows XP.


Supplementary Characters
The initial version of Unicode used the 2-byte encoding format. By using 16 bits for every code
point, a total of 65,536 characters can be represented. However, there is a need to support many
more characters. For example, the Chinese-speaking community alone uses more than 55,000
characters.
For languages such as Chinese, Japanese, and Korean, there are still tens of thousands of
ideograms that are not yet encoded. And even though many of these are rarely used characters, e
they are still present in documents that must be preserved electronically. r a bl
s e
ftaking
To meet this requirement, the Unicode Standard defines supplementary characters. nBy
tra an
two 16-bit code points (also known as surrogate pairs) to represent a single n -
character,
additional 1,048,576 characters can be defined. a no
a s
The first batch of the supplementary characters—44,944 of them—was) h i d eฺ in the Unicode
added
standard 3.1 released in March 2001. Together with the m
co49,194 u existing characters in
already
G
i l
Unicode 3.0, there are now a grand total of 94,140aencoded
ฺ n t
g m u d echaracters in Unicode 3.1. This
introduces more complexity into the Unicode
k i i s St but far less than managing a large
@ Standard,
syu Database
number of different encodings. Oracle
a e th supports the Unicode 4.0 standard.
Note: Notice above that UTF-16
i ( M andt o us with hyphens, refer to the Unicode Standard
UTF-8,
encodings, whereas y
s uk AL32UTF8,
UTF8,
n se and AL16UTF16, without hyphens, refer to Oracle
database charactera
M sets based
l e
ic on the Unicode Standard.
Note: n l e y
For details on Oracle’s support for Unicode, see the Oracle Database Globalization
t a
S Guide.
Support

Oracle Database 11g: Administration Workshop II 20 - 8


Computer Pride Limited

How Are Character Sets Used?

• Oracle Net compares the client NLS_LANG setting to the


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

character set on the server.


• If needed, conversion occurs automatically and
transparently.

NLS_LANG
ble
fe r a
Oracle Net ans
n - t r
n o
Client a
Server
s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
How Are Character Sets k i
u Used?
a s y e n se
The NLS_LANG
y lic defines a client terminal’s character-encoding scheme. Different
M parameter
le use different encoding schemes. Data passed between the client and the server is
clientsncan
a
S t
converted automatically between the two encoding schemes. The database’s encoding scheme
should be a superset, or equivalent, of all the clients’ encoding schemes. The conversion is
transparent to the client application.
When the database character set and the client character set are the same, the database assumes
that the data being sent or received is of the same character set, so no validations or conversions
are performed.
Character set conversion may be required in a client/server environment, if a client application
resides on a different platform than the server and if the platforms do not use the same character-
encoding schemes. Character data passed between the client and the server must be converted
between the two encoding schemes. Character conversion occurs automatically and
transparently through Oracle Net.

Oracle Database 11g: Administration Workshop II 20 - 9


Computer Pride Limited

Problems to Avoid

Example:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NLS_LANG:
AL32UTF8 Oracle Net

Client Server
Windows English Database character set: e
Code page: WE8MSWIN1252 AL32UTF8 r a bl
sfe
No conversion occurs, because it does not seem to be tran
o n -
required.
s an
ha eฺ
Issue: Invalid data are entered into the database.
) id
o m G u
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Problems to Avoid uki e
y
as enters s
ea ndatabase when the NLS_LANG parameter is not set properly on the
Invalid data usually
M l i c
l
client. The
n eyNLS_LANG value should reflect the encoding of the incoming data.
S• taWhen the NLS_LANG parameter is set properly, the database can automatically convert
incoming data from the client operating system.
• When the NLS_LANG parameter is not set properly, the data entering the database is not
converted properly.
For example, suppose that the database character set is AL32UTF8, the client is an English
Windows operating system (code page: WE8MSWIN1252), and the NLS_LANG setting on the
client is AL32UTF8. Data entering the database is encoded in WE8MSWIN1252 and is not
converted to AL32UTF8 data because the NLS_LANG setting on the client matches the database
character set. Thus the Oracle database assumes that no conversion is necessary, and invalid data
is entered into the database.

Oracle Database 11g: Administration Workshop II 20 - 10


Computer Pride Limited

Another Sample Problem


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

CREATE DATABASE ...


CHARACTER SET US7ASCII
NATIONAL CHARACTER SET
UTF8 ...

bl e
fe r a
ans
n - t r
a no
a s
) h
% export NLS_LANG=‘SIMPLIFIED
i d eฺ
CHINESE_HONG m Gu
co nKONG.ZHS16GBK’
i l ฺ t
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Another Sample Problem k i
a s yu ense
For example, M
y ic character set is US7ASCII and you are using Simplified Chinese
your database
l
Windows
a n leas your client terminal. By setting NLS_LANG to SIMPLIFIED CHINESE_HONG
S t
KONG.ZHS16GBK as the client character set, you can store multibyte Simplified Chinese
characters inside a single-byte database. This means that the database treats these characters as
single-byte characters. Therefore, all SQL string manipulation functions (such as SUBSTR or
LENGTH) are based on bytes rather than characters. All of your non-ASCII characters could be
lost following an export and import into another database.

Oracle Database 11g: Administration Workshop II 20 - 11


Computer Pride Limited

Choosing Your Character Set

• Trade-offs to consider
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Choosing the correct character set that meets your business


requirements now and in the future
• Specifying the character set
• Changing the character set after database creation

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Choosing Your Character k i
u nSet
a s y e se
For best performance,
y M lic a character set that avoids character set conversion and uses the
choose

a n le encoding for the languages desired. Single-byte character sets result in better
most efficient
S t
performance than multibyte character sets, and they also are the most efficient in terms of space
requirements. However, single-byte character sets limit how many languages you can support.
To choose your correct database character set, evaluate your current and future business
requirements, as well as technical requirements (for example, the XML and Java standards
require Unicode). In general, Oracle recommends the use of Unicode for all new databases,
because it is the most flexible character set and avoids future conversions.
To specify the character set, use the CREATE DATABASE statement with the CHARACTER SET
and NATIONAL CHARACTER SET clauses. If you do not use the NATIONAL CHARACTER
SET clause, then it defaults to AL16UTF16.
You may need to change the character set after database creation, to support unforeseen
requirements, for example, to provide support for new data sources (XA, data warehousing, and
so on). This can often be a time-consuming and costly process. In most cases, you need to do a
full export or import to properly convert all data to the new character set.

Oracle Database 11g: Administration Workshop II 20 - 12


Computer Pride Limited

Database Character Sets and


National Character Sets
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Database Character Sets National Character Sets

Defined at creation time Defined at creation time

Cannot be changed without Can be exchanged


re-creation (exceptions in certain
configurations)
Store data columns of type CHAR, Store data columns of type
VARCHAR2, CLOB, LONG NCHAR, NVARCHAR2, NCLOB
ble
Can store varying-width character Can store Unicode using either
fe r a
sets AL16UTF16 or UTF8
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Database Character u k
Sets i (and eNational Character Sets
s y
a character n s
e set is used to identify and to hold SQL and PL/SQL source code,
Because the database
M l i c
l ey either EBCDIC or 7-bit ASCII as a subset, whichever is native to the platform.
it mustnhave
Sta it is not possible to use a fixed-width, multibyte character set as the database
Therefore,
character set; you can use this only as the national character set.
A national character set is an alternate character set that enables you to store Unicode character
data in a database that does not have a Unicode database character set. SQL NCHAR,
NVARCHAR2, and NCLOB data types support Unicode data only. You can use either the UTF8
or the AL16UTF16 character set.

Oracle Database 11g: Administration Workshop II 20 - 13


Computer Pride Limited

Obtaining Character Set Information


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> SELECT parameter, value


2 FROM nls_database_parameters
3 WHERE parameter LIKE '%CHARACTERSET%';

PARAMETER VALUE
----------------------- -------------
NLS_CHARACTERSET WE8ISO8859P1
NLS_NCHAR_CHARACTERSET AL16UTF16
ble
fe r a
2 rows selected.
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Obtaining CharacteruSet k i (Information
a s y ense
y M lic
Use the NLS_DATABASE_PARAMETERS view to display the permanent NLS settings for the
database,
a n leincluding the database and national character sets. This view contains the explicitly set
t
values,
S as well as the default values used by the database.

Oracle Database 11g: Administration Workshop II 20 - 14


Computer Pride Limited

Specifying Language-Dependent Behavior

Initialization parameters for the database server


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Environment variables for the clients


ALTER SESSION command

SQL function

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
SELECT sysdate FROM m
co dual;G u
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Specifying Language-Dependent i
u nse Behavior
s y
a retrieving e data for most contemporary languages in a database, additional
Beyond storing
y M and l i c
supportn iseavailable
l for a subset of the languages. The database can display dates by using local
t
date a
S and time formats and can sort text data according to cultural conventions. The database also
supports cultural conventions that are specific to geographical locations, or territories, such as
numeric and monetary conventions.
NLS parameters determine the locale-specific behavior on both the client and the server. There
are four ways to specify national language support (NLS) parameters:
• As initialization parameters on the server side to specify the default server environment.
(These default settings have no effect on the client side.)
• As environment variables for the client to specify locale-dependent behavior overriding the
defaults set for the server
• Using the ALTER SESSION command to override the defaults set for the client and the
server
• In SQL functions, to explicitly to hard-code NLS behavior for an application or query
overriding the default values that are set for the server and client, as well as any values
specified with an ALTER SESSION statement

Oracle Database 11g: Administration Workshop II 20 - 15


Computer Pride Limited

Specifying Language-Dependent
Behavior for the Session
• Specify the locale behavior with the NLS_LANG environment
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

variable:
– Language
– Territory
– Character set

NLS_LANG=FRENCH_CANADA.WE8ISO8859P1

• Set other NLS environment variables to: ble


fe r a
– Override database initialization parameter settings for allns
sessions
n - tra
– Customize the locale behavior a no
a s
– Change the default location of the NLS) h
library eฺ
idfiles
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Specifying Language-Dependent
y u ki se toBehavior for the Session
The Environment M asVariable
l i c enNLS_LANG
n
A localel eisya linguistic and cultural environment in which a system or program is running.
Sta the NLS_LANG environment parameter is the simplest way to specify locale behavior for
Setting
the Oracle database software. It sets the language and territory used by the client application and
the database server. It also sets the character set for data entered or displayed by a client
program. The value of NLS_LANG overrides any values of the NLS initialization parameters.
Each component controls a subset of NLS features:
NLS_LANG=<language>_<territory>.<charset>
language is used to override the value of NLS_LANGUAGE. territory overrides the value
of NLS_TERRITORY. charset specifies the character-encoding scheme used by client
application (usually that of the user’s terminal).
All components of the NLS_LANG definition are optional; any item that is not specified uses its
default value. If you specify territory or character set, then you must include the preceding
delimiter [underscore (_) for territory, period (.) for character set]. For example:
NLS_LANG = _JAPAN
NLS_LANG = .US7ASCII

Oracle Database 11g: Administration Workshop II 20 - 16


Computer Pride Limited

Language-Dependent and Territory-Dependent


Parameters
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Parameter Default Values

NLS_LANGUAGE AMERICAN
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_DUAL_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_DATE_FORMAT DD-MON-RR ble
NLS_NUMERIC_CHARACTERS ., fe r a
ans
NLS_TIMESTAMP_FORMAT
NLS_TIMESTAMP_TZ_FORMAT
DD-MON-RRHH.MI.SSXFF AM
n
DD-MON-RRHH.MI.SSXFF AM TZR - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Language-Dependent k i
u nTerritory-Dependent
and e Parameters
s y s
a lice and NLS_TERRITORY initialization parameters determines the
Setting the NLS_LANGUAGE
M
l ey that should be used by the Oracle database. You can override these default values
defaultnvalues
by a
Stexplicitly setting the values for those initialization parameters whose default values depend
on the settings of NLS_LANGUAGE and NLS_TERRITORY.
NLS_LANGUAGE Initialization Parameter
The NLS_LANGUAGE initialization parameter determines the default values of the following
parameters:
Column Description
NLS_DATE_LANGUAGE Determines the language for day and month
names and abbreviations and spelled values of
other date format elements
NLS_SORT Changes the linguistic sort sequence that the
Oracle database uses to sort character values.
(The sort value must be the name of a linguistic
sort sequence.)

Oracle Database 11g: Administration Workshop II 20 - 17


Computer Pride Limited

Language-Dependent and Territory-Dependent Parameters (continued)


NLS_TERRITORY Initialization Parameter
NLS_TERRITORY determines the default values for the following initialization parameters:

Column Description
NLS_CURRENCY Specifies the local currency symbol
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NLS_DATE_FORMAT Specifies the date format. (The value must be


a date format model.)
NLS_DUAL_CURRENCY Defines a secondary currency symbol for a
given territory
NLS_ISO_CURRENCY Indicates the territory whose ISO currency
symbol should be used
NLS_NUMERIC_CHARACTERS Explicitly specifies a new decimal character rab
le
e
and group separator nsf
t ra
NLS_TIMESTAMP_FORMAT n
o the
Defines the default date formatnfor
-
TIMESTAMP and TIMESTAMP s a WITH
h a ฺ
LOCAL TIME ZONE
m de Must have
) datauitypes.
o
ilฺ ent G
NLS_LANGcset.
a
NLS_TIMESTAMP_TZ_FORMAT Defines
@ ud date format for the
gm theSdefault
t
y u ki TIMESTAMP
t h is and TIMESTAMP WITH
s
a usLOCAL e TIME ZONE data types used with
i ( M to the and TO_TIMESTAMP_TZ
u k e
TO_CHAR
a sy cens functions. Must have NLS_LANG set.
yM li
l e
These
S t anare some of the NLS initialization parameters that are independent of the
NLS_LANGUAGE and NLS_TERRITORY values:

Column Description
NLS_CALENDAR Specifies which calendar system is used by the
Oracle database
NLS_COMP Can be set to ANSI or BINARY. When
NLS_COMP is set to ANSI, SQL operations
perform a linguistic comparison based on the
value of NLS_SORT.
NLS_LENGTH_SEMANTICS Enables you to create CHAR, VARCHAR2, and
LONG columns by using either byte or character
length semantics.

Oracle Database 11g: Administration Workshop II 20 - 18


Computer Pride Limited

Specifying Language-Dependent Behavior

Using NLS parameters in SQL functions:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ALTER SESSION SET NLS_DATE_FORMAT='DD.MM.YYYY';

DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT',
'''DD.MM.YYYY''') ;

SELECT TO_CHAR(hire_date,'DD.Mon.YYYY',
ble
'NLS_DATE_LANGUAGE=FRENCH')
fe r a
FROM employees
ans
WHERE hire_date > '01-JAN-2000';
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Specifying Language-Dependent
u nse Behavior
s y
a liissuing e ALTER SESSION commands, you can use the
In addition toM
explicitly c
l ey
DBMS_SESSION.SET_NLS
n database procedure, specifying the name of the parameter to
t a
change
S and the new value of the parameter. The second example shown in the slide performs the
same action as the first example, but uses the DBMS_SESSION package.
Client utilities such as SQL*Plus and SQL*Loader read the environment variables set on the
client and issue the corresponding ALTER SESSION command after they are connected to the
database.
The third example shows the use of the NLS_DATE_LANGUAGE NLS parameter in the
TO_CHAR SQL function.

Oracle Database 11g: Administration Workshop II 20 - 19


Computer Pride Limited

Linguistic Searching and Sorting

Sort order can be affected by:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Case-sensitivity
• Diacritics or accent characters
• Combination of characters that is treated as a single
character
• Phonetics or character appearance
• Cultural preferences
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Linguistic Searchinguand k i (M
Sortingt o
a s y ense
Different languages
y M have licdifferent sort orders. In addition, different cultures or countries that use
the same
a n lealphabets may sort words differently. For example, in Danish, Æ is after Z, whereas Y
andt
S Ü are considered to be variants of the same letter. Sort order can:
• Be case-sensitive or non-case-sensitive
• Ignore or consider diacritics (a mark near or through a character or combination of
characters that indicates a different sound than the sound of the character without the
diacritic)
• Be phonetic or it can be based on the appearance of the character (such as the number of
strokes in East Asian ideographs)
Another common sorting issue is combining letters into a single character. For example, in
traditional Spanish, ch is a distinct character that comes after c, which means that the correct
order is: cerveza, colorado, cheremoya. This means that the letter c cannot be sorted until the
database has checked whether the next letter is an h.
To produce a sort sequence that matches the alphabetic sequence of characters, another sort
technique must be used that sorts characters independently of their numeric values in the
character-encoding scheme. This technique is called a linguistic sort. A linguistic sort operates
by replacing characters with numeric values that reflect each character’s proper linguistic order.

Oracle Database 11g: Administration Workshop II 20 - 20


Computer Pride Limited

Linguistic Searching and Sorting

Three types of sorting:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Binary sorting
– Sorted according to the binary values of the encoded
characters
• Monolingual linguistic sorting
– A two-pass sort based on a character’s assigned major and
minor values
• Multilingual linguistic sorting e
r a bl
– Based on the ISO standard (ISO 14651), and the Unicode 3.2
n s fe
Standard for multilingual collation
n - tra
– Ordered by the number of strokes, PinYin, or radicals
a no for
Chinese characters a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Linguistic Searchinguand k i (M
Sortingt o (continued)
a s y ense
A binary sort M
y lic sorting mechanism by which letters are sorted according to the
is a conventional
le used to encode the characters. Binary sorts are the fastest type of sort. They
binarynvalues
a
t
produce
S reasonable results for the English alphabet because the ASCII and EBCDIC standards
define the letters A through Z in ascending numeric value. When characters used in other
languages are present, a binary sort usually does not produce reasonable results.
For monolingual sorting, the Oracle database uses major and minor values to compare
characters. Usually, letters with the same appearance have the same major value. For example,
A, a, and ä. The Oracle database defines letters with diacritics and case differences as having the
same major value but different minor values.
In a monolingual sort, the database makes two passes when comparing strings in monolingual
sorts. The first pass is to compare the major value of the entire string from the major table and
the second pass is to compare the minor value from the minor table. Although this provides
better sorting than binary, it is still limited.
Multilingual sorts enable you to sort data in more than one language in a single sort. This is
useful for regions or languages that have complex sorting rules.
Refer to the Oracle Database Globalization Support Guide for more information about the
supported linguistic sorts.

Oracle Database 11g: Administration Workshop II 20 - 21


Computer Pride Limited

Using Linguistic Searching and Sorting

You can specify the type of sort used for character data with
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

the:
• NLS_SORT parameter
– Default value derived from the NLS_LANG environment
variable, if set
– Can be specified for the session, client, or server
• NLSSORT function
– Defines the sorting method at the query level e
r a bl
s fe
- t r an
n
no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Using Linguistic Searching i
u nsand e Sorting
s y
To overcomeM thealimitations
l i c e of binary sorting, you can specify linguistic sorts by setting the
l
NLS_SORT
n ey parameter or by using NLSSORT in your query.
StaNLS_SORT Parameter
The
Consider the following words stored in a database by using the WE8ISO8859P1 character set:
• gelée
• gelé
• gèle
• gelez

If NLS_SORT is set to BINARY, gelez is sorted before gelé. This occurs because e has a
binary value lower than è in the WE8ISO8859P1 character encoding.
If NLS_SORT is set to the FRENCH monolingual sort, the word gelé is sorted before gelez
and gèle, which still does not satisfy all the nuances of the French language. For example, in
the French language, letters are sorted from left to right and accents from right to left.
When NLS_SORT is set to the FRENCH_M multilingual sort, both the characters and the
diacritics are sorted properly.

Oracle Database 11g: Administration Workshop II 20 - 22


Computer Pride Limited

Using Linguistic Searching and Sorting (continued)


The NLSSORT Function
NLSSORT allows sorting to be defined at the query level. The following example sets
NLS_SORT to BINARY at the session level but then changes the sort at the query level.

SQL> ALTER SESSION SET NLS_SORT=BINARY;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Session altered.

SQL> SELECT fr_word


2 FROM words
3 ORDER BY fr_word;

FR_WORD
-------
gelez
gelé
ble
gelée
fe r a
gèle
ans
n - t r
SQL> SELECT fr_word
a no
2 FROM words a s
3 ORDER BY NLSSORT(fr_word,'NLS_SORT=FRENCH_M');) h i d eฺ
m
co nt Gu
i l
a de ฺ
FR_WORD
g m tu
--------
i @ S
gèle
s y uk this
gelé
( M a use
gelée
y u ki se to
gelez
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II 20 - 23


Computer Pride Limited

Case-Insensitive and Accent-Insensitive


Search and Sort
• Specify the linguistic name:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NLS_SORT = <NLS_sort_name>[_AI | _CI]

• Examples:
NLS_SORT = FRENCH_M_AI

NLS_SORT = XGERMAN_CI

• Specify the sort action for WHERE clauses and PL/SQL e


r a bl
blocks: s fe
- t r an
NLS_COMP = BINARY | ANSI n
no
s a
• Useful for migrated databases ) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Case-Insensitive anduk i (M e to u Search and Sort
Accent-Insensitive
Use the session a
parameter
ns
sy ceNLS_SORT to specify the linguistic sort name. The default value is
y M l i
e the initialization parameter NLS_LANGUAGE. The _AI and _CI values are
derived lfrom
n
t a
suffixed
S to the sort name to indicate an accent-insensitive sort or a case-insensitive sort. From
the example in the slide, the following are determined:
• Accent-insensitive and case-insensitive “French_M” sort
• Accent-sensitive and case-insensitive “Xgerman” sort
Comparisons in the WHERE clause and in PL/SQL blocks are binary unless you use the
NLSSORT function. By setting NLS_COMP to ANSI, you indicate that comparisons in the
WHERE clause and in PL/SQL blocks should use the linguistic sort specified in the NLS_SORT
parameter. You must also define an index on the column for which you want linguistic sorts.
Note: The format of the NLS_SORT parameter applies for both monolingual and multilingual
linguistic sorts. In the monolingual sort, only major and minor levels are included. If the
NLS_COMP parameter is set to ANSI, the options apply to any SQL or PL/SQL operators that
already support collation-based comparisons in previous database releases. The _AI or _CI
options are not affected in the INSTR, TRIM, and LIKE SQL functions because these functions
compare strings only in binary order.
Note for database migrators: Sybase, SQL Server, and MS Access can use case-insensitive
operations. These options can be used to preserve existing application functionality.
Oracle Database 11g: Administration Workshop II 20 - 24
Computer Pride Limited

Support in SQL and Functions

• The following SQL clauses support NLS_SORT and


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NLS_COMP settings:
– WHERE
– ORDER BY
– START WITH
– HAVING
– IN/NOT IN
– BETWEEN e
– r a bl
CASE-WHEN
ns fe
n - tra and
• The NLSSORT() function supports the case-insensitive
o
accent-insensitive functionality. an s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
Support in SQL anduFunctionsi (M e to u
a sy incthe e s
nslide
The SQL clauses
M listed l i are affected when the _AI or _CI options are appended to
y
t a nle SELECT
the NLS_SORT parameter.
S cust_last_name
FROM customers
WHERE NLSSORT(cust_last_name, 'NLS_SORT = generic_m_ai')
= NLSSORT('De Niro', 'NLS_SORT=generic_m_ai');

CUST_LAST_NAME
--------------------
de Niro
De Niro
dë Nirõ
You typically use the NLSSORT function in an ORDER BY or WHERE clause when the linguistic
setting of the session parameter NLS_SORT is different from the linguistic setting in the SQL
statement. The example (given on this page) searches for all occurrences of “De Niro”
regardless of the case and accent. You can get the same result as shown in the example by
setting the NLS_COMP parameter:
ALTER SESSION SET NLS_SORT=generic_m_ai;
ALTER SESSION SET NLS_COMP=ansi;

Oracle Database 11g: Administration Workshop II 20 - 25


Computer Pride Limited

Linguistic Index Support

• Create an index on linguistically sorted values.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Rapidly query data without having to specify ORDER BY


clause and NLSSORT:
CREATE INDEX list_word ON
list (NLSSORT(word, 'NLS_SORT=French_M'));

SELECT word FROM list;

• Set the NLS_SORT parameter to match the linguistic


a b le
definition that you want to use for the linguistic sort whennsfe
r
a
creating the index. n-tr no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Linguistic Index Support k i
a s yu ense
Linguistic sorting
y lic specific. When data in multiple languages is stored in the
M is language
database,
a n leyou may want to sort the data in different ways depending on the language. Creating a
S t
linguistic index for columns to be sorted greatly improves the performance of queries requiring
linguistic sorting, although it can slow down inserts and updates.
Functional indexes are used to create linguistically sorted indexes. The SQL function NLSSORT
returns the string of bytes used to sort the first parameter in the given linguistic sorting sequence.
In the example shown in the slide, an index is created on WORD that is sorted according to the
FRENCH_M sorting order. This enables you to perform index-based queries on data that is sorted
according to the rules of each language.
You can also build a single linguistic index for all languages by using one of the multilingual
linguistic sorts such as GENERIC_M or FRENCH_M. Or, for a small set of languages, use a
language column to be used as a parameter of the NLSSORT function. The language column
contains the NLS_LANGUAGE values for the data in the indexed column.
CREATE INDEX i2 on list (NLSSORT(word,
'NLS_SORT=GENERIC_M'));
CREATE INDEX word_all_idx ON
list (NLSSORT(word, 'NLS_SORT=' || LANG_COL));
See the Oracle Database Globalization Support Guide for details on creating linguistic indexes.

Oracle Database 11g: Administration Workshop II 20 - 26


Computer Pride Limited

Customizing Linguistic
Searching and Sorting
You can customize linguistic sorting for:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Ignorable characters
• Contracting or expanding characters
• Special combination letters or special letters
• Expanding characters or special letters
• Special uppercase and lowercase letters
• Context-sensitive characters
ble
• Reverse secondary sorting
fe r a
• Canonical equivalence ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Customizing Linguistic k i
u nse and Sorting
Searching
s y
a andlicsorting
e has many features. Many of these features are customizable, so
Linguistic searching
M
you cann l ey the desired results from your data. For example:
retrieve
S• taNow you can also specify a sort or query on the base letters only (accent-insensitive) or on
the base letter and the accents (case-insensitive).
• You can specify that the dash punctuation character should be ignored so that e-mail can
be treated in the same way as email.
• The expanding character ö sorts as if it were oe, after od and before of.
• You can properly sort prolonged sound marks in Japanese.
• Making ä equivalent to its base letter, a, and an umlaut, ¨, so that ä and a¨ are considered
equal.
• You can have a character with a diacritic placed before or after its unmarked variant.
• Whether or not in Thai and Lao, some characters first change places with the following
character before sorting.
• You can map lowercase letters to multiple uppercase letters, such as the German ß to SS,
and uppercase letters to multiple lowercase letters, such as the Turkish I becoming a small,
dotless i: ı.

Oracle Database 11g: Administration Workshop II 20 - 27


Computer Pride Limited

Customizing Linguistic Searching and Sorting (continued)


To create custom linguistic sorts, you need to use the Oracle Locale Builder utility, which
provides a graphical user interface for customizing locale data such as language, territory,
character set, and linguistic sort.
Note: For more information about Oracle Local Builder, see the Oracle Database Globalization
Support Guide.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta

Oracle Database 11g: Administration Workshop II 20 - 28


Computer Pride Limited

Implicit Conversion
Between CLOB and NCLOB
Transparent implicit conversion is supported in:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• SQL IN and OUT bind variables for query and DML


• PL/SQL functions and procedure parameter passing
• PL/SQL variable assignment

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Implicit Conversion u k
Between to uand NCLOB
i (M eCLOB
Converting data a sy cUnicode
between e ns and the database national language character set is becoming
li Explicit conversion between CLOB and NCLOB is already
y M requirement.
l e
a more frequent
n
Sta in SQL and in PL/SQL with the TO_CLOB and TO_NCLOB functions. Oracle
available
Database performs implicit conversion for SQL IN and OUT bind variables in queries and DML
operations, as well as for PL/SQL function and procedure parameter passing and PL/SQL
variable assignment. For example, conversion is completely transparent in the following
scenario:
CREATE TABLE my_table (nclob_col NCLOB);
DECLARE
clob_var CLOB;
nclob_var NCLOB;
BEGIN
clob_var := 'clob data'; -- initialize the CLOB
INSERT INTO my_table VALUES (clob_var);
-- Bind a CLOB into an NCLOB column
SELECT nclob_col
INTO clob_var FROM my_table;
-- Define an NCLOB column as a CLOB var
END;

Oracle Database 11g: Administration Workshop II 20 - 29


Computer Pride Limited

NLS Data Conversion with Oracle Utilities

• Multiple data conversions can take place when data is


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

exported from one database and imported into another if the


same character sets are not used.
• External tables use the NLS settings on the server for
determining the data character set.
• SQL*Loader:
– Conventional path: Data is converted into the session
character set specified by NLS_LANG.
ble
– Direct path: Data is converted using client-side directives. fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
NLS Data Conversion k i
u nOracle
with e Utilities
s y
a lifor s
eExport and Import
GlobalizationMSupport c
n l
The Exporteyutility always saves the data, including Unicode data, in the same character sets as
the
a
Stdatabase from which the taken was exported. When exporting data definition language
(DDL), Export writes export files using the character set specified in the NLS_LANG
environment variable for the user session. A character set conversion is performed if the value of
NLS_LANG differs from the database character set.
When importing user data, if the character sets of the source database (and the export dump file)
are different from the character sets of the import database, a single conversion is performed to
automatically convert the data to the character sets of the target database.
During the import of DDL, the data is automatically converted from the character set of the
export file to the character set of the import user session. Import can perform this conversion
only for single-byte character sets. This means that for multibyte character sets, the import file’s
character set must be identical to the export file’s character set. If the character set used by the
import user session is different from the target database’s character set, a final character set
conversion is performed.

Oracle Database 11g: Administration Workshop II 20 - 30


Computer Pride Limited

NLS Data Conversion with Oracle Utilities (continued)


Globalization Support for External Tables
The NLS environment variable settings on the server determine the character set and date masks
for the table.
Globalization Support for SQL*Loader
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL*Loader supports four character sets:


• Client character set (NLS_LANG of the client SQL*Loader process)
• Data file character set (usually the same as the client character set)
• Database character set
• Database national character set
Performance is optimized if all character sets are the same.
SQL*Loader has the capability to convert data from the data file character set to the database
character set. The character set of the data file can be set up by using the NLS_LANG parameter
or by specifying the CHARACTERSET parameter in the SQL*Loader control file: e
a bl
LOAD DATA
fe r
CHARACTERSET UTF16
ans
INFILE ulcase11.dat
n - t r
REPLACE …
a no
The SQL*Loader control file itself is assumed to be in the character
h a s set specified
ฺ for your
session by the NLS_LANG parameter. If the control file character ) set e
idis different from the data
o m G u
lฺc especified
file character set, delimiters and comparison clauseivalues
a n t in the SQL*Loader control
file as character strings are converted from the
@ gm udcharacter set to the data file character
controltfile
S
set before any comparisons are made. To
y u ki ensure
t h ithat
s the specifications are correct, you may
prefer to specify hexadecimal strings,
a s rather
s e than character string values.
M
i ( withethe
If the character set specified u
toNLS_LANG parameter for your session is different from
y u k s
the character set ofsthe data file,
n character strings in the control file are converted to the
character set M a l i c e
l e y of the data file. This is done before SQL*Loader checks for the default record
n
terminator.
Sta
The character set specified with the CHARACTERSET parameter does not apply to data in the
control file (specified with INFILE). To load data in a character set other than the one specified
for your session by the NLS_LANG parameter, you must place the data in a separate data file.
You can use SQL*Loader to load data using one of three methods: conventional path, direct
path, or external table. During conventional path data loads, data is converted into the session
character set specified by the NLS_LANG parameter for that session.
During a direct path load, data conversion occurs on the client side rather than on the server side.
This means that NLS parameters in the initialization parameter file are not used. To override this
behavior, you can specify a format mask in the SQL*Loader control file that is equivalent to the
setting of the NLS parameter in the initialization parameter file, or set the appropriate
environment variable.
If the target character set for the SQL*Loader data is not a superset of the source data file
character set, characters that have no equivalent in the target character set are converted to
replacement characters, such as a question mark, resulting in loss of data.

Oracle Database 11g: Administration Workshop II 20 - 31


Computer Pride Limited

NLS Data Conversion with Data Pump

• Data Pump Export always saves data in the same character


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

set as the database from which the data originates.


• Data Pump Import converts the data to the character set of
the target database, if needed.
• The Data Pump log file is written in the language specified
by NLS_LANG for the session that started Data Pump.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
NLS Data Conversion k i
u nData
with e Pump
s y
a settings s
e used by the session that initiated Data Pump are used within the
The NLS parameter
M l i c
l
Data Pump
n eyjob. Therefore, ensure that the parameters are set correctly before you start any Data
Sta job. The client NLS_LANG settings are used only for messages returned by the Data Pump
Pump
utilities, such as impdp or expdp.
During the execution of a job, a log file is optionally written. The log file summarizes the
progress of the job and any errors that were encountered along the way. Data Pump writes the
log file by using the NLS_LANG setting of the client. For example, setting NLS_LANG to
French.WE8DEC causes all messages for the job to be displayed in French, even if the job is
restarted from an American.WE8DEC client.
If you use a parameter file (PARFILE) with Data Pump, the parameter file is assumed to be in
the client’s character set. The Data Pump utility translates the text strings in the parameter files
into the database character set. If the parameter file is in a different character set than that being
currently used by the client, then you must alter the NLS settings of the client to ensure a proper
translation.

Oracle Database 11g: Administration Workshop II 20 - 32


Computer Pride Limited

Language and Character Set File Scanner


(LCSSCAN)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Character set

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(Set
Language and Character k i
u nseFile Scanner (LCSSCAN)
s y
a Character e Set File Scanner (LCSSCAN) is a high-performance, statistically
The LanguageMand l i c
based n l ey for determining the language and character set for unknown file text. It can
utility
Sta
automatically identify a wide variety of language and character set pairs. With each text, the
language and character set detection engine sets up a series of probabilities, each probability
corresponding to a language and character set pair. The most statistically probable pair identifies
the dominant language and character set.
The syntax for the lcsscan utility is shown below:
LCSSCAN [RESULTS=number] [FORMAT=file_type] [BEGIN=number]
[END=number] FILE=file_name
Below are the meanings of the parameters:
• FILE: The text file that contains the text to scan
• RESULTS: The number of language and character set pairs you expect to be identified.
• FORMAT: The format of the file to be scanned. This can be text, html, or auto.
• BEGIN: The byte number of where the scanner is to begin scanning the file.
The default is 1.
• END: The byte number of where the scanner is to stop scanning the file. The minimum is 3,
and the default is the last byte of the file.
Note: For more information about LCSSCAN, refer to the Oracle Database Globalization
Support Guide.
Oracle Database 11g: Administration Workshop II 20 - 33
Computer Pride Limited

Setting the Database Time Zone

The current time zone in the database is determined by the


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

following:
• The SET TIME_ZONE clause of the CREATE DATABASE
statement
• The time zone of the operating system on the database
server host
• The time zone specified by the ALTER SESSION SET
TIME_ZONE command e
r a bl
s fe
CREATE DATABASE ... SET TIME_ZONE='-04:00';
- t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Setting the DatabaseuTime k i (MZone t o
a s y ense
Set the database
y M time zone
l ic when the database is created by using the SET TIME_ZONE clause
a n le
of the CREATE DATABASE statement. If you do not set the database time zone, then it defaults
t
toSthe time zone of the server’s operating system. The time zone may be set to an absolute offset
from UTC or to a named region. To set the time zone to an offset from UTC, use a statement
similar to the one shown in the slide. To set the time zone to a named region, use a TIME_ZONE
string such as:
SET TIME_ZONE='Europe/London';
You can determine the time zone of the database by running the following query:
SELECT dbtimezone FROM DUAL;
Note: For more information about setting the time zone and how that affects time-based data in
your database, refer to the Oracle Database Globalization Support Guide.

Oracle Database 11g: Administration Workshop II 20 - 34


Computer Pride Limited

Summary

In this lesson, you should have learned how to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Determine a correct database character set that meets your


business requirements
• Obtain globalization support configuration information
• Customize language-dependent behavior for the database
and individual sessions
• Specify different linguistic sorts for queries
• Retrieve data that matches a search string ignoring case or able
accent differences s fer
n a
o n -tr
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II 20 - 35


Computer Pride Limited

Practice 20 Overview:
Using Globalization Support
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

• Determining the database character set


• Setting the NLS_SORT variable

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II 20 - 36


Computer Pride Limited

Appendix A
Practices and Solutions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited

Table of Contents
Practices for Lesson 1 ......................................................................................................... 4
Practice 1-1: Upgrade the Database Storage to ASM..................................................... 5
Practice 1-2: ASM Fast Mirror Resync ........................................................................ 19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Practice 1-3: ASMCMD ............................................................................................... 24


Practices for Lesson 2 ....................................................................................................... 26
Practice 2-1: Configuring ARCHIVELOG Mode ........................................................ 26
Practice 2-2: Resizing the Flash Recovery Area........................................................... 28
Practice 2-3: Verifying the Backup Destination ........................................................... 30
Practice 2-4: Configuring the Retention Policy ............................................................ 32
Practices for Lesson 3 ....................................................................................................... 33
Practice 3-1: Creating a Recovery Catalog................................................................... 33
Practice 3-2: Creating the Recovery Catalog Owner.................................................... 44
Practice 3-3: Creating the Recovery Catalog................................................................ 44 e
Practice 3-4: Registering a Database in the Recovery Catalog..................................... 46
r a bl
Practice 3-5: Cataloging Additional Backup Files........................................................ 48 s fe
Practice 3-6: Backing Up the Recovery Catalog .......................................................... 50
- t r an
no n
Practices for Lesson 4 ....................................................................................................... 53
a
Practice 4-1: Setting the Date and Time Format for RMAN ........................................ 53
s
h a eฺ
Practice 4-2: Enabling Control File Autobackup.......................................................... 54
)
m i d
co nt Gu
Practice 4-3: Configuring Devices for Backup............................................................. 56
i l ฺ
Practices for Lesson 5 ....................................................................................................... 58
ma tude
Practice 5-1: Creating Fast Incremental Backups......................................................... 58
g
u k i@ is S
Practice 5-2: Cross-Checking Backups......................................................................... 61
sy se th
Practice 5-3: Listing Backup Files................................................................................ 65
a
k i (M to u
Practices for Lesson 6 ....................................................................................................... 77
Practice 6-1: Backing up the database .......................................................................... 77
syu cense
Practice 6-2: Recovering from the loss of a datafile..................................................... 80
a
yM li
Practice 6-3 Recovering from the loss of all controlfiles ............................................. 85
nle
Practice 6-4: Recovering from the loss of a redo log group ......................................... 91
StaPractices for Lesson 7 ....................................................................................................... 95
Practice 7-1: Recovering Image Copies........................................................................ 95
Practice 7-2: Performing Fast Recovery ..................................................................... 103
Practices for Lesson 8 ..................................................................................................... 110
Practice 8-1: Cloning a Database................................................................................ 110
Practices for Lesson 9 ..................................................................................................... 120
Practice 9-1: Performing Tablespace Point-in-Time Recovery .................................. 120
Practices for Lesson 10 ................................................................................................... 131
Practice 10-1: Monitoring RMAN Jobs...................................................................... 131
Practices for Lesson 11 ................................................................................................... 133
Practice 11-1: Using the Recycle Bin ......................................................................... 134
Practice 11-2: Flashback Transaction Backout........................................................... 137
Practices for Lesson 12 ................................................................................................... 146
Practice 12-1: Flashback Database ............................................................................. 147
Practice 12-2: Using Flashback Data Archive ............................................................ 153

Oracle Database 11g: Administration Workshop II A - 2


Computer Pride Limited

Practices for Lesson 13 ................................................................................................... 167


Practice 13-1: Diagnostic Scenario............................................................................. 168
Practice 13-2: Repairing Block Corruption ................................................................ 179
Practice 13-3: SQL Repair Advisor Scenario ............................................................. 188
Practices for Lesson 14 ................................................................................................... 205
Practice 14-1: Using Automatic Memory Management ............................................. 206
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Practices for Lesson 15 ................................................................................................... 222


Practice 15-1: Monitoring Services ............................................................................ 222
Practice 15-2: Using SQL Tuning Advisor................................................................. 231
Practices for Lesson 16 ................................................................................................... 237
Solution for Practice 16-1: Managing Storage............................................................ 238
Practices for Lesson 17 ................................................................................................... 248
Practice 17-1: Managing Resources............................................................................ 249
Practices for Lesson 18 ................................................................................................... 260
Practice 18-1: Creating Scheduler Components ......................................................... 261
Practice 18-2: Creating Lightweight Scheduler Jobs.................................................. 269
Practice 18-3: Monitoring the Scheduler .................................................................... 275 ble
fe r
Practices for Lesson 19 ................................................................................................... 279 a
an s
Practices for Lesson 20 ................................................................................................... 280
n - t
Practice 20-1: Using Globalization Support ............................................................... 280
r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 3


Computer Pride Limited

Practices for Lesson 1

In these practices, you upgrade the database storage from file system files to ASM. You
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

also explore the functionality of the ASM command-line utility, ASMCMD.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 4


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM


In this practice, you upgrade the database storage from file system files to ASM. You use
DBCA to create an ASM instance called +ASM and configure two diskgroups, DATA and
FRA. The DATA diskgroup uses four 3 GB raw slices employing normal redundancy. The
FRA diskgroup uses four 3 GB slices employing external redundancy. Then you use
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Enterprise Manager (EM) to perform the storage migration.


1) From a terminal window, set ORACLE_SID to +ASM and start DBCA.
$ export ORACLE_SID=+ASM
$ dbca

2) Click Next on the Welcome page to get started.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 5


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

3) On the next page, select Configure Automatic Storage Management from the list of
possible operations, and then click Next to continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
4) You are asked to irun t u
(Mthe localconfig
o script to set up local Cluster
u k e
sy cService
Synchronization
a e ns (CSS) for high availability purposes.
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 6


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 7


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

5) Open a terminal window and run the localconfig add script as root.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
no
When the script has completed, click OK to close the localconfig dialog box.
a
a s
) h i d eฺ
6) After returning to the Operations page, click Nexto m
c to continue.
G u
i l ฺ t
g ma tuden
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 8


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

7) The new ASM instance must have a password for the SYS account. Use oracle for
the password and click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
8) Click OK to start the ASM instance. a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
s y u nse
M a
Wait a few moments
l i c e the instance starts.
while

n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 9


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

9) Next, the diskgroups must be created. Click Create New to begin.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
a Normal
10) Enter DATA for the Disk Group Name and
g mselect t u de redundancy. Select the first
k i@and click
four raw slices that are 3 GB in size,
i s SOK.
u
sy se t h
a
(M to u
k i
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 10


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

11) Click Create New to create the next diskgroup for the flash recovery area.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
(M Group
12) Enter FRA for thei Disk t o u and select External Redundancy. There will be
Name
k e Select them and click OK to continue.
syu ofc3eGB
four raw slices
a nsleft.
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 11


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m Guto continue.
coClick nFinish
l
13) Both diskgroups should be mounted at this stage.
i ฺ t
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 12


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

14) Click No when prompted to perform another DBCA operation.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

15) Connect to Enterprise Manager using the following URL:


https://your_host_name:1158/em. Enter sys as your username and oracle as your
password, and connect as sysdba. Make sure that you accept the certificate
authority. Also make sure that you specify oracle as the old and new passwords for ble
both SYSTEM and SYS users on the Modify Passwords page right after you log in forfe r a
the first time. ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
le
16) On the Database home page, click the Server folder tab, and then click Migrate to
n
Sta ASM under the Storage section. The Target Name should be
+ASM_your_host_name. The ASM ORACLE_HOME should be the same as your
database, /u01/app/oracle/product/11.1.0/db_1. Next, provide the SYS
password, oracle. The port should be 1521 and the SID should be +ASM. Enter the
host credentials next (oracle/oracle) and click Continue.

Oracle Database 11g: Administration Workshop II A - 13


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
s
17) In the Files to Be Migrated section, select all three check boxes: Database Files,
an
n - t r
Recovery-related Files, and Parallelze File Copy Operations. The working directory
should be the same as the database home,
a no
/u01/app/oracle/product/11.1.0/db_1/dbs. Click Next to continue.
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 14


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

18) In the Database Area section, enter DATA in the Database Area field. In the Flash
Recovery Area section, enter FRA in the Flash Recovery Area field and change the
Flash Recovery Area Size to 4096. Select Setup Flash Recovery Area and Migrate
Recovery-related Files and then click Next to continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
19) On the Schedule page, select Immediately
k S Start section and click Next to
i@ iins the
continue. u
sy se t h
a
(M to u
k i
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 15


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)

20) On the Review page, examine your selections. If you have made any errors, use the
Back button to go back and correct them. Click Submit Job when ready.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ
g ma tStatus
21) After the job has been submitted, click the View
progress. It takes several minutes to complete. u denbutton to monitor the job’s
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
That takes you to the Job Activity page. When the job finishes, you will be disconnected
from Enterprise Manager.

Oracle Database 11g: Administration Workshop II A - 16


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)


22) Wait a few moments and log back in to Enterprise Manager. Click the +ASM link on
the database home page. What do you see?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an
On the +ASM home page, you see that the DATA diskgroup is associated with the orcl s
instance storage. n - t r
n o
23) Now that the database has been migrated to ASM, you can remove a
s allฺthe files that
h a
were stored in the traditional file system.
m ) u i de
o
$ cd $ORACLE_BASE/oradata/orcl
a ilฺc ent G
ud
$ pwd
/u01/app/oracle/oradata/orclgm t
@
ki this S
$ ls -l
y u
total 1906132
-rw-r----- 1 (oracle M as oinstall
u se 9748480 Sep 24 20:44
k i t o
nse oinstall 9748480 Sep 24 20:44
syu c1 eoracle
control01.ctl
a
-rw-r-----
li
l e yM
control02.ctl

tan control03.ctl
-rw-r----- 1 oracle oinstall 9748480 Sep 24 20:44
S -rw-r----- 1 oracle oinstall 104865792 Sep 24 20:44
example01.dbf
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo01.log
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo02.log
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo03.log
-rw-r----- 1 oracle oinstall 680140800 Sep 24 20:44
sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Sep 24 20:44
system01.dbf
-rw-r----- 1 oracle oinstall 29368320 Sep 24 20:35
temp01.dbf
-rw-r----- 1 oracle oinstall 209723392 Sep 24 20:44
undotbs01.dbf

Oracle Database 11g: Administration Workshop II A - 17


Computer Pride Limited

Practice 1-1: Upgrade the Database Storage to ASM (continued)


-rw-r----- 1 oracle oinstall 5251072 Sep 24 20:44
users01.dbf
$ rm *
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 18


Computer Pride Limited

Practice 1-2: ASM Fast Mirror Resync


In this practice, you compare the time it takes to add an offlined disk following a nondata
loss issue. You compare the same operation once without using ASM Fast Mirror
Resync, and once using it.
1) Determine the compatibility values for your existing ASM disk groups. What do you
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

observe?
a) Set the proper environment variables for the +ASM instance. Run the query in the
following screenshot to check COMPATIBLE values for both ASM and the
database. You should see that both compatibility values are set to 10.1.
$ export ORACLE_SID=+ASM
$ export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
$ export PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:
/usr/bin:/usr/local/bin:/usr/X11R6/bin
$ sqlplus / as sysasm
ble
fe r a
SQL> select name,compatibility,database_compatibility from
ans
v$asm_diskgroup;
n - t r
NAME COMPATIBILITY DATABASE_COMPATIBILITY
a no
a s
-------------------- ------------------ ----------------------
DATA 10.1.0.0.0 ) h
10.1.0.0.0
i d eฺ
FRA 10.1.0.0.0 m
co nt Gu
10.1.0.0.0
i l ฺ
g ma tude
k S disk group page.
i@to theisDATA
s y u
2) Using Enterprise Manager, navigate t h
a s e
to u lab. For example:
i (Mtheeprevious
a) Connect to Enterprise Manager Database Control as user SYS using the URL that
k
was givenuduring
a sy cens
https://edrsr14p1.us.oracle.com:1158/em/
M li
b)y Click the +ASM link on the main Database page.
n l e
Sta c) On the ASM home page, click the Disk Groups tab.
d) On the Automatic Storage Management Login page, enter sys in the Username
field and oracle in the Password field, and select SYSASM from the Connect As
drop-down list. Select the Save as Preferred Credentials check box. Then click
Login.
e) On the ASM home page, click the Disk Groups tab.
f) On the Disk Groups page, click the DATA link in the table.
3) Using Enterprise Manager Database Control, change both the Database compatibility
and ASM compatibility attributes of the DATA disk group. Set them both to
11.1.0.0.0. What do you observe after having changed these two parameters?
a) On the Disk Group: DATA General subpage, click Edit in the Advanced
Attributes section.

Oracle Database 11g: Administration Workshop II A - 19


Computer Pride Limited

Practice 1-2: ASM Fast Mirror Resync (continued)


b) On the Edit Advanced Attributes for Disk Group: DATA page, enter
11.1.0.0.0 in both the Database Compatibility and ASM Compatibility fields.
Then click Apply.
c) Back to the Disk Group: DATA General subpage, make sure you can see that
both fields are updated, and that you see the new Disk Repair Time attribute in the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Advanced Attributes section. You should also see that disks are around thirty
percent full.
4) Use SQL*Plus to verify that the previous update was done correctly:
a) From a terminal window, connected as the user oracle, launch SQL*Plus and
look at V$ASM_DISKGROUP:
$ export ORACLE_SID=+ASM
$ export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
$ export
PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:/usr/bin:/us
ble
r/local/bin:/usr/X11R6/bin
fe r a
$ sqlplus / as sysasm
ans
SQL> select name,compatibility,database_compatibility from
n - t r
v$asm_diskgroup;
a no
a s
NAME COMPATIBILITY DATABASE_COMPATIBILITY
) h i d eฺ
------ -------------
m
----------------------
c o t Gu
DATA
FRA
11.1.0.0.0
10.1.0.0.0
11.1.0.0.0
i
a denl ฺ
g m10.1.0.0.0 tu
i @ S
s y uk this
5) Execute the asm_setup.sh
( M a script u sefrom the labs directory to set up the
i practice.
environment forkthis
u e toThe script creates a new tablespace called TBSJMW in
the DATA
a y
sdisk groupe s
nusing a 50 MB file. It then creates a new table called
y M
SYSTEM.JMW l i c
residing in this new tablespace. The script then inserts some rows in
n l e
the newly created table.
Sta $ cd ~/labs
$ ./asm_setup.sh

#!/bin/bash

cd /home/oracle/solutions/lesson1

export ORACLE_SID=orcl

export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1

export
PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:/usr/bin:/us
r/local/bin:/usr/X11R6/bin

sqlplus system/oracle <<EOF

Oracle Database 11g: Administration Workshop II A - 20


Computer Pride Limited

Practice 1-2: ASM Fast Mirror Resync (continued)


set echo on

create tablespace tbsjmw datafile '+DATA' size 50M;

drop table jmw purge;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

create table JMW(c varchar2(500)) tablespace tbsjmw;

insert into jmw


values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

commit;

begin
for i in 1..10 loop
ble
insert into jmw select * from jmw;
end loop; fe r a
commit; ans
end; n - t r
/
a no
a s
EOF ) h i d eฺ
m u sure that the Disk
o groupt making
cdisk G
6) Offline the second disk that is part of the DATA i l ฺ
Repair Time attribute is set to 0:
g ma tuden
a) Back to the Disk Group: DATA k i@Generali s S
page, select the second disk
u
sy Offline. t h
(DATA_0001), andaclick
u s e
k i (M page,
b) On the Confirmation t o change the Disk Repair Time from its default (3.6
hours)sto
a n seShow SQL.
yu0 andeclick
y M DISKGROUPlic DATA OFFLINE DISK DATA_0001 DROP AFTER 0 h
n l e
ALTER

Sta c) Click Return.


d) Back to the Confirmation page, click Yes.
7) What do you observe?
a) Back to the Disk Group: DATA General page, you can see that DATA_0001 is
now empty. Refresh your browser page until you no longer see the offlined disk.
b) Back to the Disk Group: DATA General page, you should now see that all three
of the remaining disks are around forty percent full. This forced the lost mirrored
extents to be rebalanced across surviving disks.
8) Modify some rows in the SYSTEM.JMW table (delete 499 rows). Is it working?
a) You can still modify the JMW table:
$ export ORACLE_SID=orcl
$ sqlplus system/oracle as sysdba

Oracle Database 11g: Administration Workshop II A - 21


Computer Pride Limited

Practice 1-2: ASM Fast Mirror Resync (continued)


SQL> delete from system.jmw where rownum<500;

SQL> commit;

9) Add the dropped ASM disk back to the DATA disk group:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

a) You now need to wipe out the dropped disk before you can add it back. You must
be root to do this:
# dd if=/dev/zero of=/dev/raw/raw2 bs=1M count=20

b) Back to the Disk Group: DATA General page, click Add.


c) On the Add Disks page, select /dev/raw/raw2 from the Member Disks table.
Restore the original DISKGROUP and FAILGROUP names: DATA_0001. Set
REBALANCE POWER to 11.
d) Click Show SQL. ble
fe r a
ALTER DISKGROUP DATA ADD FAILGROUP DATA_0001 DISK
ans
'/dev/raw/raw2' NAME DATA_0001 SIZE 3000 M REBALANCE POWER 11
n - t r
e) Click Return.
a no
a s
f) On the Add Disks page, click OK.
) h i d eฺ
10) What do you observe? m
co nt Gu
i l ฺ
apage, refresh
a) Back to the Disk Group: DATA General
g m t u de your browser until you see
no more rebalance activity. i@
k i s S
u
sy operation
b) You can see that a rebalance h
t is going on for a while.
a s e
u of the DATA disk group making sure that the Disk
M thattisopart
11) Offline the second
k i (disk
a syuattribute
Repair Time
e n seset to its default value. Modify the SYSTEM.JMW table again
is
c of 499 rows). What are your observations?
y M anotherlibatch
(delete
l e
Stan a) Back to the Disk Group: DATA General page, select the second disk
(DATA_0001), and click Offline.
b) On the Confirmation page, leave the default value of 3.6 Hours in the Disk Repair
Time field, and click Yes.
c) Back to the Disk Group: DATA General page, you can see that DATA_0001 is
not empty. Even if you refresh your browser page, no rebalance is taking place.
d) You can still modify the SYSTEM.JMW table.
$ sqlplus system/oracle as sysdba

SQL> delete from system.jmw where rownum<500;

SQL> commit;

12) Now, how would you add the offlined disk back into the DATA disk group? It is not
necessary to wipe out the dropped disk.

Oracle Database 11g: Administration Workshop II A - 22


Computer Pride Limited

Practice 1-2: ASM Fast Mirror Resync (continued)


a) Back to the Disk Group: DATA General page, select the offline disk and click
Online.
b) On the Confirmation page, click Yes.
c) Back to the Disk Group: DATA General page, you should see the disk back to its
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

level (around 30% full), without the need of any rebalance operation. The disk is
added back immediately.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 23


Computer Pride Limited

Practice 1-3: ASMCMD


In this practice, you use ASMCMD commands to view and manage various files stored in
the ASM diskgroups.
1) Start ASMCMD and view the contents of the +DATA diskgroup. Get a listing of the
DATAFILE directory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ export ORACLE_SID=+ASM
$ asmcmd
ASMCMD> ls +DATA/*

+DATA/ASMTESTING/:
DATAFILE/

+DATA/ORCL/:
CHANGETRACKING/
DATAFILE/
ble
ONLINELOG/
fe r a
TEMPFILE/
ans
ASMCMD> ls +DATA/ORCL/DATAFILE n - t r
EXAMPLE.260.630800437
a no
SYSAUX.257.628766309
a s
SYSTEM.256.628766309 ) h i d eฺ
TBSJMW.269.628767357 m
co nt Gu
i l ฺ
ma tude
UNDOTBS1.258.628766309
USERS.259.628766309 g
u k i@ is S
a sy se th
i M to u
(create
2) Using ASMCMD,
y u k s e a new directory called jmw in the DATA disk group. Then
create an s
a alias lcalled
c n
e +DATA/jmw/mytbs.f that points to the file used to store
y
yourMTBSJMW i
tablespace.
nle
Sta $ export ORACLE_SID=+ASM

$ asmcmd

ASMCMD> mkdir +DATA/jmw

ASMCMD> cd +DATA/ORCL/DATAFILE

ASMCMD> ls
...
TBSJMW.269.630835753 (Your numerical extension will be different!)
...
ASMCMD>

-- replace alias name with output from previous command


ASMCMD>

Oracle Database 11g: Administration Workshop II A - 24


Computer Pride Limited

ASMCMD> mkalias TBSJMW.269.630835753 +DATA/jmw/mytbs.f


ASMCMD> ls +DATA/jmw/
mytbs.f

3) Use ASMCMD to back up ASM metadata for the DATA disk group:
ASMCMD> md_backup -g data
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Disk group to be backed up: DATA


Current alias directory path: jmw
ASMCMD>

Backups performed through ASMCMD can be restored with the md_restore


command.
4) Use ASMCMD to make a copy of the EXAMPLE data file in the JMW directory.
ASMCMD> ls +DATA/ORCL/DATAFILE/EXAMPLE*
EXAMPLE.260.630800437
ble
fe r a
ASMCMD> cp +DATA/ORCL/DATAFILE/EXAMPLE.260.630800437
ans
+DATA/jmw/exampl01_copy.dbf (Your numerical extension may vary)
n - t r
a no
s
source +DATA/ORCL/DATAFILE/EXAMPLE.260.630800437
a
target +DATA/jmw/exampl01_copy.dbf
) h i d eฺ
copying file(s)... m
co nt Gu
ASMCMD> i l ฺ
ASMCMD> ls +DATA/jmw
g ma tude
exampl01_copy.dbf
u k i@ is S
sy se th
mytbs.f
ASMCMD> exit a
(M to u
$
k i
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 25


Computer Pride Limited

Practices for Lesson 2

Practice 2-1: Configuring ARCHIVELOG Mode


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you configure your database to archive redo logs before reusing them.
1) Set up the environment for the ORCL database, using the oraenv script, and enter
orcl when prompted for ORACLE_SID. If it is already set up for orcl (that is, you
see orcl in the brackets), press Enter.
Note: This command is a period, followed by a space, and then the oraenv script
name.
$ . oraenv
ORACLE_SID = [+ASM] ? orcl
ble
2) Run the size_memory_down.sh script to size the database appropriately for the
fe r a
following practices.
an s
$ cd ~/labs n - t r
$ ./size_memory_down.sh
a no
a s
) h
3) Determine the archive mode your database is running in now.
i d eฺ
m
co nt Gu
$ sqlplus / as sysdba
i
a de l ฺ
SQL*Plus: Release 11.1.0.6.0g- mProduction tu on Sat Jul 14
i @ S
02:17:17 2007
s y uk this
Copyright (c) 1982,
( M a 2007,
u seOracle. All rights reserved.
y u ki se to
M as to:
Connected l i c en
y
nleOracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Sta Production
With the Partitioning, OLAP and Data Mining options

SQL> archive log list


Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Current log sequence 6
SQL>

Note that it is running in NOARCHIVELOG mode.


4) Because you can change the ARCHIVELOG mode only when the database is
mounted, shut down the database.
SQL> shutdown immediate
Database closed.

Oracle Database 11g: Administration Workshop II A - 26


Computer Pride Limited

Practice 2-1: Configuring ARCHIVELOG Mode (continued)


Database dismounted.
ORACLE instance shut down.

5) Mount the database.


SQL> startup mount
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ORACLE instance started.

Total System Global Area 523108352 bytes


Fixed Size 1300904 bytes
Variable Size 373294680 bytes
Database Buffers 142606336 bytes
Redo Buffers 5906432 bytes
Database mounted.
SQL>

6) Alter the database to use ARCHIVELOG mode.


SQL> alter database archivelog; ble
fe r a
Database altered.
ans
n - t r
SQL>
a no
a s
7) Open the database.
) h i d eฺ
SQL> alter database open; m
co nt Gu
i l ฺ
Database altered. g ma tude
u k i@ is S
SQL>
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 27


Computer Pride Limited

Practice 2-2: Resizing the Flash Recovery Area


In this practice, you enlarge the Flash Recovery Area.
1) Determine how big the Flash Recovery Area is now.
SQL> show parameter recovery_file_dest_size;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NAME TYPE VALUE


------------------------------------ ----------- -------------
db_recovery_file_dest_size big integer 4G
SQL>
Note that it is 4 GB in size.
2) How big could the Flash Recovery Area be?
a) Determine where the Flash Recovery Area is located.
SQL> show parameter recovery_file_dest;
ble
fe r a
NAME TYPE VALUE
ans
------------------------------------ -----------
t r
-------------
n -
no
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer
s a 4G
SQL>
) h a eฺ
m i d
Note that the Flash Recovery Area is in the FRA
i l ฺ t Gu
co diskngroup.
b) Using EM, navigate to Database > Home m a > +ASM_<hostname>
de > Disk Groups.
g t u
S instance, provide sys and
u k i@
If prompted for login credentials for the ASM
i s
oracle as the username
s y and t h
password,
e respectively. When the disk group list
appears, note theM
( a uscolumn for the FRA disk group.
Usable Free
i
uk nse t o
s y
a lice
y M
nle
Sta
Note that the FRA disk group has enough usable free space to enlarge the Flash
Recovery Area considerably.
3) Change the Flash Recovery Area size to 6 GB.
a) Navigate to Database > Availability > Recovery Settings and change the Flash
Recovery Area Size to 6 GB. Click Show SQL, and note the SQL that will be run.
This is important to know because if the Flash Recovery Area is having sizing
problems, you may not be able to run Enterprise Manager to change it.
ALTER SYSTEM SET db_recovery_file_dest_size = 6442450944 SCOPE=BOTH

Oracle Database 11g: Administration Workshop II A - 28


Computer Pride Limited

Practice 2-2: Resizing the Flash Recovery Area (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

b) Click Return, and then click Apply.


4) Verify the size of the Flash Recovery Area by using SQL*Plus. ble
fe r a
SQL> show parameter recovery_file_dest_size;
t r a ns
NAME TYPE o n
VALUE -
------------------------------------ ----------- n
a -------------
db_recovery_file_dest_size s
ha ideฺ
big integer 6G
SQL> )
m Gu
ฺ c o t
a il e n
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
y
nle
Sta

Oracle Database 11g: Administration Workshop II A - 29


Computer Pride Limited

Practice 2-3: Verifying the Backup Destination


In this practice, you test the backup destination to see where backups are written.
1) Use the oraenv script to ensure you are still using the orcl instance in your
terminal session.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ . oraenv

2) Start RMAN.
$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Jul


17 22:45:39 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1155655108)


ble
fe r a
RMAN>
ans
3) See if the control files are automatically backed up. n - t r
a no
RMAN> show CONTROLFILE AUTOBACKUP;
a s
h eฺ
) withuiddb_unique_name
RMAN configuration parameters for database m
ORCL are:
a i l ฺco nt G
CONFIGURE CONTROLFILE AUTOBACKUP
g m OFF; t u d#edefault
k
Note that automatic backup is not enabled.is S
i@
u
sy sebackthup the control file when any backups are
a
4) Configure RMAN to automatically
(M to u
done. k i
RMAN> aconfigure
se
syu cencontrolfile autobackup on;
y M l i
nlenew RMAN configuration parameters:
Sta CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
5) Take a backup of data file 5, and note where the backup is written.
RMAN> backup datafile 5;

Starting backup at 2007-08-01:21:24:08


using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005
name=+DATA/orcl/datafile/example.265.629496303
channel ORA_DISK_1: starting piece 1 at 2007-08-01:21:24:09
channel ORA_DISK_1: finished piece 1 at 2007-08-01:21:24:35

Oracle Database 11g: Administration Workshop II A - 30


Computer Pride Limited

Practice 2-3: Verifying the Backup Destination (continued)


piece
handle=+FRA/orcl/backupset/2007_08_01/nnndf0_tag20070801t21240
9_0.260.629501049 tag=TAG20070801T212409 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:26
Finished backup at 2007-08-01:21:24:35
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>
Note that the backup file is written to the Flash Recovery Area.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 31


Computer Pride Limited

Practice 2-4: Configuring the Retention Policy


In this practice, you configure a retention policy for backups.
1) Use the oraenv script to ensure that you are still using the ORCL instance in your
terminal session.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ . oraenv

2) Return to the RMAN session and show the current retention policy setting.
RMAN> show retention policy;

using target database control file instead of recovery catalog


RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO NONE;

RMAN>
ble
Note that there is currently no retention policy configured. fe r a
ans
t r
3) Change the retention policy to ensure that at least one copy of each file is backed up.
n -
RMAN> configure retention policy to redundancy 1; a no
a s
old RMAN configuration parameters: ) h i d eฺ
CONFIGURE RETENTION POLICY TO NONE;co m G u
new RMAN configuration parameters: i l ฺ
a den1; t
CONFIGURE RETENTION POLICY TO g mREDUNDANCY
tu successfully stored
new RMAN configuration k i @ is Sare
parameters

a s yu e th
RMAN>
i ( M to us
y uk policy
4) Check the retention
s n se setting again.
a ic e
l e y M show lretention
RMAN> policy;
n
Sta RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;

RMAN> exit

Oracle Database 11g: Administration Workshop II A - 32


Computer Pride Limited

Practices for Lesson 3

Practice 3-1: Creating a Recovery Catalog


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you create a recovery catalog.

1) First, stop the listener.

$lsnrctl stop

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 12-NOV-2008


14:03:30

ble
Copyright (c) 1991, 2007, Oracle. All rights reserved.
fe r a
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
an s
TNS-12541: TNS:no listener
n - t r
TNS-12560: TNS:protocol adapter error
a no
TNS-00511: No listener
a s
Linux Error: 2: No such file or directory
) h i d eฺ
Connecting to
m
co nt Gu
i l ฺ
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edu1r2p0.us.oracle.com)(PORT=

ma tude
1521)))
g
i@pressisCtrlS+ C to escape back to the prompt.
If this command appears to “hang,”kthen
u
a sy se th
k i (M to u
Now, restart the listener:

a yu ense
sstart
lic
$ lsnrctl

l e y Mfor Linux:
tan14:05:03
LSNRCTL Version 11.1.0.6.0 - Production on 12-NOV-2008
S
Copyright (c) 1991, 2007, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr: please


wait...

TNSLSNR for Linux: Version 11.1.0.6.0 - Production


System parameter file is
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/edu1r2p0/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edu1r2p0.us.oracle.com)(PORT=
1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER

Oracle Database 11g: Administration Workshop II A - 33


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 -
Production
Start Date 12-NOV-2008 14:05:03
Uptime 0 days 0 hr. 0 min. 0 sec
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Trace Level off


Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/edu1r2p0/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edu1r2p0.us.oracle.com)(PORT=
1521)))
The listener supports no services
ble
The command completed successfully
fe r a
ans
n - t r
2) Use DBCA to start the process of creating a recovery catalog database.
a no
$ dbca
a s
) h i d eฺ
m
co nt Gu
3) On the Welcome page, click Next. i l ฺ
g ma tude
4) On the Operations page, select theiCreate
k S option, and then click Next.
@ aisDatabase
u
sy se t h
a
(M to u
k i
a syu cense
yM li
l e
Stan

Oracle Database 11g: Administration Workshop II A - 34


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
coof General
G u
i l ฺ
5) On the Database Templates page, leave the default
a n t Purpose or Transaction
Processing, and then click Next. gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 35


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


6) On the Database Identification page, enter the name of the recovery catalog database.
Use rcat as the Global Database Name. Then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m Gu Manager option,
co nEnterprise
7) On the Management Options page, deselect the ฺConfigure
i l t
and then click Next.
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan

8) On the Database Credentials page, select the option Use the Same Administrative
Password for All Accounts. Then enter oracle in the password fields and click Next.

Oracle Database 11g: Administration Workshop II A - 36


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
9) On the Storage Options page, select File System asothe u
storage mechanism,
G and then
click Next. ฺ
ail den t
m
g Stu
i @
s y uk this
( M a use
y u ki se to
M as licen
n l ey
Sta

10) On the Database File Locations Page, select Use Common Location for all Database
Files, and enter /u01/app/oracle/oradata as the path. Then click Next.

Oracle Database 11g: Administration Workshop II A - 37


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
h a s ฺ
11) On the Recovery Configuration page, increase the size )of the Flash
i d eRecovery Area to
o m G u
4096 MB. Then click Next.
a ilฺc ent
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta

12) On the Database Control page, enable the Sample Schemas option, and then click
Next.

Oracle Database 11g: Administration Workshop II A - 38


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co size G u
i l ฺ
13) On the Initialization Parameter page, set the memory
a Next. den tto 300 MB, enable
Automatic Memory Management, and then m
click
g Stu
i @
s y uk this
( M a use
y u ki se to
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 39


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


14) On the Security Settings page, keep the defaults, and then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g madisable
15) On the Automatic Maintenance Task page,
t u dtheeautomatic tasks, and click
Next.
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan

Oracle Database 11g: Administration Workshop II A - 40


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


16) On the Database Storage page, review the configuration, and then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i
a del ฺ
g mthat
17) On the Creation Options page, make sure tu Database is the only option
Create
selected, and then click Finish. uk i @ is S
s y t h
( M a use
y u ki se to
M as licen
n l ey
Sta

18) Review the Confirmation page, and then click OK to start the database creation
process.

Oracle Database 11g: Administration Workshop II A - 41


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g mthea database.
The Database Creation Assistant now creates t u de
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan

Oracle Database 11g: Administration Workshop II A - 42


Computer Pride Limited

Practice 3-1: Creating a Recovery Catalog (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ
then click Exit. g m tuden view the final page, and
19) When the Database Configuration Assistantafinishes running,

u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan

Oracle Database 11g: Administration Workshop II A - 43


Computer Pride Limited

Practice 3-2: Creating the Recovery Catalog Owner


In this practice/task, you configure the recovery catalog database with a user ID and
appropriate privileges, and register a database.
1) Use SQL*Plus to configure the recovery catalog database. Connect to it as SYS.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ sqlplus sys/oracle@rcat as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Jul 18


03:52:44 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options
ble
SQL>
fe r a
an s
t r
2) Create a tablespace named RCAT to hold the repository data. Make it 15 MB in size.
n -
n o
SQL> create tablespace rcat datafile a
ssize 15M;
‘/u01/app/oracle/oradata/rcat/rcat01.dbf’
) h a eฺ
m i d
Tablespace created.
i l ฺ co nt Gu
SQL> g ma tude
k i@ catalog
3) Create a user who will own theurecovery i s Sdata. Name the user RCATOWNER.
The default tablespace should sbey the RCAT
e h
t tablespace, and the user should have
unlimited quota on that (M a
tablespace. u s
k
u nsei t o
a syuser c ercatowner identified by oracle
M
SQL> create
y l i
l e
2 default tablespace rcat

Stan3 quota unlimited on rcat;


User created.

SQL>

4) Grant the RECOVERY_CATALOG_OWNER role to the RCATOWNER user.


SQL> grant recovery_catalog_owner to rcatowner;

Grant succeeded.

SQL> exit

Practice 3-3: Creating the Recovery Catalog


In this practice, you create the recovery catalog inside the recovery catalog database you
have prepared.

Oracle Database 11g: Administration Workshop II A - 44


Computer Pride Limited

Practice 3-3: Creating the Recovery Catalog (Continued)


1) Connect to the recovery catalog database using RMAN. Log in as the recovery
catalog owner you just created.
$ rman catalog rcatowner@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

18 03:38:21 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

recovery catalog database Password:oracle


connected to recovery catalog database

RMAN>

2) Create the recovery catalog. This command may take several minutes to complete.
RMAN> create catalog;
ble
fe r a
recovery catalog created
ans
n - t r
no
RMAN> exit

s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 45


Computer Pride Limited

Practice 3-4: Registering a Database in the Recovery Catalog


In this practice, you register the ORCL database in the recovery catalog that you have just
created.
1) Set up the environment for the ORCL database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ . oraenv
ORACLE_SID = [orcl] ? orcl

2) Connect to the target database (to be registered) and the recovery catalog database
using RMAN.
$ rman target / catalog rcatowner@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul


18 03:58:10 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.


ble
fe r a
connected to target database: ORCL (DBID=1155655108)
an s
recovery catalog database Password:oracle
n - t r
connected to recovery catalog database
a no
a s
RMAN>
) h i d eฺ
3) Register the database in the catalog. m
co nt Gu
i l ฺ
RMAN> register database;
g ma tude
i@ iscatalogS
database registered inuk h
t catalog
syof recovery
recovery
starting full resync a s e
i (M to u
full resync complete
k
syu cense
RMAN> aexit
y M li
l e
n4) Register the recovery catalog to be used by Enterprise Manager.
Sta a) In EM, navigate to Availability > Recovery Catalog Settings.
b) Click Add Recovery Catalog.
c) Enter the following information:
Host: <your_hostname>
Port: 1521
SID: rcat
Recovery Catalog Username: rcatowner
Recovery Catalog Password: oracle

Oracle Database 11g: Administration Workshop II A - 46


Computer Pride Limited

Practice 3-4: Registering a Database in the Recovery Catalog


(continued)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
n o
d) On the Review page, click Finish. s a
e) Back on the Recovery Catalog Settings page, select)Use haRecovery
i d eฺCatalog.
m u
o t isGselected
cregistered
i l
f) Make sure that the recovery catalog you just
a ฺ n in the drop-
down list, and then click OK. gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
y
nle
Sta

Oracle Database 11g: Administration Workshop II A - 47


Computer Pride Limited

Practice 3-5: Cataloging Additional Backup Files


In this practice/task, you make a manual backup of a file, and then catalog it, allowing it
to appear in the recovery catalog.
1) Take the USERS tablespace offline, so you can manually make a copy of its data file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus / as sysdba
SQL> alter tablespace users offline;

Tablespace altered.

SQL>

2) Go to another terminal session and use the copy_users_df.sh script to make a


copy of the data file for the USERS tablespace. Run this script as the oracle user.
The copy is /tmp/users_copy.dat. ble
fe r a
$ cd ~/labs
an s
$ ./copy_users_df.sh
n - t r
source +data/orcl/datafile/USERS.259.627874231
a no
target /tmp/users_copy.dat
a s
copying file(s)...
) h i d eฺ
file, /tmp/users_copy.dat, copy committed. m
co nt Gu
$ i
a del ฺ
g m u
3) Back in the SQL*Plus session, bring the USERSttablespace back online.
k i @ i s S
SQL> alter tablespace
a syuusers e th
online;

Tablespace k i (M to us
altered.
a s yu ense
yM
SQL> lic
l e
n4) Start an RMAN session, connecting to the ORCL instance as the target, and also
Sta connecting to the RCAT instance as the recovery catalog. Again, use oraenv to set
up the environment for the ORCL instance.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ rman target / catalog rcatowner/oracle@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul


18 22:14:47 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1155655108)


connected to recovery catalog database

RMAN>

Oracle Database 11g: Administration Workshop II A - 48


Computer Pride Limited

Practice 3-5: Cataloging Additional Backup Files (continued)


5) List the image copy backups available.
RMAN> list datafilecopy all;

RMAN-00571:
===========================================================
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS


===============
RMAN-00571:
===========================================================
RMAN-03002: failure of list command at 07/18/2007 22:27:40
RMAN-06004: ORACLE error from recovery catalog database: RMAN-
20230: datafile copy not found in the recovery catalog

RMAN>
Note that there are none at this point.
6) Catalog the image copy of the USERS data file. ble
fe r a
RMAN> catalog datafilecopy '/tmp/users_copy.dat';
an s
n - t r
cataloged datafile copy
a no
datafile copy file name=/tmp/users_copy.dat RECID=3
a s
STAMP=628295424
) h i d eฺ
m
co nt Gu
RMAN> i l
a de ฺ
g
7) Again, list the data file copies available.mThen exittuRMAN.
i @ S
RMAN> list datafilecopy
s y ukall; this
( M a use
starting full
u i resync
kcomplete e toof recovery catalog
y
asDatafile
full resync s
en Copies
M
List
y
of
l i c
nle
=======================

Sta Key File S Completion Time Ckp SCN Ckp Time


------- ---- - --------------- ---------- ---------------
260 4 A 18-JUL-07 1008905 18-JUL-07
Name: /tmp/users_copy.dat

RMAN> exit

Note that the data file copy you made manually is now listed as a backup in the
recovery catalog.

Oracle Database 11g: Administration Workshop II A - 49


Computer Pride Limited

Practice 3-6: Backing Up the Recovery Catalog


In this practice, you back up your recovery catalog.
1) Start RMAN, but this time use the recovery catalog database as the target, with no
catalog specified.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ rman target sys/oracle@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul


18 22:44:45 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: RCAT (DBID=400373882)

RMAN>
2) Make sure that the retention policy is set to redundancy greater than 1. If it is not, set ble
it to at least 2.
fe r a
ans
RMAN> show retention policy;
n - t r
a no
using target database control file instead of recovery catalog
a s
RMAN configuration parameters for database with db_unique_name
) h i d eฺ
RCAT are:
m
co nt Gu
i l ฺ
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN> configure retention policy g ma toturedundancy


de 2;
i @ is S
s y ukparameters:
t h
seTO REDUNDANCY 2;
new RMAN configuration
(
CONFIGURE RETENTION M a POLICY
u
u ki se to parameters are successfully stored
new RMAN configuration
y
M
RMAN> as licen
y
n3)leBack up the database.
Sta RMAN> backup database;

Starting backup at 18-JUL-07


ORACLE error from target database:
ORA-00258: manual archiving in NOARCHIVELOG mode must identify
log

using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=137 device type=DISK
specification does not match any archived log in the recovery
catalog
backup cancelled because all files were skipped
Finished backup at 18-JUL-07

Oracle Database 11g: Administration Workshop II A - 50


Computer Pride Limited

Starting backup at 18-JUL-07


using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

===============
RMAN-00571:
===========================================================
RMAN-03002: failure of backup plus archivelog command at
07/18/2007 22:55:45
ORA-19602: cannot backup or copy active file in NOARCHIVELOG
mode

RMAN>

Note that you cannot back up an open database that is not in ARCHIVELOG mode.
The recovery catalog database should be run in ARCHIVELOG mode for maximum ble
availability. fe r a
ans
4) Exit RMAN.
n - t r
RMAN> exit
a no
a s
5) Run the rcat_to_archivelog.sh script to change ) h
the recovery
i d eฺcatalog
database to run in ARCHIVELOG mode. m
co nt Gu
i l ฺ
$ cd ~/labs
g ma tude
$ ./rcat_to_archivelog.sh
u k i@ is S
Database closed.
Database dismounted. a sy se th
ORACLE instance i u
(Mshuttodown.
k se
syu censtarted.
ORACLE instance
a
l e y M Systemli Global Area 263639040 bytes
Total
n Fixed Size
Sta
1299164 bytes
Variable Size 230690084 bytes
Database Buffers 25165824 bytes
Redo Buffers 6483968 bytes
Database mounted.

Database altered.

Database altered.

6) Log in to RMAN again, as in the preceding step.


$ rman target sys/oracle@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Sun Aug


19 08:33:45 2007

Oracle Database 11g: Administration Workshop II A - 51


Computer Pride Limited

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: RCAT (DBID=403110344)

RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

7) Try to back up the recovery catalog database again.


RMAN> backup database;

Starting backup at 2007-07-31:22:48:53


using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001
name=+DATA/rcat/datafile/system.264.629081371
input datafile file number=00002
name=+DATA/rcat/datafile/sysaux.269.629081371
ble
input datafile file number=00003
fe r a
name=+DATA/rcat/datafile/undotbs1.270.629081373input datafile
ans
file number=00005 name=+DATA/rcat/datafile/rcat.294.629356557
n - t r
no
input datafile file number=00004
name=+DATA/rcat/datafile/users.271.629081373
s a
a
channel ORA_DISK_1: starting piece 1 at 2007-07-31:22:49:00
) h eฺ
i d
channel ORA_DISK_1: finished piece 1 at 2007-07-31:22:52:37
m
piece
i l ฺ co nt Gu
g ma tude
handle=+FRA/rcat/backupset/2007_07_31/nnndf0_tag20070731t22485
3_0.298.629419741 tag=TAG20070731T224853 comment=NONE
k i@ is S
channel ORA_DISK_1: backup set complete, elapsed time:
u
00:03:37
a sy se th
k i (M to u
Finished backup at 2007-07-31:22:52:37

RMAN> syu
a e n se
yM
8) eRun lic
the disable_asynch_io.sh script to disable asynchronous input/output
n l
Sta (I/O). This improves performance on the following labs:
$ ~/labs/disable_asynch_io.sh

Oracle Database 11g: Administration Workshop II A - 52


Computer Pride Limited

Practices for Lesson 4

Practice 4-1: Setting the Date and Time Format for RMAN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you set the date/time format that RMAN uses for displaying timestamps.
1) Set the NLS_LANG and NLS_DATE_FORMAT variables such that RMAN includes
time information in any timestamp values. Add the following two lines to the
~oracle/.bashrc file. Then exit all of your terminal windows. This ensures that
when you create new ones, these settings will be in effect.
export NLS_LANG=american_america.al32utf8
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"

2) Start a new terminal window, and verify the settings by starting RMAN and listing
the backups of the recovery catalog database.
ble
a) Start RMAN. fe r a
ans
$ rman target sys/oracle@rcat
n - t r
a
b) List the backups, and note the timestamp format. no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
ma tude
RMAN> list backup;
g
List of Backup Sets yuk
i@ is S
a s e th
===================
i ( M to us
s y uk nse
BS Keya TypecLV e Size
y M l i Device Type Elapsed Time Completion

nle------- ---- -- ---------- ----------- ------------ ----------


Time

Sta ---------
1 Full 9.36M DISK 00:00:02 2007-10-
05:03:49:29
BP Key: 1 Status: AVAILABLE Compressed: NO Tag:
TAG20071005T034926
Piece Name:
+FRA/rcat/backupset/2007_10_05/ncsnf0_tag20071005t034926_0.268
.635140169
SPFILE Included: Modification time: 2007-10-05:03:48:04
SPFILE db_unique_name: RCAT
Control File Included: Ckp SCN: 656862 Ckp time: 2007-
10-05:03:49:27
.
.
.
RMAN>

Oracle Database 11g: Administration Workshop II A - 53


Computer Pride Limited

Practice 4-2: Enabling Control File Autobackup


In this practice/task, you configure RMAN to back up the control file and SPFILE each
time it takes a backup of anything in the RCAT database.
1) In the same recovery catalog RMAN session, make sure that control file autobackup
is enabled.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> show controlfile autobackup;

RMAN configuration parameters for database with db_unique_name


RCAT are:
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

RMAN>

2) Enable control file autobackup.


RMAN> configure controlfile autobackup on;
ble
fe r a
new RMAN configuration parameters:
ans
CONFIGURE CONTROLFILE AUTOBACKUP ON;
n - t r
new RMAN configuration parameters are successfully stored
a no
a s
RMAN>
) h i d eฺ
3) Verify that it is enabled by backing up the archive c m
ologs fort the
G urecovery catalog. Then
i l ฺ
exit RMAN.
g ma tuden
RMAN> backup archivelog all;
u k i@ is S
a y th
s2007-08-20:00:54:40
e
Starting backup at
i
current log archived( M to us
y
using channel
s uk ORA_DISK_1
n se starting archived log backup set
a
channel
lic e
ORA_DISK_1:
l e y M ORA_DISK_1:
channel specifying archived log(s) in backup set
n
Sta
input archived log thread=1 sequence=7 RECID=2 STAMP=631018870
input archived log thread=1 sequence=8 RECID=4 STAMP=631040459
input archived log thread=1 sequence=9 RECID=6 STAMP=631062069
input archived log thread=1 sequence=10 RECID=8
STAMP=631068038
input archived log thread=1 sequence=11 RECID=10
STAMP=631068883
channel ORA_DISK_1: starting piece 1 at 2007-08-20:00:54:50
channel ORA_DISK_1: finished piece 1 at 2007-08-20:00:55:55
piece
handle=+FRA/rcat/backupset/2007_08_20/annnf0_tag20070820t00544
3_0.289.631068891 tag=TAG20070820T005443 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:01:05
Finished backup at 2007-08-20:00:55:55

Starting Control File and SPFILE Autobackup at 2007-08-


20:00:55:55

Oracle Database 11g: Administration Workshop II A - 54


Computer Pride Limited

Practice 4-2: Enabling Control File Autobackup (continued)


piece
handle=+FRA/rcat/autobackup/2007_08_20/s_631068955.291.6310689
63 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-08-
20:00:56:10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> exit

Note that the control file and SPFILE are automatically backed up now.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 55


Computer Pride Limited

Practice 4-3: Configuring Devices for Backup


In this practice, you configure a tape device for use in making backups.
1) Make sure the SID variable is set to ORCL.
$ . oraenv
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ORACLE_SID = [orcl] ? orcl

2) Start RMAN by connecting to the ORCL as the target database and using the recovery
catalog database.
$ rman target / catalog rcatowner/oracle@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Aug


20 01:00:48 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.


ble
connected to target database: ORCL (DBID=1157684688)
fe r a
connected to recovery catalog database
ans
n - t r
RMAN>
a no
h s devices
3) Show all configuration settings to see whether there are anyatape
ฺ defined.
) id e
RMAN> show all;
o m G u
a lฺc ent
icatalog
starting full resync of recovery
@ gm Stud
ki thfor
full resync complete
y u
RMAN configuration parameters is database with db_unique_name
ORCL are: s
a POLICY seTO REDUNDANCY 1;
( M to u
CONFIGURE u
y ki sOPTIMIZATION
CONFIGURE RETENTION
BACKUP e OFF; # default
a s DEFAULTe n
lic
CONFIGURE DEVICE TYPE TO DISK; # default
y M
CONFIGURE CONTROLFILE AUTOBACKUP ON;
n l e
Sta
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
# default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_orcl.f'; #
default

RMAN>

Oracle Database 11g: Administration Workshop II A - 56


Computer Pride Limited

Note that there are no tape devices.


4) Define a channel for a tape device that uses the test interface. This actually writes to
disk in the /tape directory.
RMAN> configure channel device type sbt
2> parms='SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/tape)';
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

new RMAN configuration parameters:


CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS
'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/tape)';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>

5) Perform a backup to the tape device to make sure it works. Back up the USERS
tablespace. Then exit RMAN.
ble
fe r a
RMAN> backup device type sbt tablespace users;
ans
...
Starting backup at 2007-08-20:02:13:50 n - t r
released channel: ORA_DISK_1
a no
using channel ORA_SBT_TAPE_1
a s
) h d eฺ
channel ORA_SBT_TAPE_1: starting full datafile backup set
i
m
co nt Gu
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
i l ฺ
ma tude
input datafile file number=00004
g
name=+DATA/orcl/datafile/users.263.630812119

u k i@ is S
channel ORA_SBT_TAPE_1: starting piece 1 at 2007-08-
20:02:13:57
a sy se th
(M to u
channel ORA_SBT_TAPE_1: finished piece 1 at 2007-08-
k
20:02:13:58 i
syu cense
piece handle=0gipqqqu_1_1 tag=TAG20070820T021350 comment=API
a
yM li
Version 2.0,MMS Version 8.1.3.0

nle channel ORA_SBT_TAPE_1: backup set complete, elapsed time:

Sta
00:00:01
Finished backup at 2007-08-20:02:13:58

Starting Control File and SPFILE Autobackup at 2007-08-


20:02:13:58
piece handle=c-1157684688-20070820-02 comment=API Version
2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2007-08-
20:02:14:15

RMAN> exit

Note that it uses a channel called ORA_SBT_TAPE_1 to perform the backup.

Oracle Database 11g: Administration Workshop II A - 57


Computer Pride Limited

Practices for Lesson 5

Practice 5-1: Creating Fast Incremental Backups


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you enable block change tracking so that you can make incremental
backups more quickly.
1) Use Enterprise Manager Database Control to configure backup optimization and
enable block change tracking. Allow a default block change tracking file to be used.
a) From the Database home page of EM, navigate to Availability > Backup Settings
> Policy, and enable backup optimization and block change tracking.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta b) Click OK.
c) If you see the following error, you have not entered the operating system
credentials. Continue with the following steps if that is the case.

d) Scroll to the bottom of the page, and enter oracle and oracle for the
username and password, respectively. Also, select the option to save this as the
preferred credential.

Oracle Database 11g: Administration Workshop II A - 58


Computer Pride Limited

Practice 5-1: Creating Fast Incremental Backups (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

e) Click OK.
2) Make sure that the ORACLE_SID variable is set to ORCL.
$ . oraenv
ORACLE_SID = [orcl] ? orcl

3) Log in to RMAN and create an incremental level 0 backup.


$ rman target / catalog rcatowner/oracle@rcat
ble
RMAN> backup incremental level 0 database plus archivelog;
fe r a
ans
starting full resync of recovery catalog
n - t r
full resync complete
a no
.
a s
.
) h i d eฺ
. m
co nt Gu
i l ฺ
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:03
g ma tude
Finished backup at 19-JUL-07
u k i@ is S
RMAN> a sy se th
i u
(aMlevel 0toincremental
k
4) Now that you have backup, you can take advantage of block
changea
tracking nsefast incremental backups. Take a level 1 incremental backup.
syu ctoemake
l e y M backupli incremental level 1 database plus archivelog;
RMAN>
n
Sta
Starting backup at 19-JUL-07
current log archived
using channel ORA_DISK_1
.
.
.
piece
handle=+FRA/orcl/backupset/2007_07_19/annnf0_tag20070719t01501
1_0.278.628307417 tag=TAG20070719T015011 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:03
Finished backup at 19-JUL-07

RMAN>

5) In another terminal window, make sure you are at the ~/labs directory.

Oracle Database 11g: Administration Workshop II A - 59


Computer Pride Limited

Practice 5-1: Creating Fast Incremental Backups (continued)


$ cd ~/labs

6) Run the query_block_count.sh script to query V$BACKUP_DATAFILE to see


how many of the blocks were read for creating the level 1 incremental backup.
$ ./query_block_count.sh
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 19


02:04:41 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options

SQL> 2 3 4 5 6 7 8 ble
FILE# AVG(DATAFILE_BLOCKS) AVG(BLOCKS_READ)
fe r a
PCT_READ_FOR_BACKUP AVG(BLOCKS)
ans
---------- -------------------- ---------------- -------------
n - t r
------ -----------
a no
1 89600 193
a s
.215401786 33
) h i d eฺ
2 78968 m
co nt Gu
1565
1.98181542 699
i l ฺ
5 ma tude
12800
g 1
.0078125 1
u k i@ is S
sy se th
4 640 1
.15625 a1
(M to u
3
k i 11520 383

syu cense
3.32465278 196
a li
MDisconnected
l e y
SQL> from Oracle Database 11g Enterprise Edition
n Release 11.1.0.6.0 - Production
Sta With the Partitioning, OLAP and Data Mining options
[oracle@edcdr11p1 labs]$

Note that the percentage of blocks read for making the backup is very low in most cases,
and sometimes very close to zero.

Oracle Database 11g: Administration Workshop II A - 60


Computer Pride Limited

Practice 5-2: Cross-Checking Backups


In this practice, you cross-check backups against the recovery catalog, identifying and
deleting any backups that are obsolete.
1) Make sure that you are at the ~/labs directory, and that the ORACLE_SID variable
is set to ORCL.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ cd ~/labs
$ . oraenv

2) Use the RMAN session from the previous practice or start RMAN. Make sure that
you connect to both your target database and the recovery catalog database.
$ rman target / catalog rcatowner/oracle@rcat

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul


18 20:53:06 2007
ble
Copyright (c) 1982, 2007, Oracle. All rights reserved.
fe r a
ans
connected to target database: ORCL (DBID=1155655108)
n - t r
connected to recovery catalog database
a no
a s
RMAN>
) h i d eฺ
m
co nttoGtheu example data file.
3) List backups of data file 5, noting the entry corresponding
i
a del ฺ
RMAN> list backup of datafile 5;m
i @ g S tu
List of Backup Setsasy
uk this
( M u se
ki se to
===================

y u
M
BS KeyasTypeliLV
c n
eSize Device Type Elapsed Time Completion Time
l e y
------- ---- -- ---------- ----------- ------------ ---------------
n 58
Sta
Full 69.01M DISK 00:00:26 22-AUG-07
BP Key: 61 Status: AVAILABLE Compressed: NO Tag:
TAG20070822T235728
Piece Name:
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
List of Datafiles in backup set 58
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
5 Full 1066265 22-AUG-07
+DATA/orcl/datafile/example.261.631245463

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
470 Incr 0 1.13G DISK 00:05:32 24-AUG-07
BP Key: 472 Status: AVAILABLE Compressed: NO Tag:
TAG20070824T004556
Piece Name:
+FRA/orcl/backupset/2007_08_24/nnndn0_tag20070824t004556_0.285.631413967
List of Datafiles in backup set 470

Oracle Database 11g: Administration Workshop II A - 61


Computer Pride Limited

Practice 5-2: Cross-Checking Backups (continued)


File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
5 0 Incr 1194715 24-AUG-07
+DATA/orcl/datafile/example.261.631245463

BS Key Type LV Size Device Type Elapsed Time Completion Time


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

------- ---- -- ---------- ----------- ------------ ---------------


594 Incr 1 1.19M DISK 00:00:11 24-AUG-07
BP Key: 598 Status: AVAILABLE Compressed: NO Tag:
TAG20070824T005242
Piece Name:
+FRA/orcl/backupset/2007_08_24/nnndn1_tag20070824t005242_0.295.631414371
List of Datafiles in backup set 594
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
5 1 Incr 1195391 24-AUG-07
+DATA/orcl/datafile/example.261.631245463

RMAN>
ble
Take note of the only backup that is a full backup of data file 5. Also note that the fe r a
“Piece Name” is the name of the ASM file where the backup file resides. ans
n - t r
a no
4) In an OS terminal window, delete the backup set file. Start a separate terminal
session, so the RMAN session can stay connected. Use the rm_asm_file.sh
a s
) h i d eฺ
script to do this. Supply the full “Piece Name” as an argument to the script.
m
co nt Gu
$ ./rm_asm_file.sh \
i
a del ฺ
g m
> +FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
tu
$
i @ S
is that corresponds to the example
s
5) List the backups again, andy ukfor thethbackup
look
data file. ( M a use
u
backup s
to
ki ofedatafile
RMAN> list
a y
s cen 5;

y M li
l e
n List of Backup Sets
Sta ===================

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ -------------------
484 Full 68.41M DISK 00:00:23 2007-07-31:07:05:37
BP Key: 485 Status: AVAILABLE Compressed: NO Tag:
TAG20070731T070514
Piece Name:
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
List of Datafiles in backup set 484
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
5 Full 1338638 2007-07-31:07:05:21
+DATA/orcl/datafile/example.260.628901531

RMAN>

Oracle Database 11g: Administration Workshop II A - 62


Computer Pride Limited

Practice 5-2: Cross-Checking Backups (continued)


Note that the backups are still listed as before. That is because the repository is not
aware of the fact that the file for the backup piece is missing.
6) Cross-check the backup sets to make the recovery catalog aware of the missing
backup file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> crosscheck backupset;

using channel ORA_DISK_1


crosschecked backup piece: found to be 'EXPIRED'
backup piece
handle=+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.26
5.631324655 RECID=7 STAMP=631324655
.
.
.

RMAN>
ble
fe r a
Note that the backup in question has expired. s
7) Delete all the expired backup sets. - t r an
no n
RMAN> delete expired backupset;
s a
) h a eฺ
m i d
co nt Gu
using channel ORA_DISK_1
i l ฺ
List of Backup Pieces
g ma tuDevice
de Type Piece Name
i@ is S ----------- ----------
BP Key BS Key Pc# Cp# Status
------- ------- --- ---k-----------
1 sy
u th
485 484
M a 1
u e
EXPIRED
s DISK

4655
u k i ( e to
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.63132

sy cewant
youa really
ns to delete the above objects (enter YES or
l e y YES li
Do M
NO)?
n
Sta deleted backup piece
backup piece
handle=+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.26
5.631324655 RECID=7 STAMP=631324655

RMAN>
8) List the backup sets again. See that the backup you just deleted is no longer listed.
RMAN> list backup of datafile 5;

List of Backup Sets


===================

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
470 Incr 0 1.13G DISK 00:05:32 24-AUG-07

Oracle Database 11g: Administration Workshop II A - 63


Computer Pride Limited

Practice 5-2: Cross-Checking Backups (continued)


BP Key: 472 Status: AVAILABLE Compressed: NO Tag:
TAG20070824T004556
Piece Name:
+FRA/orcl/backupset/2007_08_24/nnndn0_tag20070824t004556_0.285.631413967
List of Datafiles in backup set 470
File LV Type Ckp SCN Ckp Time Name
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

---- -- ---- ---------- --------- ----


5 0 Incr 1194715 24-AUG-07
+DATA/orcl/datafile/example.261.631245463

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
594 Incr 1 1.19M DISK 00:00:11 24-AUG-07
BP Key: 598 Status: AVAILABLE Compressed: NO Tag:
TAG20070824T005242
Piece Name:
+FRA/orcl/backupset/2007_08_24/nnndn1_tag20070824t005242_0.295.631414371
List of Datafiles in backup set 594
File LV Type Ckp SCN Ckp Time Name
ble
---- -- ---- ---------- --------- ----
fe r a
5 1 Incr 1195391 24-AUG-07
ans
+DATA/orcl/datafile/example.261.631245463
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 64


Computer Pride Limited

Practice 5-3: Listing Backup Files


In this practice/task, you list backup files.
1) Continue to use the RMAN session from the previous practice, and generate a report
of all the obsolete backup files.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> report obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ ---------------
-----
Archive Log 43 2007-07-14:01:41:46
+DATA/orcl/archivelog/2007_07_14/thread_1_seq_2.267.627874879
Archive Log 44 2007-07-14:02:25:03
+DATA/orcl/archivelog/2007_07_14/thread_1_seq_3.268.627877489 ble
Archive Log 45 2007-07-16:23:24:47 fe r a
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_4.269.628125799
ans
Archive Log 46 2007-07-16:23:34:35
n - t r
no
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_5.270.628126293
a
Archive Log 47 s
2007-07-16:23:39:24
a
) h eฺ
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_6.271.628126685
i d
Archive Log 48 m
co nt Gu
2007-07-16:23:41:16
i l ฺ
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_7.272.628126865
Archive Log 49
g ma tude
2007-07-17:00:04:59

u k i@ is S
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_8.273.628128279

sy se th
Archive Log 50 2007-07-17:03:44:28
a
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_9.274.628141457
(M to u
Archive Log
k i 53 2007-07-17:22:03:18
syu cense
+FRA/orcl/archivelog/2007_07_17/thread_1_seq_12.262.628207215
a
Archive Log 54 2007-07-18:00:23:14
yM li
nle +FRA/orcl/archivelog/2007_07_18/thread_1_seq_13.264.628215781

Sta
Archive Log 119 2007-07-18:05:49:47
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_14.265.628235371
Backup Set 57 2007-07-17:23:42:43
Backup Piece 60 2007-07-17:23:42:43
+FRA/orcl/backupset/2007_07_17/nnndf0_tag20070717t234236_0.263
.628213363
Archive Log 120 2007-07-18:11:06:54
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_15.266.628254397
Archive Log 121 2007-07-18:17:24:08
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_16.267.628277033
Archive Log 241 2007-07-18:22:26:03
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_17.269.628294951
Datafile Copy 260 2007-07-18:22:30:24
/tmp/users_copy.dat
Archive Log 304 2007-07-19:01:08:12
+FRA/orcl/archivelog/2007_07_19/thread_1_seq_18.268.628304879
Backup Set 312 2007-07-19:01:12:10

Oracle Database 11g: Administration Workshop II A - 65


Computer Pride Limited

Backup Piece 316 2007-07-19:01:12:10


+FRA/orcl/backupset/2007_07_19/annnf0_tag20070719t010814_0.270
.628304905
Backup Set 314 2007-07-19:01:15:53
Backup Piece 318 2007-07-19:01:15:53
+FRA/orcl/backupset/2007_07_19/ncsnn0_tag20070719t011221_0.272
.628305353
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>

What can you deduce about these backup files, given that the retention policy is set to
REDUNDANCY 1?
2) Which backups would be considered obsolete if the retention policy were set to
redundancy of 2, instead of 1? Answer this without changing the retention policy.
RMAN> report obsolete redundancy 2;

Report of obsolete backups and copies


ble
Type Key Completion Time Filename/Handle
fe r a
-------------------- ------ ------------------ ---------------
ans
-----
n - t r
no
Backup Set 84 2007-08-17:01:35:25
Backup Piece 87 2007-08-17:01:35:25
s a
a eฺ
+DATA/orcl/backupset/2007_08_17/nnsnf0_tag20070817t012756_0.26
) h
4.630812125
m i d
Control File Copy 94
co nt Gu
2007-08-17:01:35:07
i l ฺ
ma tude
+DATA/orcl/controlfile/backup.262.630811889
Backup Set 86 g 2007-08-17:02:59:08
Backup Piece
u k
89 i@ is S
2007-08-17:02:59:08
sy se th
+FRA/orcl/autobackup/2007_08_17/s_630817140.261.630817147
a
Backup Set
k i
Backup Piece(M to u110
114
2007-08-19:08:23:23
2007-08-19:08:23:23
syu cense
+FRA/orcl/autobackup/2007_08_19/s_631009384.278.631009401
a
yM li
Datafile Copy 124 2007-08-19:08:27:40

nle /tmp/users_copy.dat

Sta
Backup Set 111 2007-08-19:08:24:50
Backup Piece 115 2007-08-19:08:24:50
+FRA/orcl/autobackup/2007_08_19/s_631009483.279.631009489
Backup Set 280 2007-08-20:01:55:44
Backup Piece 282 2007-08-20:01:55:44
+FRA/orcl/autobackup/2007_08_20/s_631072536.294.631072545
Backup Set 434 2007-08-20:02:13:57
Backup Piece 435 2007-08-20:02:13:57 0gipqqqu_1_1
Backup Set 450 2007-08-20:02:14:08
Backup Piece 452 2007-08-20:02:14:08 c-1157684688-
20070820-02
Backup Set 483 2007-08-20:02:14:54
Backup Piece 486 2007-08-20:02:14:54 0iipqqsn_1_1
Backup Set 503 2007-08-20:02:15:04
Backup Piece 505 2007-08-20:02:15:04 c-1157684688-
20070820-03
Backup Set 577 2007-08-20:02:16:06

Oracle Database 11g: Administration Workshop II A - 66


Computer Pride Limited

Backup Piece 579 2007-08-20:02:16:06 c-1157684688-


20070820-04

RMAN>

Note that far fewer backups are obsolete in this hypothetical report. That is because
with an increased redundancy, more of the backups are required. This command is
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

run without affecting the retention policy.


3) Delete all obsolete backups.
RMAN> delete noprompt obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ ---------------
ble
-----
fe r a
Archive Log 43 2007-07-14:01:41:46
ans
+DATA/orcl/archivelog/2007_07_14/thread_1_seq_2.267.627874879
Archive Log 44 2007-07-14:02:25:03 n - t r
a no
+DATA/orcl/archivelog/2007_07_14/thread_1_seq_3.268.627877489
Archive Log 45
a s
2007-07-16:23:24:47
) h i d eฺ
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_4.269.628125799
Archive Log 46 m
co nt Gu
2007-07-16:23:34:35
i l ฺ
ma tude
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_5.270.628126293
. g
.
u k i@ is S
.
a sy se th
k i (M to u
archived log file
name=+FRA/orcl/archivelog/2007_07_19/thread_1_seq_18.268.62830
syu cense
4879 RECID=17 STAMP=628304892
a
yM li
deleted backup piece

nle backup piece

Sta
handle=+FRA/orcl/backupset/2007_07_19/annnf0_tag20070719t01081
4_0.270.628304905 RECID=5 STAMP=628304904
deleted backup piece
backup piece
handle=+FRA/orcl/backupset/2007_07_19/ncsnn0_tag20070719t01122
1_0.272.628305353 RECID=7 STAMP=628305353
Deleted 19 objects

RMAN>
4) List the backup archivelog files that could be used to recover to a point in time one
hour ago.
Note: You may need to adjust the following SYSDATE expression to see some results
that differ from the list command that does not use a SYSDATE qualifier at all. For
example, try ‘sysdate-30/60/24’ to indicate 30 minutes ago.
RMAN> list backup of archivelog until time 'sysdate-1/24';

Oracle Database 11g: Administration Workshop II A - 67


Computer Pride Limited

List of Backup Sets


===================

BS Key Size Device Type Elapsed Time Completion Time


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

------- ---------- ----------- ------------ ------------------


-
312 784.83M DISK 00:03:52 2007-07-
19:01:12:10
BP Key: 316 Status: AVAILABLE Compressed: NO Tag:
TAG20070719T010814
Piece Name:
+FRA/orcl/backupset/2007_07_19/annnf0_tag20070719t010814_0.270
.628304905

List of Archived Logs in backup set 312


ble
Thrd Seq
Time
Low SCN Low Time Next SCN Next
fe r a
---- ------- ---------- ------------------- ---------- -----
ans
----
n - t r
1 2 694583 2007-07-14:01:38:11
a no
706664 2007-
07-14:01:41:18
h a s718914ฺ
1 3 706664
)
2007-07-14:01:41:18
m u i de 2007-
07-14:02:24:49 o
1 4 718914 ilฺc ent G 729694
2007-07-14:02:24:49
a 2007-
07-16:23:23:17
@ gm Stud
1 5 729694
u k i2007-07-16:23:23:17
i s 744259 2007-
07-16:23:31:31
sy se t h
1 6
( M a
744259
u 2007-07-16:23:31:31 756123 2007-

1 y
7 u ki se to
07-16:23:38:05
756123 2007-07-16:23:38:05 764907 2007-
a s cen
li
07-16:23:41:05
yM
e 1 8 764907 2007-07-16:23:41:05 771262 2007-

Stanl 07-17:00:04:09
1 9 771262 2007-07-17:00:04:09 793102 2007-
07-17:03:44:16
1 10 793102 2007-07-17:03:44:16 821341 2007-
07-17:09:20:17
1 11 821341 2007-07-17:09:20:17 850076 2007-
07-17:15:41:20
1 12 850076 2007-07-17:15:41:20 879117 2007-
07-17:22:00:10
1 13 879117 2007-07-17:22:00:10 907242 2007-
07-18:00:23:00
1 14 907242 2007-07-18:00:23:00 934362 2007-
07-18:05:49:29
1 15 934362 2007-07-18:05:49:29 960808 2007-
07-18:11:06:36

RMAN>

Oracle Database 11g: Administration Workshop II A - 68


Computer Pride Limited

5) List the image copies of the single data file in the USERS tablespace.
a) Report on the schema to find out which data file number belongs to the USERS
tablespace.
RMAN> report schema;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Report of database schema for database with db_unique_name


ORCL

List of Permanent Datafiles


===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- -------------------
-----
1 700 SYSTEM YES
+DATA/orcl/datafile/system.256.627874229
2 617 SYSAUX NO
+DATA/orcl/datafile/sysaux.257.627874229
ble
3 90 UNDOTBS1 YES
fe r a
+DATA/orcl/datafile/undotbs1.258.627874231
ans
4 5 USERS NO
n - t r
+DATA/orcl/datafile/users.259.627874231
5 100 EXAMPLE NO a no
a s
+DATA/orcl/datafile/example.265.627874511
) h i d eฺ
m
co nt Gu
List of Temporary Files
i l ฺ
=======================
g ma Maxsize(MB)
t u de
File Size(MB) Tablespace
i @
k this S Tempfile Name

s y u
---- -------- -------------------- ----------- ---------------
-----
1 20 ( M
TEMPa u se 32767
k i t o
syu cense
+DATA/orcl/tempfile/temp.264.627874505
a li
l e yM
RMAN>
n
Sta Note that the file in question is data file number 4.
b) List any image copies of data file number 4.
RMAN> list copy of datafile 4;

List of Datafile Copies


=======================

Key File S Completion Time Ckp SCN Ckp Time


------- ---- - ------------------- ---------- -------------------
260 4 A 2007-07-18:22:30:24 1008905 2007-07-18:21:30:17
Name: /tmp/users_copy.dat

RMAN>
Note that, in this case, there is only one image copy of this file. You may not have
any at this point.

Oracle Database 11g: Administration Workshop II A - 69


Computer Pride Limited

6) Delete any data file 4 image copies that exist.


Note: You may not have any.
RMAN> delete copy of datafile 4;

released channel: ORA_DISK_1


allocated channel: ORA_DISK_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: SID=104 device type=DISK

RMAN> list copy of datafile 4;

RMAN>
7) To simplify things, disable control file autobackup.
RMAN> configure controlfile autobackup off;

old RMAN configuration parameters:


ble
CONFIGURE CONTROLFILE AUTOBACKUP ON;
fe r a
new RMAN configuration parameters:
an s
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
n - t r
no
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
s a
full resync complete
) h a eฺ
m i d
RMAN>
i l ฺ co nt Gu
ma tude
8) Make an image file backup of data file 4.
g
k i@ 4; i s S
u
RMAN> backup as copy datafile
sy se t h
Starting backup
a u
Mat 2007-07-19:06:06:38
(ORA_DISK_1
k i t o
a
channel yu ense starting datafile copy
using channel
sORA_DISK_1:
lic file number=00004
y M datafile
input
n l e
name=+DATA/orcl/datafile/users.259.627874231
Sta output file name=+FRA/orcl/datafile/users.267.628322805
tag=TAG20070719T060638 RECID=10 STAMP=628322805
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:01
Finished backup at 2007-07-19:06:06:46
RMAN>

9) Make another image copy of the data file, but make this one an archival backup.
RMAN> backup as copy datafile 4 keep forever;

Starting backup at 2007-07-19:06:09:38


current log archived

using channel ORA_DISK_1


backup will never be obsolete
archived logs required to recover from this backup will be
backed up

Oracle Database 11g: Administration Workshop II A - 70


Computer Pride Limited

channel ORA_DISK_1: starting datafile copy


input datafile file number=00004
name=+DATA/orcl/datafile/users.259.627874231
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN-00571:
===========================================================
RMAN-03002: failure of backup command at 07/19/2007 06:09:50
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with
keep attributes

RMAN>

Note that the backup command failed. This is because a backup with the KEEP
attribute (an archival backup) cannot be written to the Flash Recovery Area. Allowing
this has the potential of causing the Flash Recovery Area to quickly run out of space,
forcing you to specify a different location. ble
fe r a
ans
10) Reattempt the archival backup, this time providing a FORMAT specifier that causes
the backup to be written to the /tmp directory.
n - t r
a
RMAN> backup keep forever as copy datafile 4 format no
a s
'/tmp/bu_%d_%s_%p.dbf';
) h i d eฺ
m
co nt Gu
i l
Starting backup at 2007-07-19:06:11:04ฺ
current log archived
g ma tude
u k i@ is S
using channel ORA_DISK_1
a
backup will never be e th
syobsolete
i M to utos recover from this backup will
archived logs (required be
backed up uk
a
channel y ense starting datafile copy
sORA_DISK_1:
lic file number=00004
y M datafile
input
n l e
name=+DATA/orcl/datafile/users.259.627874231
Sta output file name=/tmp/bu_ORCL_32_1.dbf tag=TAG20070719T061104
RECID=11 STAMP=628323074
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:01

current log archived


using channel ORA_DISK_1
backup will never be obsolete
archived logs required to recover from this backup will be
backed up
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=31 RECID=30
STAMP=628323076
channel ORA_DISK_1: starting piece 1 at 2007-07-19:06:11:24
channel ORA_DISK_1: finished piece 1 at 2007-07-19:06:11:25

Oracle Database 11g: Administration Workshop II A - 71


Computer Pride Limited

piece handle=/tmp/bu_ORCL_33_1.dbf tag=TAG20070719T061104


comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01

using channel ORA_DISK_1


backup will never be obsolete
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

archived logs required to recover from this backup will be


backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2007-07-19:06:11:33
channel ORA_DISK_1: finished piece 1 at 2007-07-19:06:11:34
piece handle=/tmp/bu_ORCL_34_1.dbf tag=TAG20070719T061104
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
ble
using channel ORA_DISK_1 fe r a
backup will never be obsolete
ans
archived logs required to recover from this backup will be
n - t r
backed up
a no
s
channel ORA_DISK_1: starting full datafile backup set
a
) h d eฺ
channel ORA_DISK_1: specifying datafile(s) in backup set
i
m
co nt Gu
including current control file in backup set
i l ฺ
channel ORA_DISK_1: starting piece 1 at 2007-07-19:06:11:41
g ma tude
channel ORA_DISK_1: finished piece 1 at 2007-07-19:06:11:42

u k i@ is S
piece handle=/tmp/bu_ORCL_35_1.dbf tag=TAG20070719T061104
comment=NONE
a sy se th
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
k i (M to u
syu cense
Finished backup at 2007-07-19:06:11:42
a
yM li
n l e
RMAN>

Sta 11) See if there are any obsolete backups.


RMAN> report obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
no obsolete backups found

RMAN>

12) Create another (nonarchive) backup.


RMAN> backup as copy datafile 4;

Starting backup at 2007-07-19:06:14:12


using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy

Oracle Database 11g: Administration Workshop II A - 72


Computer Pride Limited

input datafile file number=00004


name=+DATA/orcl/datafile/users.259.627874231
output file name=+FRA/orcl/datafile/users.272.628323259
tag=TAG20070719T061412 RECID=12 STAMP=628323258
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:01
Finished backup at 2007-07-19:06:14:19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>

13) Report on the obsolete backups.


RMAN> report obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ ---------------
ble
-----
fe r a
Datafile Copy 1791 2007-07-19:06:06:45
ans
+FRA/orcl/datafile/users.267.628322805
n - t r
RMAN> a no
a s
Note that the first backup taken is now obsolete. ) h i d eฺ
m Gu > Manage
co tonAvailability
i l ฺ
14) For an alternate view of the backups, in EM, navigate
a the File t
Current Backups > Image Copies. Then m
g click
t u deType heading twice, to sort the
i@ is entries
listing in such a manner that the DATAFILE
k S are listed first.
u
sy se t h
a
(M to u
k i
a syu cense
yM li
l e
Stan
15) Fill in the username and password of oracle/oracle in the host credentials
section at the bottom of the page, and then at the upper-right corner of the page, click
Delete All Obsolete.
16) When the Specify Job Parameters page appears, click Show RMAN Script.

Oracle Database 11g: Administration Workshop II A - 73


Computer Pride Limited

Note that the script issues the DELETE NOPROMPT OBSOLETE command. Click
OK.
17) Click Submit Job.
18) After the job is submitted, click View Job.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

19) When the job status appears as Succeeded, navigate back to the backup listing page
for image copies (Database > Availability > Manage Current Backups > Image
Copies).
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i
a del ฺ
20) Click the File Type heading twice, g m
so that the S tu types are listed at the top.
k i @ i s DATAFILE
Note that there are now only u backups
ytwo
sthird thand
of data file 4. The obsolete one has been
a
deleted because it was the
M u e
ofsthree, the retention policy is set to 1, meaning
( to of any given file.
i two backups
there need onlykbe
y u s e
M as licen
y
nle
Sta

21) Return to the RMAN session, and take another backup of the data file in the same
way. This should not be an archival backup.
RMAN> backup as copy datafile 4;

Starting backup at 2007-07-19:06:47:32


using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004
name=+DATA/orcl/datafile/users.259.627874231
output file name=+FRA/orcl/datafile/users.267.628325261
tag=TAG20070719T064734 RECID=13 STAMP=628325260

Oracle Database 11g: Administration Workshop II A - 74


Computer Pride Limited

channel ORA_DISK_1: datafile copy complete, elapsed time:


00:00:01
Finished backup at 2007-07-19:06:47:41

RMAN>

22) Return to the Manage Current Backups page in EM. Click Go to refresh the list of
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

backups.

Note that there are three backups again. The oldest one is an archival backup.
23) Click Delete All Obsolete, and submit the job as you did in the preceding steps. ble
fe r a
24) After the job completes, navigate to the Manage Current Backups page again.
t r a ns
25) Note that there are now only two image copy backups. But the oldest one
o n -was
preserved this time because it is an archival backup.
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
y u
son this spage.
26) Click the Backup Sets M a
tab u e What archival backup sets appear there? Why
are they there?
(
ki se to
y u
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 75


Computer Pride Limited

Answer: These archival backup sets are here because they were taken as a byproduct
of taking the data file image copy as an archival backup. When the data file archival
backup was taken, control file autobackup was enabled, which causes the control file
and the SPFILE to be backed up. Also, any archive redo logs that are required to
recover the image copy are taken. Because the image copy was an archival backup,
every other file that is backed up as a part of that backup task is also an archival
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

backup.
27) Exit RMAN.
RMAN> exit

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 76


Computer Pride Limited

Practices for Lesson 6

Practice 6-1: Backing up the database


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you will back up the rcat database using cold and hot backup
techniques.

1) Create a directory (/home/oracle/BACKUP) to hold backup files.

[oracle@edu1r2p0-rcat ~]cd
[oracle@edu1r2p0-rcat ~] mkdir BACKUP
ble
fe r a
2) Make sure that your environment is pointing at the rcat database.
ans
n - t r
[oracle@edu1r2p0-rcat ~]. oraenv
ORACLE_SID= [orcl]? rcat a no
a s
) h
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
i d eฺ
/u01/app/oracle
m
co nt Gu
3) While the database is open, connect to them
i l ฺ
a asdesys or system and using V$
database
and data dictionary views, make a list@ g
of all the files
S u must be backed up for a whole
tthat
offline database backup.
i
uk this
s
a usey
Note: Copy the redo i (
logsMfor to of restore and recovery in NOARCHIVELOG mode.
ease
u k e
a sy cens~]sqlplus system/oracle
M li
[oracle@edu1r2p0-rcat
y
l e
StanSQL> spool /home/oracle/BACKUP/file_listing.txt
SQL> select name from v$controlfile;

NAME
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/control01.ctl
/u01/app/oracle/oradata/rcat/control02.ctl
/u01/app/oracle/oradata/rcat/control03.ctl

SQL> select member from v$logfile;

MEMBER
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/redo03.log
/u01/app/oracle/oradata/rcat/redo02.log
/u01/app/oracle/oradata/rcat/redo01.log

SQL> select name from v$datafile;

Oracle Database 11g: Administration Workshop II A - 77


Computer Pride Limited

NAME
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/system01.dbf
/u01/app/oracle/oradata/rcat/sysaux01.dbf
/u01/app/oracle/oradata/rcat/undotbs01.dbf
/u01/app/oracle/oradata/rcat/users01.dbf
/u01/app/oracle/oradata/rcat/example01.dbf
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

/u01/app/oracle/oradata/rcat/rcat01.dbf

6 rows selected.

SQL> spool off

4). Shut down the database with the IMMEDIATE option. Make a whole offline database
backup by copying all the data files into the $HOME/BACKUP directory using operating
system commands. This type of backup is suitable for both NOARCHIVELOG and
ARCHIVELOG databases.
ble
SQL> conn / as sysdba
fe r a
ans
SQL> shutdown immediate
n - t r
no
Database closed.
Database dismounted.
s a
ORACLE instance shut down.
) h a eฺ
SQL> exit
m i d
co nt Gu
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
i l ฺ
ma tude
With the Partitioning, Oracle Label Security, OLAP, Data Mining
g
u k i@ is S
and Real Application Testing options

[oracle@edu1r2p0-rcat ~]$
a s e th
ycp /u01/app/oracle/oradata/rcat/*
/home/oracle/BACKUP M
i ( t o us
s y uk nse
5). AlsoM a the spfile
copy l i c e into the $HOME/BACKUP directory.
n l ey
Sta [oracle@edu1r2p0-rcat ~]$ cp $ORACLE_HOME/dbs/spfilercat.ora
/home/oracle/BACKUP

[oracle@edu1r2p0-rcat ~]$ ls -alR BACKUP/

BACKUP/:
total 1883788
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:31 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:28 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf
-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo03.log
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Nov 12 17:30 system01.dbf

Oracle Database 11g: Administration Workshop II A - 78


Computer Pride Limited

-rw-r----- 1 oracle oinstall 20979712 Nov 12 17:30 temp01.dbf


-rw-r----- 1 oracle oinstall 209723392 Nov 12 17:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Nov 12 17:31 users01.dbf
-rw-r----- 1 oracle oinstall 2560 Nov 12 17.21 spfilercat.ora

6) Start the instance, and mount and open the database.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

[oracle@edu1r2p0-rcat ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Nov 12 17:31:58 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 238530560 bytes


Fixed Size 1299116 bytes ble
Variable Size 159386964 bytes
fe r a
Database Buffers 71303168 bytes
an s
Redo Buffers 6541312 bytes
n - t r
Database mounted.
Database opened.
a no
a s
h
7) Now make an open backup of the USERS tablespace. Copy
m i deฺto the
) the udatafile
o overwrite
ฺcnot
$HOME/BACKUP/ directory. Make sure that you ldo t G another copy.
a i n
m tude
SQL> alter tablespace users begin backup;
g
u k i@ is S
Tablespace altered.
a s y e th
( M to us
SQL> !cp /u01/app/oracle/oradata/rcat/users01.dbf
i
s y uk nse
/home/oracle/BACKUP/users01.bck

M a tablespace
SQL> alter
l i c e users end backup;
n l ey
Sta Tablespace altered.

8). Use the ALTER DATABASE command to back up the control file as a trace file.
SQL> alter database backup controlfile to trace as
'/home/oracle/BACKUP/trace_control.bck';

Database altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options

Oracle Database 11g: Administration Workshop II A - 79


Computer Pride Limited

Practice 6-2: Recovering from the loss of a datafile

This practice makes use of the rcat database. You will create a table in the USERS
tablespace and then simulate the loss of the datafile that belongs to this tablespace. When
you receive error messages stating that this file is missing, you will restore and recover it.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1) Switch log file a couple of times to simulate the passage of time since the backup was
taken.
[oracle@edu1r2p0-rcat ~]$ sqlplus system/oracle

SQL> alter system switch logfile;


System altered.
SQL> /
System altered
ble
fe r a
2) Create a sizable table in the USERS tablespace:
t r a ns
SQL> create table customers tablespace users as select * fromn-
sh.customers;
a no
a s
SQL>
) h i d eฺ
m
co nt Gu
i l ฺ
3) To simulate the passage of time, and to makeasure that ethis data is not cached in the
g m
buffer cache, perform the following steps and exitS u d
t SQL*Plus.
k i @ is from
SQL> alter system switch y u
s logfile; th
a
M to us e
System altered;
i (
y
SQL> alter system
s uk checkpoint;
n se
System M a
altered.lic e
y
le alter system flush buffer_cache;
tan
SQL>
S System altered
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options

4) Delete the datafile belonging to the USERS tablespace.


[oracle@edu1r2p0-rcat ~]$ cd /u01/app/oracle/oradata/rcat
[oracle@edu1r2p0-rcat ~]$ ls –al
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:31 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:28 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf

Oracle Database 11g: Administration Workshop II A - 80


Computer Pride Limited

-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf


-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo03.log
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Nov 12 17:30 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Nov 12 17:30 temp01.dbf
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

-rw-r----- 1 oracle oinstall 209723392 Nov 12 17:31 undotbs01.dbf


-rw-r----- 1 oracle oinstall 5251072 Nov 12 17:31 users01.dbf
-rw-r----- 1 oracle oinstall 2560 Nov 12 17.21 spfilercat.ora

[oracle@edu1r2p0-rcat ~]$ rm users01.dbf


[oracle@edu1r2p0-rcat ~]$ ls –al
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:31 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:28 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf
ble
-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf
fe r a
-rw-r-----
-rw-r-----
1
1
oracle
oracle
oinstall
oinstall
52429312
52429312
Nov
Nov
12
12
17:28
17:28
redo01.log
redo02.log
an s
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28
n -
redo03.logt r
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29
a no
sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Nov 12
s
17:30
a
system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Nov 12
) h 17:30
i eฺ
temp01.dbf
d
-rw-r----- 1 oracle oinstall 209723392 Nov
m
co nt Gu
12 17:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 2560
i
a del ฺNov 12 17.21 spfilercat.ora

maccess
5) Now log back in to the database and trygto u data in the system.customers
tthe
i @ S
table.
s y uk this
[oracle@edu1r2p0-rcat a
( M u se system/oracle
~]$ sqlplus

u ki 11.1.0.6.0
e to - Production on Thu Nov 13 10:34:31 2008
y
s cen
SQL*Plus: Release
a s
M
y (c) 1982,
Copyright li 2007, Oracle. All rights reserved.
l e
Stan
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options

SQL> select count(*) from system.customers;


select count(*) from system.customers
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/rcat/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
6) Knowing you are going to have to restore this file, you now take it offline, and exit
from SQL*Plus.
SQL> alter database datafile 4 offline;

Oracle Database 11g: Administration Workshop II A - 81


Computer Pride Limited

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

and Real Application Testing options

7) Now go into your $HOME/BACKUP directory to find what backups you have of the
users’ datafile. Then choose the most recent, and copy this file into where the live one
should be.
[oracle@edu1r2p0-rcat ]$ cd /home/oracle/BACKUP/

[oracle@edu1r2p0-rcat ]$ ls -al
total 1888936
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:38 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:49 ..
-rw-r--r-- 1 oracle oinstall 7011 Nov 12 17:38 cntrl.bck ble
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
fe r a
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
ans
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27
- t r
control03.ctl
n
-rw-r-----
-rw-r-----
1 oracle
1 oracle
oinstall
oinstall
104865792
15736832
Nov
Nov a no
12
12
17:28
17:28
example01.dbf
rcat01.dbf
a s
eฺ
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312) h Nov
i d
12 17:28 redo02.log
-rw-r----- 1 oracle oinstall m
co nt Gu
52429312 Nov 12 17:28 redo03.log
i l ฺ
ma tude
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
-rw-r----- 1 oracle
g
oinstall 734011392 Nov 12 17:30 system01.dbf
-rw-r----- 1 oracle
u k i@ is S
oinstall 20979712 Nov 12 17:30 temp01.dbf

sy se th
-rw-r----- 1 oracle oinstall 209723392 Nov 12 17:31 undotbs01.dbf
-rw-r-----
-rw-r-----
1 oracle
a
(M to u
1 oracle
oinstall
oinstall
5251072
5251072
Nov
Nov
12
12
17:34
17:31
users01.bck
users01.dbf
k i
s yu ensecp /home/oracle/BACKUP/users01.bck
[oracle@edu1r2p0-rcat]$
a
yM lic
/u01/app/oracle/oradata/rcat/users01.dbf
l e
[oracle@edu1r2p0-rcat]$

Stan
8) Now log in to SQL*Plus and try to bring the file online.
[oracle@edu1r2p0-rcat]$ sqlplus system/oracle

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Nov 13 10:34:31 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options

SQL> alter database datafile 4 online;


alter database datafile 4 online
*

Oracle Database 11g: Administration Workshop II A - 82


Computer Pride Limited

ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/u01/app/oracle/oradata/rcat/users01.dbf'

9) The datafile cannot be brought online as it is too old and, therefore, you need to
perform media recovery to roll it forward.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> recover datafile 4


ORA-00279: change 635864 generated at 11/12/2008 17:33:54 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/RCAT/archivelog/2008_11_12/o1_mf_1_
24_4kp52vx4_.arc
ORA-00280: change 635864 for thread 1 is in sequence #26

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

10) Because you want to completely recover this datafile, you enter AUTO.
ble
fe r a
ns
auto

t r
- fora
ORA-00279: change 644645 generated at 11/12/2008 17:42:32 needed
o n
an
thread 1
ORA-00289: suggestion :
s
ha ideฺ
/u01/app/oracle/flash_recovery_area/RCAT/archivelog/2008_11_12/o1_mf_1_
27_4kp5n9z0_.arc )
m G#27 u
ORA-00280: change 644645 for thread 1 is ฺin
l c o t
i sequence

g ma tuden
ORA-00279: change 647988 generatedk S
i@ atis11/12/2008 17:46:49 needed for
y u t h
:s
thread 1
ORA-00289: suggestion a
( M u se
y u
28_4kp5z248_.arc ki se to
/u01/app/oracle/flash_recovery_area/RCAT/archivelog/2008_11_12/o1_mf_1_

ORA-00280:
M aschange
l i c n for thread 1 is in sequence #28
e647988
n l
Logeyapplied.
Sta Media recovery complete.
11) Now try to bring the datafile online.
SQL> alter database datafile 4 online;

Database altered.

12) Try again to access the system.customers table, and then exit SQL*Plus.
SQL> select count(*) from system.customers;

COUNT(*)
----------
55500

Oracle Database 11g: Administration Workshop II A - 83


Computer Pride Limited

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 84


Computer Pride Limited

Practice 6-3 Recovering from the loss of all controlfiles

This practice makes use of the rcat database. You will simulate the loss of all
controlfiles, and then restore the controlfiles and recover the database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1) Delete the controlfiles.


[oracle@edu1r2p0-rcat ]$ cd /u01/app/oracle/oradata/rcat
[oracle@edu1r2p0-rcat ]$ ls
control01.ctl example01.dbf redo02.log system01.dbf users01.dbf
control02.ctl rcat01.dbf redo03.log temp01.dbf
control03.ctl redo01.log sysaux01.dbf undotbs01.dbf
[oracle@edu1r2p0-rcat ]$ rm control0*
[oracle@edu1r2p0-rcat ]$ ls
example01.dbf redo01.log redo03.log system01.dbf undotbs01.dbf
rcat01.dbf redo02.log sysaux01.dbf temp01.dbf users01.dbf
ble
fe r a
2) Log in to the database and see some of the symptoms caused by the missing an s
controlfiles: n - t r
a no
[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba
a s
h
) Nov 13i d eฺ
SQL*Plus: Release 11.1.0.6.0 - Production on Thu
c m
o t Gu 12:31:03 2008

Copyright (c) 1982, 2007, Oracle. Allarights ei l ฺ n


g m tud reserved.
Connected to:
k i@ i s S
Oracle Database 11g Enterpriseu
sy sLabel h
t Security, OLAP,
Edition Release 11.1.0.6.0 - Production
With the Partitioning,aOracle
M u e Data Mining
and Real Application (
ki se to Testing options
y u
as * from
SQL> select
select M l i c n
ev$datafile;
ey
* from v$datafile
n l *
Sta ERROR at line 1:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/rcat/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> select * from v$controlfile;

STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS


------- ------------------------------ --- ---------- --------------
/u01/app/oracle/oradata/rcat/c NO 16384 610
ontrol01.ctl

/u01/app/oracle/oradata/rcat/c NO 16384 610


ontrol02.ctl

/u01/app/oracle/oradata/rcat/c NO 16384 610


ontrol03.ctl

Oracle Database 11g: Administration Workshop II A - 85


Computer Pride Limited

3) The information from v$controlfile can be used to determine the physical status
of the control files at the operating system level, but because you have deleted them, you
can start to restore them without any further investigation.
First, the database must be shut down. Try a “shutdown immediate” first, but this will fail
because checkpoint information must be written to the control files. Then try a “shutdown
abort.” Exit SQL*Plus.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> shutdown immediate


ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/rcat/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.

4) Now try to start the instance and open the database. The database will fail to mount
ble
with errors pointing at control file problems. Exit SQL*Plus.
fe r a
ans
SQL> startup mount
ORACLE instance started. n - t r
n o
Total System Global Area 238530560 bytes s a
Fixed Size 1299116 bytes
) h a eฺ
m i d
co nt Gu
Variable Size 159386964 bytes
Database Buffers
i
71303168 bytesl ฺ
Redo Buffers
ma file,
6541312 bytes
g t u decheck alert log for more
i@ is S
ORA-00205: error in identifying control
info
u k
a sy se th
SQL> exit
k i (M to u
a
u Oracle
Disconnectedyfrom
s- Production
e n se Database 11g Enterprise Edition Release
11.1.0.6.0
Withythe lic
M Partitioning,
l e Oracle Label Security, OLAP, Data Mining

tan
and Real Application Testing options
S
5) Now find backups of the controlfile and copy them back into their correct locations.
[oracle@edu1r2p0-rcat]$ cd /home/oracle/BACKUP
[oracle@edu1r2p0-rcat]$ ls -al
total 1888936
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:38 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 13 12:30 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf
-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo03.log
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf

Oracle Database 11g: Administration Workshop II A - 86


Computer Pride Limited

-rw-r----- 1 oracle oinstall 734011392 Nov 12 17:30 system01.dbf


-rw-r----- 1 oracle oinstall 20979712 Nov 12 17:30 temp01.dbf
-rw-r----- 1 oracle oinstall 209723392 Nov 12 17:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Nov 12 17:34 users01.bck
-rw-r----- 1 oracle oinstall 5251072 Nov 12 17:31 users01.dbf

[oracle@edu1r2p0-rcat ]$ cp control01.ctl /u01/app/oracle/oradata/rcat/


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

[oracle@edu1r2p0-rcat ]$ cp control02.ctl /u01/app/oracle/oradata/rcat/


[oracle@edu1r2p0-rcat ]$ cp control03.ctl /u01/app/oracle/oradata/rcat/

6) Now log in using SQL*Plus, and try to mount the database again. It should work this
time because the controlfiles have been restored.
[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Nov 13 12:37:40 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.


ble
fe r a
Connected to:
ans
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
n - t r
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options a no
a s
SQL> alter database mount; ) h i d eฺ
m
co nt Gu
i l ฺ
ma tude
Database altered.
g S
u k
7) Because the controlfiles have been i@
restored,i s
the database must be recovered. When
y auto.
sreply e t h
a
prompted for the next log file,
(M using u s
k i t o
yu e1213429 se generated at 11/13/2008 03:24:55 needed for
SQL> recover database backup controlfile;

a schange n
lic
ORA-00279:
thread
l e yM1

tan/u01/app/oracle/flash_recovery_area/rcat/arhivelog/2008_11_13/o1_mf_1_3
ORA-00289: suggestion :
S 3_4kr5w6b6_.arc
ORA-00280: change 1213429 for thread 1 is in sequence #33

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


auto
.
.
.
.
ORA-00279: change 1213899 generated at 11/13/2008 12:05:03 needed for
thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/rcat/arhivelog/2008_11_13/o1_mf_1_3
5_4kr60897_.arc
ORA-00280: change 1213899 for thread 1 is in sequence #35
ORA-00278: log file
'/u01/app/oracle/flash_recovery_area/rcat/arhivelog/2008_11_13/o1_mf_1_
34_4kr5zh7s_.arc' no longer needed for this recovery

Oracle Database 11g: Administration Workshop II A - 87


Computer Pride Limited

ORA-00279: change 1213915 generated at 11/13/2008 12:05:28 needed for


thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/rcat/archivelog/2008_11_13/o1_mf_1_
36_%u_.arc
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ORA-00280: change 1213915 for thread 1 is in sequence #36


ORA-00278: log file
'/u01/app/oracle/flash_recovery_area/rcat/archivelog/2008_11_13/o1_mf_1
_35_4kr60897_.arc' no longer needed for this recovery

ORA-00308: cannot open archived log


'/u01/app/oracle/flash_recovery_area/rcat/archivelog/2008_11_13/o1_mf_1
_36_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

ble
r a
this is sequence number 36. This is probably because sequence number 36 is onera
sfe
8) The recovery failed as it cannot find the next archived redo log. In the example above,
ofnthe
online redo logs.
o n -t
We need to determine which online redo logs have not been archived, a andn what their
s
haas thisidview
sequence numbers are. This is what v$log usually shows,)but eฺ will get its
m uthe information in the
co restored,
information from the controlfile, and these have just been G
view will not be up to date. i
a denl ฺ t
g m tu
SQL> select * from v$log;
i @ S
s y uk thisBYTES MEMBERS ARC STATUS
GROUP# THREAD# SEQUENCE#
---------- ----------
( M u se---------- ---------- --- ------------
a----------
----
y u ki se to
M as ---------
FIRST_CHANGE#
-------------
l i c en
FIRST_TIM

n l ey 1175121
1 1 31 52428800 1 NO CURRENT

Sta 13-NOV-08

3 1 30 52428800 1 YES INACTIVE


1142979 12-NOV-08

2 1 29 52428800 1 YES INACTIVE


1109701 12-NOV-08

SQL> exit

The sequence numbers shown above are earlier sequences than the 36 needed to continue
the recovery in this example.
9) The alert log contains entries for every log file switch. So, as long as this has not been
damaged, it can be searched for a reference to the missing log, which in our example is
sequence 36.
[oracle@edu1r2p0-rcat]$ cd /u01/app/oracle/diag/rdbms/rcat/rcat/trace
[oracle@edu1r2p0-rcat]$ more alert_rcat.log

Oracle Database 11g: Administration Workshop II A - 88


Computer Pride Limited

Wed Nov 12 15:52:53 2008


Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Shared memory segment for instance monitoring created
.
.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

.
.
Current log# 2 seq# 35 mem# 0: /u01/app/oracle/oradata/rcat/redo02.log
Wed Nov 12 19:09:45 2008
Thread 1 advanced to log sequence 36
Current log# 3 seq# 36 mem# 0:
/u01/app/oracle/oradata/rcat/redo03.log
.
.
.
10) It is now known that sequence 36 is contained within Log Group 3. So, the recover
command can be restarted and /u01/app/oracle/oradata/rcat/redo03.log can be
entered as the name of the next log file to use for recovery. ble
fe r a
ans
[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba
n - t r
SQL> recover database using backup controlfile;
n o
s a
ORA-00279: change 1213915 generated at 11/13/2008 12:05:28 needed for
thread 1
) h a eฺ
m i d
ORA-00289: suggestion :
l ฺ c o t Gu
i
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2008_11_13/o1_mf_1_
en #36
36_%u_.arc
g
ORA-00280: change 1213915 for threadm1ais tinudsequence
u k i@ is S
a th | AUTO | CANCEL}
sy s| efilename
(M to u
Specify log: {<RET>=suggested
k i
syu cense
/u01/app/oracle/oradata/rcat/redo03.log
a
Log y M
applied. li
l e
tan
Media recovery complete.
S
11) Now, try to open the database.
SQL> alter database open;
Alter database open
*
ERROR at line 1:
ORA-01589:must use RESETLOGS or NORESTLOGS option for database open
12) Because we have restored the controlfiles, we need to open with the resetlogs
keyword.
SQL> alter database open resetlogs;
Database altered.

Oracle Database 11g: Administration Workshop II A - 89


Computer Pride Limited

13) Finally, back up the controlfile.


SQL> alter database backup controlfile to
'/home/oracle/BACKUP/control.bck';
Database altered.
SQL> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 90


Computer Pride Limited

Practice 6-4: Recovering from the loss of a redo log group


This practice makes use of the rcat database. You will delete the current redo log files,
and see the effect this has on the database.
1) Log in to the database using SQL*Plus, and run the following query to gather
information about your redo logs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba

SQL> set linesize 120


SQL> col member for a40
SQL> select l.group#, l.sequence#, l.archived,
2 l.status, f.member
3 from v$log l, v$logfile f
4 where l.group#=f.group#;

GROUP# SEQUENCE# ARC STATUS MEMBER


-------- ---------- --- ------- --------------------------------------
3 3 NO CURRENT
ble
/u01/app/oracle/oradata/rcat/redo03.log
fe r a
2 2 YES INACTIVE
ans
/u01/app/oracle/oradata/rcat/redo02.log
1 1 YES INACTIVE n - t r
/u01/app/oracle/oradata/rcat/redo01.log
a no
a s
) h i d eฺ
m
o 3 ist the
cGroup G ucurrent log group. It
2) From this it can be seen in our example that Logi l ฺ
ma have
can also be seen that none of the redo log groups
g u d enmultiplexed. Your current
been
Redo Log Group may be different from
k i St
@the oneisshown.
Determine the current Redo Log
a syuGroupseforthyour database, and then delete its member file
k i (M to u
from the operating system.

syu cense
SQL> ! rm /u01/app/oracle/oradata/rcat/redo03.log
a
yM li
l e
Stan3) Now issue the alter system switch logfile command thrice. The third
command should hang.
SQL> alter system switch logfile;
SQL> /
SQL> /

4) In another Xterm window, look at the alert log to see what errors are being reported.
[oracle@edu1r2p0-rcat]$ cd /u01/app/oracle/diag/rdbms/rcat/rcat/trace
[oracle@edu1r2p0-rcat]$ more alert_rcat.log
.<below is an extract from the output>
.
.
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312:online log 3 thread 1:
'/u01/app/oracle/oradata/rcat/redo03.log'
ORA-27037: unable to obtain file status

Oracle Database 11g: Administration Workshop II A - 91


Computer Pride Limited

Linux Error: 2: No such file or directory


Additional information: 3
2008-11-13 15:42:16.669000 +00:00
Thread 1 cannot allocate new log, sequence 6
Checkpoint not complete
Current log# 2 seq# 5 mem# 0: /u01/app/oracle/oradata/rcat/redo02.log
2008-11-13 15:42:17.850000 +00:00
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ORACLE Instance rcat - Can not allocate log, archival required


Thread 1 cannot allocate new log, sequence 6
All online logs needed archiving
Current log# 2 seq# 5 mem# 0: /u01/app/oracle/oradata/rcat/redo02.log
2008-11-13 15:42:23.530000 +00:00
Errors in file
/u01/app/oracle/diag/rdbms/rcat/rcat/trace/rcat_arc0_19359.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1:
'/u01/app/oracle/oradata/rcat/redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory

ble
fe r a
5) The messages report that you cannot allocate a log, as archival is required. There are
ans
also various messages saying that log group 3 cannot be opened.
n - t r
no
This is because the logfile has been deleted, and therefore cannot be archived. Because
a
a s
the log file has not been archived, lgwr is not allowed to overwrite it, even if the file no
longer exists. ) h i d eฺ
m u
o ttheGmissing
cre-create
i l
a den
If you clear the missing log file group, then this willฺ logfile.
[oracle@edu1r2p0-rcat]$ sqlplus / g m tu
i @ is 3S
as sysdba

s y uk tgroup h
se 3
SQL> alter database clear logfile
( M
alter database clear logfilea ugroup
*
y u ki se to
aslog l3icofeninstance rcat (thread 1) needs to be archived
ERROR at line 1:
M
ORA-00350:
y
l e
ORA-00312: online log 3 thread 1:

Stan
'/u01/app/oracle/oradata/rcat/redo03.log'

6) Because the logfile group has not been archived, you must use the keyword
“unarchived” in the command. Then exit SQL*Plus.
SQL> alter database clear unarchived logfile group 3;

Database altered.

SQL> exit

7) If you now look at your original Xterm window, in which you issued the alter
system switch logfile command that hung, you should now find that the session
is no longer hanging.

Oracle Database 11g: Administration Workshop II A - 92


Computer Pride Limited

Now examine the alert log again in your second Xterm window. You will see that the
“alter database clear unarchived logfile group” command has been recorded in the
alert.log, and that warning messages have been issued because of the use of this
command.
[oracle@edu1r2p0-rcat]$ more alert_rcat.log
.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2008-11-13 15:44:50.448000 +00:00


alter database clear unarchived logfile group 3
WARNING! CLEARING REDO LOG WHICH HAS NOT BEEN ARCHIVED. BACKUPS TAKEN
BEFORE 11/13/2008 15:41:58 (CHANGE 1967996) CANNOT BE USED FOR
RECOVERY.
Clearing online log 3 of thread 1 sequence number 3
Errors in file
/u01/app/oracle/diag/rdbms/rcat/rcat/trace/rcat_ora_21524.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1:
'/u01/app/oracle/oradata/rcat/redo03.log'
ble
ORA-27037: unable to obtain file status
fe r a
Linux Error: 2: No such file or directory
ans
Additional information: 3
n - t r
no
2008-11-13 15:44:52.294000 +00:00
Completed: alter database clear unarchived logfile group 3
s a
.
) h a eฺ
.
m i d
i l ฺ co nt Gu
a dfrom
mrecovered e this point in time.
g
8) Now back up the database, so that it can be t u
S the database for a cold backup.
u k i@and shuti s
Return to your original Xterm window,
sy se t h down
SQL> shutdown immediate a
(M to u
Database closed. k i
u nse
s y
Database dismounted.
a
M lice down.
ORACLE instance shut
SQL>yexit
le
StanDisconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options

[oracle@edu1r2p0-rcat ~]$ cp /u01/app/oracle/oradata/rcat/*


/home/oracle/BACKUP

9) When the backup has completed, start the instance and open the database.
[oracle@edu1r2p0-rcat ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Nov 12 17:31:58 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup

Oracle Database 11g: Administration Workshop II A - 93


Computer Pride Limited

ORACLE instance started.

Total System Global Area 238530560 bytes


Fixed Size 1299116 bytes
Variable Size 159386964 bytes
Database Buffers 71303168 bytes
Redo Buffers 6541312 bytes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Database mounted.
Database opened.
SQL> exit

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 94


Computer Pride Limited

Practices for Lesson 7

Practice 7-1: Recovering Image Copies


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you recover an image copy of a file to the current SCN, to allow faster
recovery time later. You create a new tablespace called APPRAISAL, which has one
table in it. After creating initially, with a small amount of data, you take an incremental
backup of it. Then you perform more DML on it, adding many more rows. Then you take
another incremental backup. At that point, you have an image copy of the APPRAISAL
tablespace and also an incremental backup of it. Because you need to recover the
tablespace later, you recover the image copy so that it is as up-to-date as the last
incremental backup. This is done without going to the expense of creating a new image
copy.
bl e
1) Make sure you are at the ~/labs directory and your environment points to the orcl ra
instance. n s fe
n - tra
$ cd ~/labs
$ . oraenv a no
a s
ORACLE_SID = [orcl] ? orcl
) h i d eฺ
The Oracle base for
c m
o t Gu is
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
i l ฺ
/u01/app/oracle
$ g ma tuden
u k i@ is S
a s y
2) Run the create_appraisal_ts.sh
e th script to create a new tablespace called
APPRAISAL.
i ( M to us
s y uk nse
$ ./create_appraisal_ts.sh
M a lcreated.
Tablespace
i c e
y created.
nle$
Table

Sta 3) Make a level 1 backup of the tablespace, to be used for image copy recovery. If no
level 1 exists yet, it will actually create a level 0 incremental backup. This takes
several minutes.
$ rman target / catalog rcatowner/oracle@rcat
RMAN> backup incremental level 1 for recover of copy with tag
'app_incr' database;

Starting backup at 2007-10-05:23:02:59


new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=112 device type=DISK
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 2 found

Oracle Database 11g: Administration Workshop II A - 95


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 5 found
no parent backup or copy of datafile 6 found
no parent backup or copy of datafile 7 found
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

input datafile file number=00001


name=+DATA/asmtesting/datafile/testing.257.635151709
output file name=+FRA/orcl/datafile/system.290.635209395
tag=APP_INCR RECID=18 STAMP=635209733
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:05:47
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002
name=+DATA/orcl/datafile/sysaux.259.635127417
output file name=+FRA/orcl/datafile/sysaux.291.635209755
tag=APP_INCR RECID=19 STAMP=635210005
ble
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:04:18 fe r a
channel ORA_DISK_1: starting datafile copy ans
input datafile file number=00003 n - t r
no
name=+DATA/orcl/datafile/undotbs1.258.635127417output file
a
s
name=+FRA/orcl/datafile/undotbs1.292.635210025 tag=APP_INCR
a
RECID=20 STAMP=635210104 ) h i d eฺ
m
co nt Gu
channel ORA_DISK_1: datafile copy complete, elapsed time:
i l ฺ
ma tude
00:01:25
g
channel ORA_DISK_1: starting datafile copy

u k i@ is S
input datafile file number=00005

a sy se th
name=+DATA/orcl/datafile/example.260.635127419
output file name=+FRA/orcl/datafile/example.293.635210123
k i (M to u
tag=APP_INCR RECID=21 STAMP=635210156
syu cense
channel ORA_DISK_1: datafile copy complete, elapsed time:
a
yM
00:00:45
li
nle channel ORA_DISK_1: starting datafile copy

Sta
input datafile file number=00006
name=+DATA/orcl/datafile/tbsjmw.263.635148067
output file name=+FRA/orcl/datafile/tbsjmw.294.635210175
tag=APP_INCR RECID=22 STAMP=635210188
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007
name=+DATA/orcl/datafile/appraisal.256.635209311
output file name=+FRA/orcl/datafile/appraisal.295.635210207
tag=APP_INCR RECID=23 STAMP=635210211
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004
name=+DATA/orcl/datafile/users.262.635127891
output file name=+FRA/orcl/datafile/users.296.635210221
tag=APP_INCR RECID=24 STAMP=635210221

Oracle Database 11g: Administration Workshop II A - 96


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:03
Finished backup at 2007-10-05:23:17:03

Starting Control File and SPFILE Autobackup at 2007-10-


05:23:17:04
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

piece
handle=+FRA/orcl/autobackup/2007_10_05/s_635210233.297.6352102
37 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-10-
05:23:17:23

RMAN>

4) In a separate terminal window, perform some DML on the table in the APPRAISAL
tablespace. Use the emp_inserts.sh script.
$ ./emp_inserts.sh
ble
fe r a
107 rows created.
ans
.
n - t r
.
a no
.
a s
) h
5) List the copy of the APPRAISAL tablespace to see its SCN. i d eฺ
m
co nt Gu
i l ฺ
ma tude
RMAN> list copy of tablespace appraisal;

List of Datafile Copies i@


g S
u k h i s
=======================
a sy se t
File iS(M t o u Time
Key
u k Completion
s e
Ckp SCN Ckp Time
sy - n-------------------
------- ----
630 a 7 icAe 2007-10-05:23:16:51 822339
-------- ------------------

y M l 2007-10-

nle
05:23:16:45

Sta
Name: +FRA/orcl/datafile/appraisal.295.635210207
Tag: APP_INCR

RMAN>
6) Run the script to perform more transactions on the table that resides in the
APPRAISAL tablespace.
$ ./emp_inserts.sh

428 rows created.

Commit complete.

856 rows created.

Commit complete.
$

Oracle Database 11g: Administration Workshop II A - 97


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


7) Perform another level 1 backup. This one will indeed be a level 1 because you already
have a level 0.
RMAN> backup incremental level 1 for recover of copy with tag
'app_incr' database;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Starting backup at 2007-10-05:23:37:02


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=109 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile
backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001
name=+DATA/asmtesting/datafile/testing.257.635151709
input datafile file number=00002
name=+DATA/orcl/datafile/sysaux.259.635127417
input datafile file number=00003
name=+DATA/orcl/datafile/undotbs1.258.635127417input datafile ble
file number=00005
fe r a
name=+DATA/orcl/datafile/example.260.635127419
ans
input datafile file number=00006
n - t r
name=+DATA/orcl/datafile/tbsjmw.263.635148067
a no
input datafile file number=00007
a s
) h
name=+DATA/orcl/datafile/appraisal.256.635209311
i d eฺ
input datafile file number=00004 m
co nt Gu
i l ฺ
name=+DATA/orcl/datafile/users.262.635127891
ma tude
channel ORA_DISK_1: starting piece 1 at 2007-10-05:23:37:11
g
u k i@ is S
channel ORA_DISK_1: finished piece 1 at 2007-10-05:23:37:36

sy se th
piece
a
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t23370
(M to u
i
2_0.298.635211431 tag=TAG20071005T233702 comment=NONE
k
a syu cense
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:25
yM li
Finished backup at 2007-10-05:23:37:36
nle
Sta Starting Control File and SPFILE Autobackup at 2007-10-
05:23:37:36
piece
handle=+FRA/orcl/autobackup/2007_10_05/s_635211458.299.6352114
67 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-10-
05:23:37:53

RMAN>

8) List and note the SCN of the APPRAISAL tablespace incremental backup (not the
image copy).
RMAN> list backup of tablespace appraisal;

List of Backup Sets


===================

Oracle Database 11g: Administration Workshop II A - 98


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


BS Key Type LV Size Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- ------------ ----------
---------
676 Incr 1 12.72M DISK 00:00:24 2007-10-
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

05:23:37:27
BP Key: 679 Status: AVAILABLE Compressed: NO Tag:
TAG20071005T233702 Piece Name:
+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t233702_0.298
.635211431
List of Datafiles in backup set 676
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
7 1 Incr 824887 2007-10-05:23:37:11
+DATA/orcl/datafile/appraisal.256.635209311

ble
RMAN>
fe r a
9) Use the incremental backup to recover the APPRAISAL tablespace image copy.
ans
n - t r
RMAN> recover copy of tablespace appraisal with tag
'app_incr'; a no
a s
Starting recover at 2007-10-05:23:52:00 )
h i d eฺ
c m
o t Gu
allocated channel: ORA_DISK_1
i l ฺ
ma type=DISK
channel ORA_DISK_1: SID=170 device
channel ORA_DISK_1: startinggincremental u d endatafile backup set
k i @ is St
restore
channel ORA_DISK_1:sy u th datafile copies to recover
M a e
specifying
usfile number=00007
i (
recovering datafile copy
t o
y uk nse reading from backup.635210207
name=+FRA/orcl/datafile/appraisal.295
channelsORA_DISK_1:
M a lice
+FRA/orcl/backupset/2007_10_05/nnn
piece
y
nledn1_tag20071005t233702_0.298.635211431
Sta channel ORA_DISK_1: piece
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag200710
05t233702_0.298.635211431 tag=TAG20071005T233702
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2007-10-05:23:52:03
.
.
.
RMAN>

10) List the SCN for the APPRAISAL tablespace image copy. What is it now?
RMAN> list copy of tablespace appraisal;

List of Datafile Copies


=======================

Oracle Database 11g: Administration Workshop II A - 99


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- ----------------
732 7 A 2007-10-05:23:52:02 824887 2007-10-
05:23:37:11
Name: +FRA/orcl/datafile/appraisal.295.635210207
Tag: APP_INCR
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>
Note that it is now equal to the SCN of the last incremental backup.
11) Recover all the data file image copies in the database based on the most recent
incremental backup.
RMAN> recover copy of database with tag 'app_incr';

Starting recover at 2007-10-06:00:00:17


ble
allocated channel: ORA_DISK_1
fe r a
channel ORA_DISK_1: SID=112 device type=DISK
ans
no copy of datafile 7 found to recover
channel ORA_DISK_1: starting incremental datafile backup set n - t r
restore
a no
a s
channel ORA_DISK_1: specifying datafile copies to recover
)
recovering datafile copy file number=00001h i d eฺ
m
co nt Gu
name=+FRA/orcl/datafile/system.290.635209395
i l ฺ
ma tude
recovering datafile copy file number=00002
g
name=+FRA/orcl/datafile/sysaux.291.635209755
k i@ is S
recovering datafile copy file number=00003
u
sy se th
name=+FRA/orcl/datafile/undotbs1.292.635210025
a
(M to u
recovering datafile copy file number=00004
k i
name=+FRA/orcl/datafile/users.296.635210221
syu cense
recovering datafile copy file number=00005
a
yM li
name=+FRA/orcl/datafile/example.293.635210123

nle recovering datafile copy file number=00006

Sta
name=+FRA/orcl/datafile/tbsjmw.294.635210175
channel ORA_DISK_1: reading from backup piece
+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t233702_0.298
.635211431
channel ORA_DISK_1: piece
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t23370
2_0.298.635211431 tag=TAG20071005T233702
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
Finished recover at 2007-10-06:00:00:54
.
.
.
RMAN>
12) View the SCNs of all the image copies now. They should all be, at the most, equal to
the latest incremental backup.

Oracle Database 11g: Administration Workshop II A - 100


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


RMAN> list copy;

List of Datafile Copies


=======================

Key File S Completion Time Ckp SCN Ckp Time


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

------- ---- - ------------------- ---------- ----------------


---
800 1 A 2007-10-06:00:00:39 824887 2007-10-
05:23:37:11
Name: +FRA/orcl/datafile/system.290.635209395
Tag: APP_INCR

802 2 A 2007-10-06:00:00:46 824887 2007-10-


05:23:37:11
Name: +FRA/orcl/datafile/sysaux.291.635209755
Tag: APP_INCR
ble
fe r a
801 3 A 2007-10-06:00:00:40 824887 2007-10-
ans
05:23:37:11
Name: +FRA/orcl/datafile/undotbs1.292.635210025 n - t r
Tag: APP_INCR
a no
a s
799 4 A 2007-10-06:00:00:34 824887 ) h i d eฺ
2007-10-
05:23:37:11 m
co nt Gu
i l ฺ
ma tude
Name: +FRA/orcl/datafile/users.296.635210221
Tag: APP_INCR g
u k i@ is S
506 4
sy se th 799678
A 2007-10-05:05:18:05
a
2007-10-
05:05:18:03
i M to u
(+FRA/orcl/datafile/users.279.635145483
k
Name:
se
yu TAG20071005T051803
a sTag: e n
l e y M 4 licA 2007-10-05:04:53:32 797391
414 2007-10-
n 05:04:53:31
Sta Keep: BACKUP_LOGS Until: FOREVER
Name: /tmp/bu_ORCL_24_1.dbf
Tag: TAG20071005T045326

797 5 A 2007-10-06:00:00:32 824887 2007-10-


05:23:37:11
Name: +FRA/orcl/datafile/example.293.635210123
Tag: APP_INCR

798 6 A 2007-10-06:00:00:33 824887 2007-10-


05:23:37:11
Name: +FRA/orcl/datafile/tbsjmw.294.635210175
Tag: APP_INCR

732 7 A 2007-10-05:23:52:02 824887 2007-10-


05:23:37:11
Name: +FRA/orcl/datafile/appraisal.295.635210207

Oracle Database 11g: Administration Workshop II A - 101


Computer Pride Limited

Practice 7-1: Recovering Image Copies (continued)


Tag: APP_INCR
.
.
.
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 102


Computer Pride Limited

Practice 7-2: Performing Fast Recovery


In this practice/task, you take advantage of the Flash Recovery Area to perform a fast
recovery of a data file.
Note: The data file numbers in your database may differ from what is shown here.
1) Use the RMAN session from the previous practice and take the APPRAISAL data file
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

offline.
RMAN> sql "alter tablespace appraisal offline";

sql statement: alter tablespace appraisal offline


starting full resync of recovery catalog
full resync complete

RMAN>

2) Use the SWITCH command to replace the data file from the flash recovery area.
ble
a) Determine the name of the data file that is currently associated with the
fe r a
APPRAISAL tablespace.
ans
n - t r
RMAN> report schema;
a no
s
Report of database schema for database with adb_unique_name
) h i d eฺ
ORCL
c m
o t Gu
List of Permanent Datafiles i l
a denฺ
=========================== gm tu segs Datafile Name
i @ S
File Size(MB) Tablespace
s y uk this ------- -------------------
RB

-----
( M a use
---- -------- --------------------

1 700
u ki SYSTEMe to YES
y
as liceSYSAUXn s
+DATA/asmtesting/datafile/testing.258.634268145
2 M679 NO
l e y
n +DATA/orcl/datafile/sysaux.259.634164339
Sta 3 200 UNDOTBS1 YES
+DATA/orcl/datafile/undotbs1.260.634164355
4 5 USERS NO
+DATA/orcl/datafile/users.263.634165219
5 100 EXAMPLE NO
+DATA/orcl/datafile/example.261.634164377
6 50 TBSJMW NO
+DATA/orcl/datafile/tbsjmw.269.634202579
7 25 APPRAISAL NO
+DATA/orcl/datafile/appraisal.256.634276429
.
.
.
RMAN>

Oracle Database 11g: Administration Workshop II A - 103


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


Note that there is only one data file for the tablespace. In this case, it is data file
number 7. You can use that data file number, instead of the tablespace name, in the
upcoming set of commands.
b) Confirm that you have an image copy for data file 7 that you can switch to.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> list copy of datafile 7;

List of Datafile Copies


=======================

Key File S Completion Time Ckp SCN Ckp Time


------- ---- - ------------------- ---------- ----------------
---
832 7 A 2007-09-26:04:19:58 1287901 2007-09-
26:04:18:13
Name: +FRA/orcl/datafile/appraisal.295.634277277
Tag: APP_INCR
ble
fe r a
RMAN>
ans
c) Switch to that copy of the image file. n - t r
n o
RMAN> switch datafile 7 to copy; s a
) h a eฺ
datafile 7 switched to datafile copy om i d
i l ฺ c nt Gu
"+FRA/orcl/datafile/appraisal.295.634277277"
starting full resync of recovery
g ma catalog
t u de
full resync complete
u k i@ is S
RMAN> a sy se th
k i (M7. to u
a s yu ense
d) Recover data file
M recover
RMAN>
y lic datafile 7;
nle
Sta Starting recover at 2007-09-26:04:40:37
using channel ORA_DISK_1

starting media recovery


media recovery complete, elapsed time: 00:00:01

Finished recover at 2007-09-26:04:40:38

RMAN>

3) Bring the APPRAISAL tablespace back online.


RMAN> sql "alter tablespace appraisal online";

sql statement: alter tablespace appraisal online


starting full resync of recovery catalog
full resync complete

Oracle Database 11g: Administration Workshop II A - 104


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


RMAN>
4) Report the schema to note the file name for the APPRAISAL tablespace.
RMAN> report schema;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Report of database schema for database with db_unique_name


ORCL

List of Permanent Datafiles


===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- -------------------
-----
1 700 SYSTEM YES
+DATA/asmtesting/datafile/testing.258.634268145
2 679 SYSAUX NO
+DATA/orcl/datafile/sysaux.259.634164339
ble
3 200 UNDOTBS1 YES
fe r a
+DATA/orcl/datafile/undotbs1.260.634164355
ans
4 5 USERS NO
n - t r
+DATA/orcl/datafile/users.263.634165219
5 100 EXAMPLE NO a no
a s
+DATA/orcl/datafile/example.261.634164377
) h i d eฺ
6 50 TBSJMW NO
m
co nt Gu
+DATA/orcl/datafile/tbsjmw.269.634202579
i l ฺ
7 25 APPRAISAL NO
g ma tude
+FRA/orcl/datafile/appraisal.295.634277277
.
u k i@ is S
.
a sy se th
.
k i (M to u
Note thats yuare now
you n e the Flash Recovery Area data file as the open data file
susing
a lic e
Monline tablespace.
for the
l e y
n5) Determine what happened to the original data file.
Sta List the image copies for data file 7, to see if it is listed.
RMAN> list copy of datafile 7;

List of Datafile Copies


=======================

Key File S Completion Time Ckp SCN Ckp Time


------- ---- - ------------------- ---------- ----------------
---
982 7 A 2007-09-26:04:37:21 1288660 2007-09-
26:04:25:52
Name: +DATA/orcl/datafile/appraisal.256.634276429

Oracle Database 11g: Administration Workshop II A - 105


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


Note that it is still there and is listed now as an image copy. But, the reason for
switching was because this data file was considered to be on a damaged disk, or the
data file itself was corrupted.
6) In a separate terminal window, make sure you are at the ~/labs directory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ cd ~/labs

7) Remember that the reason for switching was because this data file was considered to
be on a damaged disk, or the data file itself was corrupted in some way. So, run the
rm_asm_file.sh script to delete the file.
$ ./rm_asm_file.sh +DATA/orcl/datafile/appraisal.256.634276429

8) Eventually, you want to refrain from using the Flash Recovery Area as storage for
active data files. By now, the hardware or corruption problem has been remedied, so
switch the data file back to the original location.
a) Back up the data file, specifying the DATA ASM disk group, using the ble
DATAFILE template. fe r a
ans
RMAN> backup as copy to destination '+DATA(datafile)' datafile
n - t r
7;
a no
a s
Starting backup at 2007-09-26:05:11:02
) h i d eฺ
using channel ORA_DISK_1 m
co copy G u
channel ORA_DISK_1: starting datafile i l
a den ฺ t
input datafile file number=00007
g m tu
i @ S
name=+FRA/orcl/datafile/appraisal.295.634277277
is
ukRECID=33
t h
output file name=+DATA/orcl/datafile/appraisal.256.634281073
s y
a
tag=TAG20070926T051102
M u s e STAMP=634281075
i (
channel ORA_DISK_1:
k t o
datafile copy complete, elapsed time:
00:00:03 u
a sybackup e n se
lic
Finished at 2007-09-26:05:11:15
y M
l e
n Starting Control File and SPFILE Autobackup at 2007-09-
Sta 26:05:11:16
piece
handle=+FRA/orcl/autobackup/2007_09_26/s_634281078.304.6342810
91 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-09-
26:05:11:33

RMAN>

b) Take the data file offline.


RMAN> sql "alter database datafile 7 offline";

sql statement: alter database datafile 7 offline

RMAN>

c) Switch the data file to the newly made copy.

Oracle Database 11g: Administration Workshop II A - 106


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy


"+DATA/orcl/datafile/appraisal.256.634281073"
starting full resync of recovery catalog
full resync complete
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>
d) Report the schema to confirm that the data file location has changed.
RMAN> report schema;

Report of database schema for database with db_unique_name


ORCL

List of Permanent Datafiles


===========================
ble
File Size(MB) Tablespace RB segs Datafile Name
fe r a
---- -------- -------------------- ------- -------------------
ans
-----
n - t r
1 700 SYSTEM YES
+DATA/asmtesting/datafile/testing.258.634268145 a no
a s
2 679 SYSAUX NO
) h i d eฺ
m
co nt Gu
+DATA/orcl/datafile/sysaux.259.634164339
3 200 UNDOTBS1
i l ฺYES
ma tude
+DATA/orcl/datafile/undotbs1.260.634164355
g
4 5 USERS
u k i@ is S NO
+DATA/orcl/datafile/users.263.634165219
5 100
a sy se th
EXAMPLE NO

k i (M to u
+DATA/orcl/datafile/example.261.634164377

syu cense
6 50 TBSJMW NO
a
+DATA/orcl/datafile/tbsjmw.269.634202579
li
le
7
yM 25 APPRAISAL NO
n +DATA/orcl/datafile/appraisal.256.634281073
Sta .
.
.

9) Recover the data file.


RMAN> recover datafile 7;

Starting recover at 2007-09-26:05:14:48


using channel ORA_DISK_1

starting media recovery


media recovery complete, elapsed time: 00:00:00

Finished recover at 2007-09-26:05:14:49

RMAN>

Oracle Database 11g: Administration Workshop II A - 107


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


10) Bring the data file online.
RMAN> sql "alter database datafile 7 online";

sql statement: alter database datafile 7 online


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN>

11) Cross-check the image copy backups and remove the obsolete data file 7 image copy.
Exit RMAN when finished.
RMAN> crosscheck copy;

released channel: ORA_DISK_1


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=118 device type=DISK
validation succeeded for datafile copy
datafile copy file
ble
name=+FRA/orcl/datafile/system.290.634276557 RECID=30
fe r a
STAMP=634278061
ans
validation succeeded for datafile copy
n - t r
no
.
.
s a
.
) h a eฺ
datafile copy file
m i d
i l ฺ co nt Gu
name=+FRA/orcl/datafile/appraisal.295.634277277 RECID=34

ma tude
STAMP=634281188
g
validation failed for datafile copy
datafile copy file
u k i@ is S
sy se th
name=+DATA/orcl/datafile/appraisal.256.634276429 RECID=32
a
k i (M to u
STAMP=634279041
validation succeeded for archived log
syu cense
archived log file
a
yM li
name=/u01/app/oracle/product/11.1.0/db_1/dbs/arch1_36_63124294

nle 3.dbf RECID=7 STAMP=634245437

Sta validation succeeded for archived log


archived log file
name=+FRA/orcl/archivelog/2007_09_25/thread_1_seq_36.279.63424
5437 RECID=8 STAMP=634245437
validation succeeded for archived log
.
.
.
Crosschecked 28 objects

RMAN> list expired copy;

specification does not match any archived log in the recovery


catalog
List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time

Oracle Database 11g: Administration Workshop II A - 108


Computer Pride Limited

Practice 7-2: Performing Fast Recovery (continued)


------- ---- - ------------------- ---------- ----------------
---
982 7 X 2007-09-26:04:37:21 1288660 2007-09-
26:04:25:52
Name: +DATA/orcl/datafile/appraisal.256.634276429
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

RMAN> delete expired copy;

released channel: ORA_DISK_1


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=118 device type=DISK
specification does not match any archived log in the recovery
catalog
List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time


ble
------- ---- - ------------------- ---------- ----------------
--- fe r a
982 7 X 2007-09-26:04:37:21 1288660 2007-09- ans
26:04:25:52 n - t r
Name: +DATA/orcl/datafile/appraisal.256.634276429
a no
a s
) h i d eฺ
Do you really want to delete the above
c o m G
objects u(enter YES or
NO)? yes ฺ
ail den t
deleted datafile copy m
g Stu
datafile copy file i @
y uk this
name=+DATA/orcl/datafile/appraisal.256.634276429
s RECID=32
STAMP=634279041 a
us
M objects e
i ( t o
uk nse
Deleted 1 EXPIRED
s y
RMAN> aexit ce
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 109


Computer Pride Limited

Practices for Lesson 8

Practice 8-1: Cloning a Database


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you clone a database using Enterprise Manager (EM).

1) Start an RMAN session, connecting to the orcl instance as the target, and also
connecting to the rcat instance as the recovery catalog. Again, use oraenv to set up
the environment for the orcl instance.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ rman target / catalog rcatowner/oracle@rcat
ble
fe r a
2) Make sure that RMAN is configured to automatically back up the control file. ans
n - t r
RMAN> configure controlfile autobackup on;
a no
a s
old RMAN configuration parameters: ) h i d eฺ
CONFIGURE CONTROLFILE AUTOBACKUP OFF; om u
new RMAN configuration parameters: ilฺc t G
CONFIGURE CONTROLFILE AUTOBACKUPm a den
ON;
@ g
new RMAN configuration parameters are tsuccessfully
S u stored
k i i s
full resync complete syu
starting full resync of recovery catalog
a e th
RMAN>
i ( M to us
3) Configure s y uk to nwrite
RMAN sethe control file auto backup to the desired location, so that
a e
c there together.
l e y M filesliare
all the backup

StanRMAN> configure controlfile autobackup format for device type


disk to '/backup/%F';

old RMAN configuration parameters:


CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '/backup/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '/backup/%F';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN>

4) You need a backup of the ORCL database to be used as the source of the cloning
operation. Back up all the data files.

RMAN> backup database format '/backup/bu_%d_%s_%p' plus

Oracle Database 11g: Administration Workshop II A - 110


Computer Pride Limited

archivelog format '/backup/bu_%d_%s_%p';

5) Return the autobackup file location to the default setting.

RMAN> configure controlfile autobackup format for device type


disk clear;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

old RMAN configuration parameters:


CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '/backup/%F';
RMAN configuration parameters are successfully reset to
default value
starting full resync of recovery catalog
full resync complete
RMAN>

6) The PFILE for the cloned database will be based on ORCL’s SPFILE. The dispatcher
parameter references the orclXDB service, so you have to remove it from the SPFILE
while the clone operation is taking place. ble
fe r a
Log in using SQL*Plus and remove the entry for the dispatchers from the SPFILE. Then
ans
t r
archive the current redo logs, to make available as much redo as possible for the clone
n -
operation.
a no
a s
eฺ
$ sqlplus / as sysdba
) h i d
m
co nt Gu
SQL> show parameter disp
i l ฺ
NAME TYPE
g ma VALUE t u de
u k i@ is S----------------------
--------------------------- -----------
dispatchers
a sy integer
string
e th (PROTOCOL=TCP)(SERVICE=orclXDB)
M to us
max_dispatchers
i (
s y uk set
SQL> alter system
n s e
dispatchers='' scope=spfile;

System M
a
altered.lice
n l eyalter system archive log current;
Sta SQL>

System altered.

SQL>

7) In EM, navigate to Data Movement > Clone Database.

Oracle Database 11g: Administration Workshop II A - 111


Computer Pride Limited

8) Select the option to use an existing backup for the source. Then click Continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
no
9) On the Source Options page, enter the backup directory in the RMAN Backup
a
s
Location field. Leave the Staging Area Location as the default setting. Then click Next.
a
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 112


Computer Pride Limited

10) Specify odup for the Global Database Name and the Instance Name. Leave the
default values in all the other fields. Then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 113


Computer Pride Limited

11) On the Destination Options page, leave the default values in all the fields. Then click
Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
h a
12) You see a warning page regarding a sales history data file andsthe control
ฺ file
directory. Click Yes to continue. ) id e
o m G u
a ilฺc ent
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 114


Computer Pride Limited

13) You may also get an error message similar to the following about controlfiles:

“The following files or directories cannot be created due to the specified reasons:
/u01/app/oracle/oradata/odup/current.267.ctl; These file names are used for more than
one database file.”
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

If this happens, click the Customize button on the Destination Options page and scroll
down on the new page to the section on controlfiles. You will see that both controlfiles
are going to be called the same name, so alter the name of one to stop this happening.

Then click OK to return to the Destination Options page. Then click Next.

14) On the Database Configuration page, leave the default values in all the fields, and
click Next.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 115


Computer Pride Limited

15) On the Schedule page, leave the default values in all the fields, and click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
k i@
16) Review the Review page, anduthen i s
clickhSubmit
S Job.
a sy se t
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 116


Computer Pride Limited

17) Click View Results, and view the status of the job until it shows that it is
“Succeeded.”
The entire job takes five to eight minutes to complete.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

18) Configure a terminal window environment to work with a terminal session with the
ORACLE_SID set to ODUP.
ble
$ . oraenv
fe r a
ORACLE_SID = [orcl] ? odup
ans
The Oracle base for
n - t r
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle a no
a s
deฺsure that you
$
h
)table toumake
i
o m
19) Log in to the ODUP database, using SQL*Plus. Query a
have a copy of the source database.
a ilฺc ent G
$ sqlplus / as sysdba
@ gm Stud
SQL*Plus: Release 11.1.0.6.0
y u ki - tProduction
h is on Mon Aug 20
12:50:13 2007 s se All rights reserved.
a2007, uOracle.
Copyright (c) 1982,
Connected to: ki ( M to
Oracle Databasey u
s cen e
11gsEnterprise Edition Release 11.1.0.6.0 -
a li
M Partitioning,
Production
Withy the Oracle Label Security, OLAP, Data
l e
tanand Real Application Testing options
Mining
S
SQL> select count(*) from hr.job_history;
COUNT(*)
----------
10

20) Truncate the HR.JOB_HISTORY table in the ODUP database, and then exit
SQL*Plus.
SQL> truncate table hr.job_history;
Table truncated.
SQL> exit

21) Query the truncated table to prove it is still populated in the ORCL instance.
$ . oraenv

Oracle Database 11g: Administration Workshop II A - 117


Computer Pride Limited

ORACLE_SID = [odup] ? orcl


$ sqlplus / as sysdba
SQL> select count(*) from hr.job_history;
COUNT(*)
----------
10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

22) Now reinstate the dispatcher parameter in the orcl instance and then exit from
SQL*Plus.
SQL> show parameter disp

NAME TYPE VALUE


--------------------------- ----------- ----------------------
dispatchers string (PROTOCOL=TCP)(SERVICE=orclXDB)
max_dispatchers integer

SQL> alter system set dispatchers='(PROTOCOL=TCP)(SERVICE=orclXDB)'


scope=spfile;
ble
SQL> exit
fe r a
ans
23) Run dbca to delete the ODUP database because it is no longer needed.
n - t r
a) Start dbca.
a no
a s
eฺ
$ dbca
b) Click Next on the Welcome page. ) h i d
m
co nt Gu
i
c) Choose Delete a Database on the Operations page.l ฺ
a declick Finish.
tom
d) Select odup from the list of databases g delete. Then
i @ S tu
s y uk this
( M a use
y u ki se to
M as licen
n l ey
Sta

Oracle Database 11g: Administration Workshop II A - 118


Computer Pride Limited

e) Confirm the delete operation by clicking Yes.

f) After the delete operation is finished, click No when asked if you want to perform
another operation.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 119


Computer Pride Limited

Practices for Lesson 9


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Practice 9-1: Performing Tablespace Point-in-Time Recovery


In this practice, you perform tablespace point-in-time recovery.
1) Execute the export_hr_data.sh script to export the HR schema.
Note: This takes four to five minutes.
$ cd ~oracle/labs
$ ./export_hr_data.sh

ble
Export: Release 11.1.0.6.0 - Production on Monday, 20 August,
fe r a
ns
2007 13:14:53

- t r a
Copyright (c) 2003, 2007, Oracle. All rights reserved.
o n
Connected to: Oracle Database 11g Enterprise s a n Release
ha ideฺ
Edition
11.1.0.6.0 - Production )
m GuOLAP, Data
With the Partitioning, Oracle Label Security,
ฺ c o t
Mining
a il e n
m tud
and Real Application Testinggoptions
k i @ s S
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":
i system/********
u
sy se t
dumpfile=hrexp.dmp schemas=hr h
M a
. . exported "HR"."REGIONS"
( u 5.476
KB 4 rows
u e to
ki"SYSTEM"."SYS_EXPORT_SCHEMA_01"
s y
Master table
a e n s successfully
M lic
loaded/unloaded
.y
l
n .e
Sta .
**************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/admin/orcl/dpdump/hrexp.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at
13:16:13

2) Run the create_hrtest.sql script to create a new tablespace and a new user in
your database.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle

Oracle Database 11g: Administration Workshop II A - 120


Computer Pride Limited

$ sqlplus / as sysdba
SQL> @create_hrtest.sql
SQL> SET TERMOUT ON
SQL> CONNECT / AS SYSDBA
Connected.
SQL> REM ***** Tablespace for the HR import *****
SQL> DROP TABLESPACE hrtest INCLUDING CONTENTS AND DATAFILES
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2 /
DROP TABLESPACE hrtest INCLUDING CONTENTS AND DATAFILES
*
ERROR at line 1:
ORA-00959: tablespace 'HRTEST' does not exist

SQL> CREATE SMALLFILE TABLESPACE HRTEST


2 DATAFILE '/u01/app/oracle/oradata/orcl/hrtest01.dbf' SIZE
2M
3 AUTOEXTEND ON NEXT 500K MAXSIZE UNLIMITED LOGGING
ble
4
5
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO fe r a
6 /
ans
n - t r
Tablespace created.
a no
h a s***** ฺ
SQL> REM ***** User/schema for the HR import
m ) u i de
lฺco ent G
SQL> DROP USER hrtest cascade
2 /
a i
DROP USER hrtest cascade
@ gm Stud
*
ERROR at line 1:
y u ki this
a s
ORA-01918: user 'HRTEST' e not exist
sdoes
( M u
y u ki se to
as licUSER
SQL> CREATE
M en hrtest
l e y2 PROFILE DEFAULT
n 3 IDENTIFIED BY hrtest
Sta 4 DEFAULT TABLESPACE hrtest
5 TEMPORARY TABLESPACE temp
6 QUOTA UNLIMITED ON hrtest
7 ACCOUNT UNLOCK
8 /

User created.

SQL> GRANT connect, resource


2 TO hrtest
3 /

Grant succeeded.

SQL> SPOOL OFF


SQL> exit

Oracle Database 11g: Administration Workshop II A - 121


Computer Pride Limited

3) Execute the pop_hrtest.sh script to populate the new tablespace with a copy of
the data from the HR schema.
Note: The import should complete successfully. You receive error messages because
the import excludes the COUNTRIES, REGIONS, and LOCATIONS tables. These
messages can be ignored.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ ./pop_hrtest.sh

Import: Release 11.1.0.6.0 - Production on Monday, 20 August,


2007 13:37:50

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release


11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options ble
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully
fe r a
loaded/unloaded
ans
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********
n - t r
dumpfile=hrexp.dmp parfile=impdphr.par
a no
Processing object type SCHEMA_EXPORT/USER
a s
) h
ORA-31684: Object type USER:"HRTEST" already exists
i d eฺ
m
co nt Gu
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
i l ฺ
Processing object type SCHEMA_EXPORT/ROLE_GRANT
ma tude
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
g
u k i@ is S
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

sy se th
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
a
Processing object type SCHEMA_EXPORT/TABLE/TABLE
(M to u
i
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
k
KB a syu cense
. . imported "HRTEST"."DEPARTMENTS"
27 rows
7.007

yM li
. . imported "HRTEST"."EMPLOYEES" 16.80
nle
Sta
KB 107 rows
. . imported "HRTEST"."JOBS" 6.984
KB 19 rows
. . imported "HRTEST"."JOB_HISTORY" 7.054
KB 10 rows
Processing object type
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type
SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"HRTEST"."EMP_DETAILS_VIEW"
created with compilation warnings

Oracle Database 11g: Administration Workshop II A - 122


Computer Pride Limited

Processing object type


SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ORA-39083: Object type REF_CONSTRAINT failed to create with
error:
ORA-00942: table or view does not exist
Failing sql is:
ALTER TABLE "HRTEST"."DEPARTMENTS" ADD CONSTRAINT
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

"DEPT_LOC_FK" FOREIGN KEY ("LOCATION_ID") REFERENCES


"HRTEST"."LOCATIONS" ("LOCATION_ID") ENABLE

Processing object type SCHEMA_EXPORT/TABLE/TRIGGER


Processing object type
SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type
SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 3 error(s) at
13:38:07

ble
$
fe r a
ans
4) Create a backup of your database using RMAN. n - t r
n o
RMAN> backup database; s a
) h a eฺ
Starting backup at 2007-08-20:13:40:42m i d
l ฺ
starting full resync of recovery icatalog co nt Gu
m a de
full resync complete
i
allocated channel: ORA_DISK_1@ g S tu
y uk device
channel ORA_DISK_1: SID=118 t h is type=DISK
channel ORA_DISK_1: s se full
a starting datafile backup set
( M o u
i filee tnumber=00001
channel ORA_DISK_1: specifying datafile(s) in backup set
u k
sy cens
input datafile
a li
name=+DATA/asmtesting/datafile/testing/system.258.630811685
y M ORA_DISK_1:
n l e
channel starting piece 1 at 2007-08-20:13:40:55

Sta
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:43:21
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.308.631114857 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:02:26
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002
name=+DATA/orcl/datafile/sysaux.259.630811693
channel ORA_DISK_1: starting piece 1 at 2007-08-20:13:43:29
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:45:45
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.309.631115013 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:02:16
channel ORA_DISK_1: starting full datafile backup set

Oracle Database 11g: Administration Workshop II A - 123


Computer Pride Limited

channel ORA_DISK_1: specifying datafile(s) in backup set


input datafile file number=00007
name=/u01/app/oracle/oradata/orcl/hrtest01.dbf
input datafile file number=00003
name=+DATA/orcl/datafile/undotbs1.260.630811713input datafile
file number=00004 name=+DATA/orcl/datafile/users.263.630812119
input datafile file number=00005
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

name=+DATA/orcl/datafile/example.261.630811719
input datafile file number=00006
name=+DATA/orcl/datafile/tbsjmw.269.630814117
channel ORA_DISK_1: starting piece 1 at 2007-08-20:13:45:52
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:46:17
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.310.631115153 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:25
Finished backup at 2007-08-20:13:46:17
ble
Starting Control File and SPFILE Autobackup at 2007-08- fe r a
20:13:46:17
ans
piece
n - t r
handle=+FRA/orcl/autobackup/2007_08_20/s_631115181.311.6311151
a no
89 comment=NONE
a s
) h
Finished Control File and SPFILE Autobackup at 2007-08-
i d eฺ
20:13:46:36 m
co nt Gu
i l ฺ
RMAN>
g ma tude
u k i@ is S
a s y e th
5) Record the current SCN
( M fortthe s
udatabase: ____________
i
ukcurrent_scn o
a s y
SQL> select
e n se from V$database;

yM lic
l e
CURRENT_SCN
n -----------
Sta 1416777

6) Record the current time: _____________________


SQL> host date
Mon Aug 20 13:49:10 GMT-7 2007

SQL>

7) Execute the query_salary.sql script to query the HRTEST.EMPLOYEES table


and view information about employees in department 60.
Make note of the highest salary that is displayed: ________
SQL> @query_salary
SQL> select employee_id, last_name, salary
2 from employees
3 where department_id = 60

Oracle Database 11g: Administration Workshop II A - 124


Computer Pride Limited

4 /

EMPLOYEE_ID LAST_NAME SALARY


----------- ------------------------- ----------
103 Hunold 9000
104 Ernst 6000
105 Austin 4800
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

106 Pataballa 4800


107 Lorentz 4200

8) Execute the give_raise.sql script to update the salaries for the employees in
department 60 and note the highest salary displayed.
Highest salary: _____________
SQL> @give_raise
SQL> update hrtest.employees
2 set salary = salary * 1.25
3 where department_id = 60
4 /
ble
fe r a
5 rows updated.
ans
SQL> select employee_id, last_name, salary
n - t r
2 from hrtest.employees
3 where department_id = 60 a no
a s
4 /
) h i d eฺ
m Gu
co ntSALARY
EMPLOYEE_ID LAST_NAME
i l ฺ
a d----------
----------- -------------------------
g m u e
103 Hunold
i @ is S t 11250
104 Ernst u k t h 7500
105 Austin sy e
( M a u s 6000
106 Pataballa
107 k i
u nse
Lorentz t o 6000
5250
s y
a lice
y M
n9)leYou now want to perform TSPITR for the HRTEST tablespace to return it to the state
Sta prior to the updates. Execute the check_deps.sql script to determine whether
there are any dependencies that prevent the TSPITR operation.
SQL> @check_deps
SQL> SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
2 obj2_owner, obj2_name, obj2_type, ts2_name,
3 constraint_name, reason
4 FROM SYS.TS_PITR_CHECK
5 WHERE (TS1_NAME IN ('HRTEST')
6 AND TS2_NAME NOT IN ('HRTEST'))
7 OR (TS1_NAME NOT IN ('HRTEST')
8 AND TS2_NAME IN ('HRTEST'))
9 /

no rows selected

Oracle Database 11g: Administration Workshop II A - 125


Computer Pride Limited

“No rows selected” indicates that there are no dependencies to any tablespaces
outside the recovery set, so you can proceed with the tablespace point-in-time
recovery.
10) You can use Enterprise Manager Database Control or the RMAN command line to
perform tablespace point-in-time recovery. In Enterprise Manager, navigate to
Availability > Perform Recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Note: The answer presents the solution using Enterprise Manager Database Control.
If you want to use the RMAN command line, refer to the course notes for detailed
information and execute the RECOVER TABLESPACE command as follows:
RECOVER TABLESPACE hrtest UNTIL SCN <scn>
AUXILIARY DESTINATION ‘/u01/app/oracle/oradata/tspitr’;
11) Select Tablespaces for Recovery Scope, enter the login credentials, and then click
Recover.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
t a n12)leOn the Point-in-time page, select the “Recover to a prior point-in-time” option button.
S Choose SCN and enter the SCN that you recorded earlier in this practice. Then click
Next.

Oracle Database 11g: Administration Workshop II A - 126


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
13) Specify the auxiliary instance location of
a no
a s
/u01/app/oracle/oradata/tspitr. Click Add to add the HRTEST
) h
tablespace to the recovery job. Then click Next.i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

14) Create the auxiliary location directory now.


$ mkdir -p /u01/app/oracle/oradata/tspitr

Oracle Database 11g: Administration Workshop II A - 127


Computer Pride Limited

15) On the Rename page, specify that the files are to be restored to the default location.
Then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
16) Review the Review page, and then click Submit. Watch fora
h s job to ฺcomplete. It
the
runs for six to eight minutes.
m ) u i de
lฺco see
17) When the job completes, note the status. Youishould
a e n G
at page titled “Operation
Succeeded.” When you do, review it, g mthen click
and t u dOK.
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan

18) Using EM, verify that the HRTEST tablespace is online by navigating to Database >
Server > Tablespaces. If there is a green check mark in the Status column, it is online.
19) Verify that the SALARY columns in HRTEST.EMPLOYEES for the employees in
department 60 contain the correct values. Run the query_salary.sql script to do
this.

Oracle Database 11g: Administration Workshop II A - 128


Computer Pride Limited

SQL> @query_salary
SQL> select employee_id, last_name, salary
2 from hrtest.employees
3 where department_id = 60
4 /

EMPLOYEE_ID LAST_NAME SALARY


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

----------- ------------------------- ----------


103 Hunold 9000
104 Ernst 6000
105 Austin 4800
106 Pataballa 4800
107 Lorentz 4200

Note that the highest salary value is now back to the original value you recorded
earlier.
20) Execute the add_constraint.sql script to add a constraint to the
HRTEST.DEPARTMENTS table. ble
fe r a
SQL> @add_constraint
an s
SQL> connect / as sysdba
n - t r
Connected.
a no
SQL> GRANT references (location_id) on hr.locations to hrtest
a s
2 /
) h i d eฺ
m
co nt Gu
Grant succeeded.
i
a del ฺ
SQL> connect hrtest/hrtest gm tu
i @ S
Connected.
s y uk this
( M
2 ADD CONSTRAINT se
SQL> ALTER TABLE hrtest.departments
a dept_loc_id_fk
u FOREIGN KEY (location_id)
i t o
uk nhr.locations
3 REFERENCES
e (location_id)
4 / sy
a lice s
y M
nleTable altered.
Sta 21) Assume you need to perform TSPITR on the HRTEST tablespace again. Execute the
check_deps.sql query to determine whether there are any dependencies outside
the recovery set.
SQL> @check_deps
SQL> set echo on
SQL> SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
2 obj2_owner, obj2_name, obj2_type, ts2_name,
3 constraint_name, reason
4 FROM SYS.TS_PITR_CHECK
5 WHERE (TS1_NAME IN ('HRTEST')
6 AND TS2_NAME NOT IN ('HRTEST'))
7 OR (TS1_NAME NOT IN ('HRTEST')
8 AND TS2_NAME IN ('HRTEST'))
9 /
OBJ1_OWNER OBJ1_NAME OBJ1_TYPE TS1_NAME
---------------------------------------------------------

Oracle Database 11g: Administration Workshop II A - 129


Computer Pride Limited

OBJ2_OWNER OBJ2_NAME OBJ2_TYPE TS2_NAME


------------------------------ --------------------------
CONSTRAINT_NAME REASON
------------------------------
HR LOCATIONS TABLE EXAMPLE
HRTEST DEPARTMENTS TABLE HRTEST
DEPT_LOC_ID_FK
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

constraint between tables not contained in recovery set

HR LOCATIONS TABLE EXAMPLE


HRTEST DEPARTMENTS TABLE HRTEST
DEPT_MGR_FK
constraint between tables not contained in recovery set

HR LOCATIONS TABLE EXAMPLE


HRTEST DEPARTMENTS TABLE HRTEST
DEPT_ID_PK
constraint between tables not contained in recovery set
ble
HR LOCATIONS TABLE EXAMPLE fe r a
HRTEST DEPARTMENTS TABLE HRTEST
ans
DEPT_NAME_NN
n - t r
constraint between tables not contained in recovery set
a no
a s
) h i d eฺ
22) If you wanted to complete the tablespace point-in-time
c m
o recovery
G ufor the HRTEST
i l ฺ t
ma tuden
tablespace now, what would you need to do?
g
k i@tablespace
Note: You will not perform another i s Spoint-in-recovery in this practice.
u t h
sy theseDEPT_LOC_ID_FK
Answer: You would need
( a
M to u
to disable constraint that was added to
k i
your HRTEST.DEPARTMENTS table or you would need to add the tablespace that
syu cense table to your recovery set.
contains theaHR.LOCATIONS
yM li
l e
Stan

Oracle Database 11g: Administration Workshop II A - 130


Computer Pride Limited

Practices for Lesson 10


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Practice 10-1: Monitoring RMAN Jobs


In this practice, you execute a long-running RMAN job and monitor its progress to
determine how much longer it is expected to run.
1) Invoke RMAN and delete all obsolete backups. You need to perform a cross-check
first, so that the repository is up-to-date.
$ rman target / catalog rcatowner/oracle@rcat
RMAN> crosscheck backup;
RMAN> delete noprompt obsolete;
ble
fe r a
2) Open a second terminal window. Change to the labs directory. Invoke SQL*Plus
ans
t r
and connect as SYSDBA. You use this second session to monitor a database backup.
n -
$ sqlplus / as sysdba
a no
h a sbegin aฺdatabase
3) Return to your first terminal window. In your RMAN session,
m ) u i de
backup to the tape device.
a i l ฺco nt G
RMAN> backup device type sbt database;
g m tude
u k i@ is S
sy se th
Starting backup at 2007-08-20:14:46:36
released channel:aORA_DISK_1
allocated channel:
i t u
(M ORA_SBT_TAPE_1
o
k
yu ense
channel ORA_SBT_TAPE_1: SID=120 device type=SBT_TAPE
a
channel sORA_SBT_TAPE_1:
c WARNING: Oracle Test Disk API
y M
channel l i
ORA_SBT_TAPE_1: starting full datafile backup set
n l e
Sta 4)
...

Use your SQL*Plus session to monitor the progress of the database backup by
querying the V$SESSION_LONGOPS view. By using this view, you can determine
whether the backup is progressing normally or hanging. If the backup is progressing
normally, the TIME_REMAINING column should be decreasing. Execute the
query_longops.sql script a few times to query V$SESSION_LONGOPS.
When the script runs, enter the SID number from step 3. Enter a slash to continue
reexecuting the query. Each time you should see the TIME_REMAINING value
decreasing for the SID associated with the backup task.
SQL> @query_longops

Enter value for sid_from_backup_output: 120


old 2: FROM v$session_longops where sid =
&sid_from_backup_output
new 2: FROM v$session_longops where sid = 120

Oracle Database 11g: Administration Workshop II A - 131


Computer Pride Limited

SID START_TIM ELAPSED_SECONDS TIME_REMAINING


---------- --------- --------------- --------------
120 27-SEP-07 94 0
120 27-SEP-07 94 0
120 27-SEP-07 42 58
120 27-SEP-07 42
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> /
Enter value for sid_from_backup_output: 120
old 2: FROM v$session_longops where sid =
&sid_from_backup_output
new 2: FROM v$session_longops where sid = 120

SID START_TIM ELAPSED_SECONDS TIME_REMAINING


---------- --------- --------------- --------------
120 27-SEP-07 94 0
120 27-SEP-07 94 0
120 27-SEP-07 54 40
ble
SQL>
120 27-SEP-07 54
fe r a
an s
5) Run the cleanup_archivelogs.sh script to back up and remove archivelog
n - t r
files. This takes several minutes to run.
a no
a s
$ cd ~/labs
) h i d eฺ
$ ./cleanup_archivelogs.sh
c m
o t Gu
i l ฺ
m tuden
6) Run the cleanup_tape_dir.sh scripta to remove files from the /tape
directory. g
u k i@ is S
$ ./cleanup_tape_dir.sh
a sy se th
i (M catalog
7) Shut down the recovery
t o uinstance. You are finished with it.
k se
a
$ sqlplussyusys/oracle@rcat
c e n as sysdba
y M l i
nleSQL> shutdown immediate
Sta 8) Run the size_memory_up.sh script to size the database appropriately for the
following practices.
$ cd ~/labs
$ ./size_memory_up.sh

Oracle Database 11g: Administration Workshop II A - 132


Computer Pride Limited

Practices for Lesson 11


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In these practices, you use the recycle bin to flash back dropped objects. You also
explore the workings of Flashback Transaction.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 133


Computer Pride Limited

Practice 11-1: Using the Recycle Bin


In this practice you use the recycle bin to restore dropped objects. You can do this with
SQL commands or with Enterprise Manager. For the former, perform steps 1 through 4.
For the latter, perform steps 1 then 5 through 8.
1) This workshop scenario simulates loss of data. To introduce the problem, change
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

directory to $HOME/labs and run the recyclebin_lab.sh as shown:


$ cd $HOME/labs
$ ./recyclebin_lab.sh

2) The lab script drops the HR.DEPARTMENTS table including indexes, restraints, and
so on. Query the DBA_RECYCLE_BIN view to confirm this.
$ sqlplus / as sysdba
SQL> SELECT owner, original_name, droptime FROM dba_recyclebin
where owner = 'HR';
ble
OWNER ORIGINAL_NAME DROPTIME
fe r a
------ ------------------ -------------------
ans
HR DEPT_LOCATION_IX 2007-07-24:10:51:11
n - t r
HR DEPT_ID_PK 2007-07-24:10:51:11
a no
HR DEPARTMENTS 2007-07-24:10:51:11
a s
...
) h i d eฺ
m
co Youncan u Flashback Table
Guse
i l ฺ
3) Use Flashback Table to restore the dropped objects. t
a dToeflash back the table using
through Enterprise Manager or through SQL*Plus.
m
Enterprise Manager, skip to step 5.@
i
g S tu
s y uk this TO BEFORE DROP;
SQL> FLASHBACK TABLE
( M a use hr.departments

u ki se to
Flashback complete.
y
SQL>
M as licen
y
n4)lePerform a select operation against the HR.DEPARTMENTS table to confirm the
Sta success of the Flashback Table operation.
SQL> SELECT * FROM hr.departments;

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID


------------- -------------------------- ---------- -----------
10 Administration 200 1700
20 Marketing 201 1800
30 Purchasing 114 1700
. . .

5) The HR.DEPARTMENTS table can also be flashed back using Enterprise Manager.
On the Database home page, click the Schema folder tab, and then click Tables
located under Database Objects. Next, click the Recycle Bin button, enter HR in the
Schema Name field and click Go. Select DEPARTMENTS from the list and click the
Flashback Drop button.

Oracle Database 11g: Administration Workshop II A - 134


Computer Pride Limited

Practice 11-1: Using the Recycle Bin (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
6) The Perform Object Level Recovery: Rename page allows you to rename the restored
ans
object. Accept the default or original name and click Next.
n - t r
no
7) On the Review page, inspect the Impact Analysis. Note that the table and dependent
a
a s
objects are to be restored and note the names they will be restored to. Click Submit.
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

8) Click OK on the Confirmation page. From a SQL*Plus session, query the


HR.DEPARTMENTS table to verify the success of the operation.
$ sqlplus / as sysdba
SQL> select * from hr.departments;

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID


------------- -------------------- ---------- -----------

Oracle Database 11g: Administration Workshop II A - 135


Computer Pride Limited

Practice 11-1: Using the Recycle Bin (continued)


10 Administration 200 1700
20 Marketing 201 1800
30 Purchasing 114 1700
40 Human Resources 203 2400
50 Shipping 121 1500
60 IT 103 1400
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

...

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 136


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout

Flashback Transaction Backout is a logical recovery option to roll back a specific


transaction and dependent transactions while the database remains online. A dependent
transaction is related by a write-after-write (WAW) relationship, in which a transaction
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

modifies the same data that was changed by the target transaction, or a primary-key
constraint relationship, in which a transaction reinserts the primary-key value that was
deleted by the target transaction. Flashback Transaction utilizes undo and the redo
generated for undo blocks to create and execute a compensating transaction for reverting
the affected data to its original state.
1) Flashback Transaction Backout requires that the database be in ARCHIVELOG mode.
From a terminal session connected as the oracle user, ensure that you are pointing
to the orcl database and execute the flatxn_archivelog.sh script from the
$HOME/labs directory.
ble
fe r a
$ cd $HOME/labs
ans
$ echo $ORACLE_SID
n - t r
orcl
$ ./flatxn_archivelog.sh a no
a s
*******************************************
) h i d eฺ
* Unlock HR account
m
co nt Gu
* Enable ARCHIVELOG mode for database
i l ฺ
The script may appear to hang g mata thetuSQLde prompt
when the database is shuttingk i@ down i s Sand being
opened. Wait a few s y u h
t it should progress.
a minutes
s eand

k i (M to u
*******************************************

s
SQL*Plus:
a yuRelease
e n se11.1.0.6.0 - Production on Thu Jul 12
y M 2007
12:35:19 lic
n l e
Sta Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> SQL>
User altered.

SQL>
System altered.

SQL> SQL> Database closed.


Database dismounted.
ORACLE instance shut down.

Oracle Database 11g: Administration Workshop II A - 137


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


SQL> ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300232 bytes
Variable Size 260049144 bytes
Database Buffers 155189248 bytes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Redo Buffers 6131712 bytes


Database mounted.
SQL>
Database altered.

SQL>
Database altered.

SQL> Database log mode Archive Mode


Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
ble
Oldest online log sequence
Next log sequence to archive
12
14 fe r a
Current log sequence 14 ans
SQL> Disconnected from Oracle Database 11g Enterprise Edition n - t r
Release 11.1.0.6.0 - Production
a no
With the Partitioning, OLAP, Data Mining and Real Application
a s
Testing options ) h i d eฺ
$ m
co nt Gu
i l ฺ
2) Using SQL*Plus, connect to the database
g masathe tSYSu deuser and run the
flatxn_setup1.sql script. This
kiflashback. S sets up the database and the HR user
@ setupisscript
u
for backing out transactionsywith
s t h It also performs four groups of
transactions. Take a M a
few moments e
sto inspect the script before executing it. Note the
ucommands.
i ( t o
ALTER DATABASE
s y uk nse and GRANT

M a sys/oracle
$ sqlplus
l i c e as sysdba
y
nle12:42:43 2007
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12

Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> @flatxn_setup1
SQL> set serveroutput on
SQL> set term on
SQL> set lines 200
SQL> set pause on
SQL>
SQL> /*== Set up the HR database account ==*/

Oracle Database 11g: Administration Workshop II A - 138


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


SQL>
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

COLUMNS;

Database altered.

SQL> GRANT EXECUTE ON dbms_flashback TO hr;

Grant succeeded.

SQL> GRANT select any transaction TO hr;

Grant succeeded.
ble
SQL> pause Press [Enter] to continue... fe r a
an s
- t r
3) Press Enter to continue to the next step in the script. The script connects to the
n
no
database as HR user and creates the first test transaction, which consists of inserting
a
five rows.
a s
) h i d eฺ
Press [Enter] to continue... m
co nt Gu
SQL>
i l ฺ
a de transaction ==*/
g m
SQL> /*== Create test data for flashback
tu
SQL> connect hr/hr
i @ S
Connected.
s y uk this
SQL>
SQL> /*== Test(M
a use1 ==*/
u kINTO e to
i hr.regions
transaction
SQL> INSERT
s y n s VALUES (10,'Pole');

Macreated.
1yrow lice
nle
Sta SQL> INSERT INTO hr.regions VALUES (20,'Moon');

1 row created.

SQL> INSERT INTO hr.regions VALUES (30,'Venus');

1 row created.

SQL> INSERT INTO hr.regions VALUES (40,'Mars');

1 row created.

SQL> INSERT INTO hr.regions VALUES (50,'Saturn');

1 row created.

SQL> COMMIT;

Oracle Database 11g: Administration Workshop II A - 139


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


Commit complete.

SQL> pause Press [Enter] to continue...

4) Press Enter to continue to the next step in the script. The script continues to create the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

second test transaction, which consists of updating two rows that you just inserted.
This creates a write-after-write (WAW) dependency. A WAW dependency exists
when a transaction updates or deletes a row that has been inserted or updated by a
dependent transaction.
Press [Enter] to continue...

SQL>
SQL> /*== Test transaction 2 ==*/
SQL> /*== Region 10 and 20 has a WAW dependency on transaction
1 ==*/
SQL> UPDATE hr.regions SET region_name='Two Poles' WHERE ble
region_id = 10;
fe r a
ans
1 row updated.
n - t r
n o
SQL> UPDATE hr.regions SET region_name='Many Moons' WHERE
s a
region_id = 20;
) h a eฺ
m i d
1 row updated. i l ฺ co nt Gu
m a de
SQL> COMMIT;
i @ g S tu
Commit complete. asy
uk this
( M u se
SQL> pauseuk
i e to to continue...
y s
Press [Enter]
as licen to the next step in the script. The script continues to create the
y M
5) Press Enter to continue
nlethird transaction, which consists of updating three rows, one of which was also
Sta updated in the previous transaction. This action creates another WAW dependency.
Press [Enter] to continue...

SQL>
SQL> /*== Test transaction 3 ==*/
SQL> /*== Region 10 has a WAW dependency on transaction 1 and
2 ==*/
SQL> /*== Region 40 and 50 has a WAW dependency on transaction
1 ==*/
SQL> UPDATE hr.regions SET region_name='No star' WHERE
region_id = 10;

1 row updated.

SQL> UPDATE hr.regions SET region_name='Red star' WHERE


region_id = 40;

Oracle Database 11g: Administration Workshop II A - 140


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


1 row updated.

SQL> UPDATE hr.regions SET region_name='Big star' WHERE


region_id = 50;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1 row updated.

SQL> COMMIT;

Commit complete.

SQL> pause Press [Enter] to continue...

6) Press Enter to continue to the next step in the script. The script continues to create a
fourth transaction, which consists of updating a row that was inserted in transaction 1.
This action creates another WAW dependency.
ble
Press [Enter] to continue...
fe r a
ans
SQL>
n - t r
SQL> /*== Test transaction 4 ==*/
a no
SQL> /*== Region 30 has a WAW dependency on transaction 1 ==*/
a s
) h i d eฺ
SQL> UPDATE hr.regions SET region_name='Still called Venus'
WHERE region_id = 30; m
co nt Gu
i l ฺ
1 row updated.
g ma tude
u k i@ is S
sy se th
SQL> COMMIT;

Commit complete.
a
(M to u
k
u nsei
SQL> asy
M i c e [Enter] to continue...
pause lPress
y
SQL>
nle
Sta 7) Press Enter to continue to the next step in the script. Finally, the script connects to the
database as SYS user and switches archive logs. Flashback Transaction requires at
least one archived log to start analyzing redo.
Press [Enter] to continue...

SQL>
SQL> connect / as sysdba
Connected.
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

System altered.

SQL>
SQL> prompt "Setup for Flashback Transaction completed"
"Setup for Flashback Transaction completed"
SQL> pause Press [Enter] to continue...

Oracle Database 11g: Administration Workshop II A - 141


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


8) Press Enter to exit the script.
Press [Enter] to continue...

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Release 11.1.0.6.0 - Production


With the Partitioning, OLAP, Data Mining and Real Application
Testing options

9) A transaction can have a write-after-write (WAW) dependency, which means a


transaction updates or deletes row data that has been inserted or updated by a
previous transaction. In this section, you want to back out a bad transaction, in
addition to its WAW dependents, which also caused incorrect changes. Perform the
following steps:
a) Log in to Enterprise Manager Database Control as the SYS user.
ble
b) You suspect that the HR.REGIONS table contains changes from the bad
fe r a
transaction, and want to view the complete table data. Click the Schema tabbed
ans
page, and then click Tables located under Database Objects.
n - t r
no
c) To view all tables that belong to the HR schema user, enter HR in the Schema field
a
and click the Go button. a s
h
)then select
i d eฺ Data from
d) On the Tables page, select the REGIONS table,oand m G u View
ilฺcthe data
the Actions drop-down list. Click Go toaview
e n t
in the HR.REGIONS table.
e) While viewing the content of the
m
g youSrealize
table,
d
tu that it should not contain the
i @ isVenus” rows. Click OK.
“Many moons” and “Still
s y uk called t h
( M a use
y u ki se to
M as licen
y
nle
Sta
f) Return to the list of tables and select the REGIONS table. Then select Flashback
Transaction from the Actions drop-down list and click Go.
g) Review the query conditions. Specify a time period in which you believe the
faulty changes were made. For this example, accept the default time period and
click Next.
h) On the Flashback Transaction: Select Transaction page, select Transaction ID,
and then click the Transaction ID link of the transaction that updated two regions.

Oracle Database 11g: Administration Workshop II A - 142


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

i) On the Select Transaction: Show Details page, review the erroneous UPDATE
commands and click OK.
j) Click Next to identify any dependent transactions and back out all needed
changes. The Processing: Flashback Transaction window appears. On the
Flashback Transaction: Show Dependencies page, click the first Transaction ID
link. ble
fe r a
s
k) On the Show Dependencies: Details page, review the compensating transactions.
an
- t r
Note that one of the compensating transactions has been executed. It is marked
nno
[exec=yes]. The other one is not executed; it is marked [exec=no]. Click
a
OK.
a s
l) On the Flashback Transaction: Show Dependencies
h
)page, click
i d eฺ Change
the
m
co nt Gu
Recovery Option button. i l ฺ
a Option
m) On the Show Dependencies: Change g mRecovery t u de page, select Cascade,
S transaction changes, and click
i@ isdependent
which will also back out thekerroneous
OK.
u
sy se t h
a u Show Dependencies page, click Next.
(MTransaction:
n) On the Flashback
k i t o
a
o) Click stheyuShow e n seSQL Script button.
Undo
M lic
p)y On the Review: Show Undo SQL page, review all compensating UPDATE
n l e
Sta commands, and then click OK.
q) Enter the following command in the Execute SQL region, and click the Execute
SQL button, to preview the result that the compensating undo statements produce:
SELECT * FROM HR.REGIONS

r) Note that the “Many Moons” row disappeared from the result list. Click OK.
s) On the Flashback Transaction: Review page, click Finish.
t) The Flashback Transaction executed successfully. Click OK.
u) Go back and view the contents of the HR.REGIONS table. Return to the Tables
page. Specify HR as the Schema, click Go, select the REGIONS table, and then
select View Data from the Actions drop-down list and click Go.

Oracle Database 11g: Administration Workshop II A - 143


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


v) The content of the table is the same as displayed four steps above. Transactions 2
and 3 are backed out, but transaction 4 remains (the region name is set to “Still
called Venus”) because there is no WAW dependency between transactions
2 and 4.
w) Log out of EM.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

10) Clean your environment by performing the following steps: From a SQL*Plus session
connected as the SYS user, execute the flatxn_cleanup.sql script.
$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12


12:45:52 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

ble
Connected to:
fe r a
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
ans
Production
n - t r
Testing options a no
With the Partitioning, OLAP, Data Mining and Real Application

a s
) h i d eฺ
m
co nt Gu
SQL>
i l ฺ
SQL> @flatxn_cleanup.sql
g ma tude
SQL> set serveroutput on
u k i@ is S
SQL> set term on
SQL> set lines 200 sy
a e th
SQL> set pause(M
i on
t o us
SQL>
s y uk / nassesysdba
a lice
SQL> connect
M
y
Connected.
nleSQL>
Sta SQL> DELETE FROM hr.regions WHERE region_id=10;

1 row deleted.

SQL> DELETE FROM hr.regions WHERE region_id=20;

1 row deleted.

SQL> DELETE FROM hr.regions WHERE region_id=30;

1 row deleted.

SQL> DELETE FROM hr.regions WHERE region_id=40;

1 row deleted.

SQL> DELETE FROM hr.regions WHERE region_id=50;

Oracle Database 11g: Administration Workshop II A - 144


Computer Pride Limited

Practice 11-2: Flashback Transaction Backout (continued)


1 row deleted.

SQL> COMMIT;

Commit complete.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL>
SQL> ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY)
COLUMNS;

Database altered.

SQL> ALTER DATABASE DROP SUPPLEMENTAL LOG DATA;

Database altered.

ble
SQL> REVOKE EXECUTE ON dbms_flashback FROM hr;
fe r a
Revoke succeeded. ans
n - t r
SQL> REVOKE select any transaction FROM hr;
a no
a s
Revoke succeeded. ) h i d eฺ
m
co nt Gu
i l ฺ
ma tude
SQL>
SQL> exit
g
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 145


Computer Pride Limited

Practices for Lesson 12


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

These practices cover the use of Flashback Database and Flashback Data Archive.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 146


Computer Pride Limited

Practice 12-1: Flashback Database


Background: In this scenario, the HR reorganization job runs prematurely, and you must
undo its changes. The changes are such that you are not sure what tables are involved. So,
you decide (now that flashback logging has been enabled) to use Flashback Database
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

instead of performing a recovery. Unless specified otherwise, you should log in as the SYS
user as SYSDBA through SQL*Plus or Database Control.
1) Using Enterprise Manager, turn on flashback logging for your database (enable
Flashback Database).

a. In Database Control, click the Availability tab, and then the Recovery Settings
link in the Backup/Recovery Setup region.

b. Scroll down and select the Enable Flashback Database check box. Click Apply.
On the Confirmation page, click Yes to proceed with the database shutdown.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
c. Entersthe
a n se using oracle/oracle and click OK.
yuhost ecredentials
M lic
d.y Click Yes on the Restart Database: Confirmation page.
n l e
Sta e. Click Refresh and wait for the database to restart. You may need to click Refresh
several times.

f. When the Login screen appears, log in as SYS AS SYSDBA.

2. After the database has been restarted with flashback logging enabled, note the current
SCN of the database by querying the V$DATABASE view.

Note: You will need this later.

Current SCN: ________________

a. Enter the following:


$ cd $HOME/labs
$ sqlplus / as sysdba

Oracle Database 11g: Administration Workshop II A - 147


Computer Pride Limited

Practice 12-1: Flashback Database (continued)


SQL> SELECT current_scn FROM v$database;

CURRENT_SCN
-----------
712863
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

3. Note the sum of the salaries in the HR.EMPLOYEES table and the count of the rows
in the JOB_HISTORY table.
SQL> SELECT SUM(salary) FROM hr.employees;

SUM(SALARY)
-----------
691400
SQL> SELECT COUNT(*) FROM hr.job_history;

ble
COUNT(*)
fe r a
----------
ans
10
n - t r
a no
h a
4. Run the flb_db_txn.sql script to perform some HR reorganization s ฺ updates as
was run in the practice for the lesson titled “Database )
Recovery.”id e
o m G u
a. Enter the following at the SQL prompt:ai
lฺc ent
g m tud
SQL> @flb_db_txn.sql k i @ i s S
s y u t h
a u s e
k i (M of that
Following is the output
t o command:

s yu ense
SQL> @flb_db_txn.sql
a
y Mupdatelicemployees set department_id = 90 where job_id =
SQL>
l e
SQL>
n 'IT_PROG';
Sta
5 rows updated.

SQL>
SQL> update employees e set salary = least(e.salary,(select
(min_salary + max_salary)/2 * 1.10 from jobs j where j.job_id
= e.job_id)) where job_id not like 'AD_%';

103 rows updated.

SQL>
SQL> commit;

Commit complete.

SQL>

Oracle Database 11g: Administration Workshop II A - 148


Computer Pride Limited

Practice 12-1: Flashback Database (continued)


5. Note the current SCN in the database again, and also the salary sum and the
JOB_HISTORY row count. If you are not connected as the SYS user, do that first.
Note that these values are different from what was queried in steps 2 and 3.
SQL> connect / as sysdba
Connected.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> SELECT current_scn FROM v$database;

CURRENT_SCN
-----------
716681

SQL> SELECT SUM(salary) FROM hr.employees;

SUM(SALARY)
-----------
679050
ble
SQL> SELECT COUNT(*) FROM hr.job_history; fe r a
ans
COUNT(*) n - t r
----------
a no
15
a s
) h i d eฺ
SQL> m
co nt Gu
i l
a SCN ฺ
6. Using RMAN, flash back the databasegtom the firsttu devalue noted in step 2.
u k i@ is S
a. Shut down and then mount
a e th by entering the following:
sy thesdatabase
M to u
SQL> SHUTDOWNi (IMMEDIATE
k
syu cMOUNT
SQL> STARTUP
a e nse
M li
b.y Go to the RMAN session in another Xterm window, and exit the current RMAN
n l e
Sta session there. Then log in to RMAN again.
$ rman target / NOCATALOG

c. At the RMAN prompt, enter the FLASHBACK DATABASE command, and supply
the SCN number recorded in step 2:
RMAN> FLASHBACK DATABASE TO SCN=712863;

Following is the output of this command:


RMAN> FLASHBACK DATABASE TO SCN=712863;

Starting flashback at 25-JUL-07


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=149 device type=DISK

Oracle Database 11g: Administration Workshop II A - 149


Computer Pride Limited

Practice 12-1: Flashback Database (continued)


starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished flashback at 25-JUL-07

RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

7. Before opening the database for read/write, verify that the database was flashed back
to the correct SCN by looking at the contents of the tables and seeing that they are
back to what was noted in step 3.

a. Enter the following at the SQL prompt to open the database in read-only mode:
$ sqlplus / as sysdba
SQL> alter database open read only;

b. Enter the following at the SQL prompt to determine the salary sum for the
ble
EMPLOYEES table.
fe r a
ans
SQL> SELECT SUM(salary) FROM hr.employees;
n - t r
SUM(SALARY)
a no
a s
eฺ
-----------
691400 ) h i d
c m
o t Gu
i l ฺ n RESETLOGS keyword.
ma totuuse
8. Open the database for read/write use. You have
g dethe
a. Shut down the database by k
entering
S at the SQL prompt:
i@ theisfollowing
u
sy se t h
a
(M to u
SQL> shutdown immediate
k
Database closed.
u nse i
Database
a s ydismounted.
e shut down.
M
ORACLE
y l i
instance c
nle
Sta b. Enter the following at the SQL prompt to start up the database in the MOUNT
state.
SQL> startup mount
ORACLE instance started.

Total System Global Area 573325312 bytes


Fixed Size 1301368 bytes
Variable Size 444597384 bytes
Database Buffers 121634816 bytes
Redo Buffers 5791744 bytes
Database mounted.

c. Enter the following at the SQL prompt to open the database in read/write mode:
SQL> alter database open resetlogs;

Database altered.

Oracle Database 11g: Administration Workshop II A - 150


Computer Pride Limited

Practice 12-1: Flashback Database (continued)


9. At this point you can familiarize yourself with the flashback-related dynamic views.
To see time values, alter your session to display hours, minutes, and seconds with any
date values.
SQL> ALTER SESSION SET NLS_DATE_FORMAT=”yyyy-mm-dd
hh24:mi:ss”;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

10. Query the V$FLASHBACK_DATABASE_LOG view and determine the lowest SCN
that the database can be flashed back to. Record your answer here: _____________
SQL> set wrap off
SQL> select * from v$FLASHBACK_DATABASE_LOG;
truncating (as requested) before column
ESTIMATED_FLASHBACK_SIZE

OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI RETENTION_TARGET


ble
FLASHBACK_SIZE
-------------------- ------------------- ---------------- ---- fe r a
ans
----------
712309 2007-07-25 11:07:20 1440 n - t r
8192000
a no
a s
) h i d eฺ
11. View the overhead associated with flashback logging
c m G u operations by
o andtrelated
i l ฺ Whateisnthe average number of bytes
querying V$FLASHBACK_DATABASE_STAT.
g mathis ttime
of flashback data written per minute during udinterval?
@
ki this S
s y u
SQL> select * from V$FLASHBACK_DATABASE_STAT;
M a
truncating (as requested)
( u sebefore column
y u ki se to
ESTIMATED_FLASHBACK_SIZE

M as licen END_TIME
BEGIN_TIME FLASHBACK_DATA
le y
DB_DATA REDO_DATA

Stan ------------------- ------------------- -------------- -------


--- ----------
2007-07-25 12:00:46 2007-07-25 12:04:30 3014656
303104 895488 0

SQL>

In the example above, the answer is 3014656/(12:04 – 12:00), which is


753664 bytes per minute. Your numbers may vary slightly.

12. Determine the current size of stored flashback data by querying


V$FLASHBACK_DATABASE_LOG. Record your answer here: _____________.
SQL> SELECT flashback_size FROM V$FLASHBACK_DATABASE_LOG;

FLASHBACK_SIZE
--------------

Oracle Database 11g: Administration Workshop II A - 151


Computer Pride Limited

Practice 12-1: Flashback Database (continued)


16384000

Note: Your results will probably vary slightly from those shown here.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 152


Computer Pride Limited

Practice 12-2: Using Flashback Data Archive


In this practice, you use Flashback Data Archive.
1) Using SQL*Plus, connect to the database as the SYS user and run the
flada_setup.sql script from the $HOME/labs directory. The setup script
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

creates a second undo tablespace, a small FLA_TBS1 tablespace, and the


ARCHIVE_ADMIN user with the ARCHIVE_ADMIN password and unlocks the HR
user with the HR password. The password is case-sensitive by default. Take a few
moments to inspect the script before executing it.
$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12


12:05:56 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.


ble
fe r a
Connected to:
ans
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
n - t r
Production
a no
s
With the Partitioning, OLAP, Data Mining and Real Application
a
Testing options
) h i d eฺ
m
co nt Gu
SQL> @flada_setup.sql
i
a del ฺ
Connected.
g m tu
SQL> set serveroutput on
SQL> -- set verify on uk i @ is S
SQL> set term on asy t h
SQL> set lines(M u se
ki 44se to
200
y u
SQL> set pages
s pause non
M a
SQL> set
l i c e
l e y
SQL>
n SQL> /*== Create a tablespace for your flashback data archive
Sta ==*/
SQL> DROP TABLESPACE fla_tbs1 INCLUDING CONTENTS
2 /
DROP TABLESPACE fla_tbs1 INCLUDING CONTENTS
*
ERROR at line 1:
ORA-00959: tablespace 'FLA_TBS1' does not exist

SQL> CREATE SMALLFILE TABLESPACE fla_tbs1


2 DATAFILE '/u01/app/oracle/oradata/orcl/fla_tbs01.dbf'
3 SIZE 10M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 32767M
4 NOLOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE
MANAGEMENT AUTO
5 /
Tablespace created.
ALTER USER hr IDENTIFIED BY "HR" ACCOUNT UNLOCK
SQL> pause Press [Enter] to continue...

Oracle Database 11g: Administration Workshop II A - 153


Computer Pride Limited

Press [Enter] to continue...

SQL>
SQL> /*== Create a second undo tablespace for testing ==*/
SQL> DROP TABLESPACE undotbs2 INCLUDING CONTENTS
2 /
DROP TABLESPACE undotbs2 INCLUDING CONTENTS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

*
ERROR at line 1:
ORA-00959: tablespace 'UNDOTBS2' does not exist

SQL> CREATE SMALLFILE UNDO TABLESPACE undotbs2


2 DATAFILE '/u01/app/oracle/oradata/orcl/undotbs02.dbf'
3 SIZE 105M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 32767M
4 /

Tablespace created.

ble
SQL> pause Press [Enter] to continue...
Press [Enter] to continue... fe r a
t r a ns
SQL> /*== Set up the HR database account for this lesson
o n - ==*/
system privilege. ==*/SQL> s an
SQL> /*== Note: The HR user has the UNLIMITED TABLESPACE

SQL> ALTER USER hr IDENTIFIED BY "HR" ACCOUNT


) ha UNLOCK
i d eฺ
2 / m
co nt Gu
i l ฺ
User altered.
g ma tude
u k i@ is Suser like the HR user ==*/
SQL> /*== with aFLA_TBS1
th tablespace ==*/
sy sedefault
SQL> /*== Create an ARCHIVE_ADMIN

i
SQL> CREATE USER
t u
(MARCHIVE_ADMIN
o PROFILE DEFAULT IDENTIFIED BY
u k e
ARCHIVE_ADMIN
a e ns
sy cTABLESPACE
y
2 DEFAULT
M l i FLA_TBS1 TEMPORARY TABLESPACE TEMP

nle
3 ACCOUNT UNLOCK;

Sta User created.

SQL> pause Press [Enter] to continue...


Press [Enter] to continue...

SQL> GRANT ALTER SESSION TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT CREATE DATABASE LINK TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT CREATE SEQUENCE TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT CREATE SESSION TO ARCHIVE_ADMIN;


Grant succeeded.

Oracle Database 11g: Administration Workshop II A - 154


Computer Pride Limited

SQL> GRANT CREATE SYNONYM TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT CREATE VIEW TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT UNLIMITED TABLESPACE TO ARCHIVE_ADMIN;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Grant succeeded.

SQL> GRANT EXECUTE ON SYS.DBMS_STATS TO ARCHIVE_ADMIN;


Grant succeeded.

SQL> GRANT CONNECT, RESOURCE TO ARCHIVE_ADMIN;


Grant succeeded.

SQL>
SQL> /*== Setup for Flashback Data Archive completed ==*/
SQL> /*== The ARCHIVE_ADMIN user has the password:
ble
ARCHIVE_ADMIN ==*/
SQL> /*== The HR user has the password: HR ==*/ fe r a
SQL>
ans
SQL> pause Press [Enter] to continue...
n - t r
Press [Enter] to continue...
a no
a s
SQL>
) h i d eฺ
m
coprivileges
G u
2) To give the ARCHIVE_ADMIN user administrative
i l ฺ t for creating,
maintaining, and dropping flashback data
g
a dexecute
marchives, u en the following command
as the SYS user:
k i @ is St
GRANT FLASHBACK ARCHIVE
a syu seADMINISTER
th TO archive_admin;
$ sqlplus / as(M sysdbao u
k i
SQL> GRANTuFLASHBACK e t ARCHIVE ADMINISTER TO archive_admin;
a y
s cen s
M
y succeeded.
Grant li
n l e
Sta SQL> exit

3) In SQL*Plus, connect as the ARCHIVE_ADMIN user with the ARCHIVE_ADMIN


password.
Note: The password needs to be in uppercase; the username is not case-sensitive.
$ sqlplus archive_admin/ARCHIVE_ADMIN

SQL>

4) To create a flashback data archive, execute the following command:


CREATE FLASHBACK ARCHIVE fla1
TABLESPACE fla_tbs1
QUOTA 10M
RETENTION 1 YEAR
/
SQL> CREATE FLASHBACK ARCHIVE fla1

Oracle Database 11g: Administration Workshop II A - 155


Computer Pride Limited

TABLESPACE fla_tbs1
QUOTA 10M
RETENTION 1 YEAR
/ 2 3 4 5

Flashback archive created.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL>

5) Give the privilege to use the FLA1 archive to the HR user, by executing the following
command:
GRANT FLASHBACK ARCHIVE on FLA1 to HR;

SQL> GRANT FLASHBACK ARCHIVE on FLA1 to HR;

Grant succeeded.

ble
SQL>
fe r a
ans
6) You now switch to the role of a flashback archive user. Connect as the HR user with
- t r
the HR password. To enable this flashback data archive for the EMPLOYEES table,
n
execute the following command:
a no
ALTER TABLE hr.employees FLASHBACK ARCHIVE fla1; a s
) h i d eฺ
SQL> connect HR/HR m
co nt Gu
Connected. i l ฺ
a deARCHIVE fla1;
SQL> ALTER TABLE hr.employeesm FLASHBACK
i @ g S tu
Table altered.
s y uk this
( M a use
SQL> exit
y u ki se to
s increase
7) To viewaand
c e nthe salary of Mr. Fox three times by 1000, execute the
y M l
flada_dml.sql i script. This produces activity in the flashback data archive.
n l e
Sta $ sqlplus / as sysdba
SQL> @flada_dml
SQL> REM "********************************************** "
SQL> REM "For demo purposes ONLY: Flashback Data Archive "
SQL>
SQL> connect hr/HR
Connected.
SQL>
SQL> set echo on
SQL> set serveroutput on
SQL> -- set verify on
SQL> set term on
SQL> set lines 200
SQL> set pages 44
SQL> set pause on pause "Press [Enter] to continue..."
SQL>
SQL> /*== Query the current salary for Mr. Fox ==*/

Oracle Database 11g: Administration Workshop II A - 156


Computer Pride Limited

SQL>
SQL> SELECT employee_id, last_name, salary
2 FROM hr.employees
3 WHERE last_name = 'Fox'
4 /
Press [Enter] to continue...
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

EMPLOYEE_ID LAST_NAME SALARY


----------- ------------------------- ----------
170 Fox 9600

1 row selected.

SQL>
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL>
ble
SQL>
SQL>
/*== Increase the salary three times by 1000 ==*/
fe r a
SQL> UPDATE hr.employees
ans
2 SET salary = salary + 1000
n - t r
3 WHERE last_name = 'Fox'
a no
4 /
a s
) h i d eฺ
1 row updated. m
co nt Gu
i l ฺ
SQL> COMMIT
g ma tude
2 /
u k i@ is S
Commit complete. as
y e th
i ( M to us
y
SQL> UPDATE
s ukhr.employees
n sesalary + 1000
a
2 SET
ic e
salary =
l e y3MWHERE llast_name = 'Fox'
n
Sta
4 /

1 row updated.

SQL> COMMIT
2 /

Commit complete.

SQL> UPDATE hr.employees


2 SET salary = salary + 1000
3 WHERE last_name = 'Fox'
4 /

1 row updated.

SQL> COMMIT
2 /

Oracle Database 11g: Administration Workshop II A - 157


Computer Pride Limited

Commit complete.

SQL> pause Press [Enter] to continue...


Press [Enter] to continue...

SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> /*== Query the up-to-date value for Mr. Fox ==*/
SQL>
SQL> SELECT employee_id, last_name, salary
2 FROM hr.employees
3 WHERE last_name = 'Fox'
4 /
Press [Enter] to continue...

EMPLOYEE_ID LAST_NAME SALARY


----------- ------------------------- ----------
170 Fox 12600
ble
1 row selected. fe r a
an s
SQL>
n - t r
SQL> pause Press [Enter] to continue...
a no
Press [Enter] to continue...
a s
) h i d eฺ
SQL> m
co nt Gu
SQL> set pause off i l ฺ
SQL> set feedback on
g ma tude
SQL>
u k i@ is S
8) To query the internal name
a e th table, execute the following command:
syof the sarchive
M to u
SELECT * FROMi (USER_FLASHBACK_ARCHIVE_TABLES;
k
a
SQL> SELECT nseUSER_FLASHBACK_ARCHIVE_TABLES;
syu c* eFROM
y M li
l e
n TABLE_NAME
Sta
OWNER_NAME
------------------------------ ------------------------------
FLASHBACK_ARCHIVE_NAME
--------------------------------------------------------------
ARCHIVE_TABLE_NAME
-----------------------------------------------------
EMPLOYEES HR
FLA1

SYS_FBA_HIST_70271

1 row selected.

SQL>

Oracle Database 11g: Administration Workshop II A - 158


Computer Pride Limited

9) To ensure that the following queries use the archive tables, and not the undo, switch
the undo tablespaces and drop the old one. As a SYS user, assign UNDOTBS2 as the
current undo tablespace, by using Enterprise Manager > Server> Automatic Undo
Management > “Change Tablespace” button, selecting the UNDOTBS2 tablespace,
and clicking OK, or by executing the following commands:
connect / as sysdba
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2;


DROP TABLESPACE UNDOTBS1;
SQL> connect / as sysdba
Connected.

SQL> ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2;


System altered.

SQL> DROP TABLESPACE UNDOTBS1;


Tablespace dropped. ble
fe r a
Note: If you execute the DROP command too quickly, while internal processing still
ans
t r
occurs, you might receive an ORA-30013 error. Wait several minutes and try again.
n -
no
10) As the HR user, choose a time after the creation of the flashback data archive and
a
a s
before you executed the erroneous DML. To view Mr. Fox’s employee record as of
) h i d eฺ
that time, execute the following query (replace '10' MINUTE with your chosen
m
co nt Gu
i l ฺ
historic date, format examples: '50' SECOND, '10' DAY, '5' MONTH):
ma tude
Note: You receive an ORA-1466 error, if the time you specify a time before the
g
u k i@ is S
flashback data archive was started. Reduce the time to a smaller interval and try
sy se th
again. If you still see the salary of 12600, increase your time interval.
a
i o u
(M tlast_name,
k
u nse AS OF TIMESTAMP
SELECT employee_id,
y salary
FROM s
a (SYSTIMESTAMP
e
hr.employees
c
y M l i - INTERVAL '10' MINUTE)
n l e
WHERE last_name = 'Fox';
Sta SQL> connect hr/HR
Connected.
SQL> SELECT employee_id, last_name, salary
2 FROM hr.employees AS OF TIMESTAMP
3 (SYSTIMESTAMP - INTERVAL '10' MINUTE)
4 WHERE last_name = 'Fox';

EMPLOYEE_ID LAST_NAME SALARY


----------- ------------------------- ----------
170 Fox 9600
1 row selected.
SQL>

Oracle Database 11g: Administration Workshop II A - 159


Computer Pride Limited

11) As the HR user, you realize that the recent updates were mistakes. To revert to the
original values for your chosen historic date (for example, ten minutes ago), execute
the following command (replace '10' MINUTE with your chosen historic date):
UPDATE hr.employees
SET salary = (SELECT salary FROM hr.employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '10' MINUTE)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

WHERE last_name = 'Fox')


WHERE last_name = 'Fox';
SQL> UPDATE hr.employees
2 SET salary = (SELECT salary FROM hr.employees
3 AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '10' MINUTE)
4 WHERE last_name = 'Fox')
5 WHERE last_name = 'Fox';

1 row updated.

SQL>
ble
12) From your SQL*Plus session, connect to the database as the SYS user and list the
fe r a
data dictionary views available to you. Execute the flada_list1.sql file: ans
n - t r
SQL> connect / as sysdba
a no
Connected.
a s
SQL> @flada_list1
) h i d eฺ
m
co nt Gu
SQL> REM "******************************************* "
i l ฺ
SQL> REM "For demo purposes ONLY:"
SQL>
g ma tude
u k i@ is S
SQL> connect / as sysdba

sy se th
Connected.
SQL>
a
(M to u
i
SQL> set echo on
k
syu cense
SQL> set serveroutput on
a
SQL> -- set verify on
li
le yM
SQL> set term on
n SQL> set lines 200
Sta SQL> set pages 44
SQL> set pause on pause "Press [Enter] to continue ..."
SQL>
SQL> /*== To list the available data dictioary views ==*/
SQL>
SQL> SELECT table_name
2 FROM dict
3 WHERE table_name LIKE '%FLASHBACK_ARCHIVE%'
4 /
Press [Enter] to continue ...

TABLE_NAME
------------------------------
DBA_FLASHBACK_ARCHIVE
DBA_FLASHBACK_ARCHIVE_TABLES
DBA_FLASHBACK_ARCHIVE_TS
USER_FLASHBACK_ARCHIVE

Oracle Database 11g: Administration Workshop II A - 160


Computer Pride Limited

USER_FLASHBACK_ARCHIVE_TABLES

SQL> pause Press [Enter] to continue ...


Press [Enter] to continue ...

SQL>
SQL> col FLASHBACK_ARCHIVE_NAME format A25
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> col ARCHIVE_TABLE_NAME format A20


SQL> col TABLE_NAME format A12
SQL> col OWNER_NAME format A10
SQL>
SQL> DESC dba_flashback_archive
Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
ble
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255) fe r a
FLASHBACK_ARCHIVE#
ans
NOT NULL NUMBER
n - t r
RETENTION_IN_DAYS
a no
NOT NULL NUMBER
a s
CREATE_TIME
) h i d eฺ
TIMESTAMP(9) m
co nt Gu
LAST_PURGE_TIME i l ฺ
TIMESTAMP(9)
g ma tude
STATUS
u k i@ is S
VARCHAR2(7)
a sy se th
i
SQL> pause Press(M[Enter]
t o u to continue ...
k e
a syu cetonscontinue
Press [Enter] ...

yM li
l e
SQL>
n SQL> /*== To query the time when the flashback data archive(s)
Sta have been created ==*/
SQL>
SQL> SELECT flashback_archive_name, create_time, status
2 FROM dba_flashback_archive
3 /
Press [Enter] to continue ...

FLASHBACK_ARCHIVE_NAME CREATE_TIME
STATUS
------------------------- ------------------------------------
--------------------------------------- -------
FLA1 25-JUL-07 02.35.23.000000000 PM

SQL> pause Press [Enter] to continue ...


Press [Enter] to continue ...

SQL>

Oracle Database 11g: Administration Workshop II A - 161


Computer Pride Limited

SQL> DESC dba_flashback_archive_ts


Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)
FLASHBACK_ARCHIVE#
NOT NULL NUMBER
TABLESPACE_NAME
NOT NULL VARCHAR2(30)
QUOTA_IN_MB
VARCHAR2(40)

SQL> pause Press [Enter] to continue ...


Press [Enter] to continue ...
ble
SQL> fe r a
SQL> /*== To list the tablespace(s), which are used for
ans
flashback data archives ==*/
n - t r
SQL>
a no
SQL> SELECT *
a s
2 FROM dba_flashback_archive_ts
) h i d eฺ
3 / m
co nt Gu
Press [Enter] to continue ... i l ฺ
g ma tude
FLASHBACK_ARCHIVE_NAME i@
k i s S
FLASHBACK_ARCHIVE# TABLESPACE_NAME
QUOTA_IN_MB u t h
sy se------------------
a
-------------------------
M to u -----------------
-------------i (----------------------------------------
FLA1
s y uk nse 1 FLA_TBS1
10 a lic e
l e yM
n SQL> pause Press [Enter] to continue ...
Sta Press [Enter] to continue ...

SQL>
SQL> DESC dba_flashback_archive_tables
Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
TABLE_NAME
NOT NULL VARCHAR2(30)
OWNER_NAME
NOT NULL VARCHAR2(30)
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)

Oracle Database 11g: Administration Workshop II A - 162


Computer Pride Limited

ARCHIVE_TABLE_NAME
VARCHAR2(53)

SQL> pause Press [Enter] to continue ...


Press [Enter] to continue ...

SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> /*== Query the table name(s), the owner name(s), and ==*/
SQL> /*== the internal "history" table name(s) of the
flashback data archive ==*/
SQL>
SQL> SELECT *
2 FROM dba_flashback_archive_tables
3 /
Press [Enter] to continue ...

TABLE_NAME OWNER_NAME FLASHBACK_ARCHIVE_NAME ARCHIVE_TABLE_NAME


----------- ---------- ---------------------- ------------------
EMPLOYEES HR FLA1 SYS_FBA_HIST_70272
ble
fe r a
SQL>
ans
SQL> pause Press [Enter] to continue ...
n - t r
Press [Enter] to continue ...
a no
a s
SQL> clear columns
) h i d eฺ
SQL> m
co nt Gu
SQL> connect hr/HR
i
a del ฺ
Connected.
g m tu
SQL>
SQL> SELECT table_nameuk i @ is S
dict sy t h
2 FROM
( M se '%FLASHBACK_ARCHIVE%'
a uLIKE
ki se to
3 WHERE table_name
4 /
y u
s ceton continue ...
Press a[Enter]
y M li
l e
n TABLE_NAME
Sta ------------------------------
USER_FLASHBACK_ARCHIVE
USER_FLASHBACK_ARCHIVE_TABLES

SQL> pause Press [Enter] to continue ...


Press [Enter] to continue ...

SQL> exit

13) To practice additional flashback data archive maintenance tasks, perform the
following steps: Using SQL*Plus, connect to the database as the ARCHIVE_ADMIN
user.
$ sqlplus ARCHIVE_ADMIN/ARCHIVE_ADMIN

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12


12:33:28 2007

Oracle Database 11g: Administration Workshop II A - 163


Computer Pride Limited

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

With the Partitioning, OLAP, Data Mining and Real Application


Testing options

SQL>

14) Data in the flashback data archive is automatically purged when the retention time
expires. However, you can also purge data explicitly with the following command to
purge data older than two minutes:
ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE TIMESTAMP (SYSTIMESTAMP -
INTERVAL '2' MINUTE);
ble
SQL> ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE fe r a
TIMESTAMP(SYSTIMESTAMP - INTERVAL '2' MINUTE); ans
n - t r
Flashback archive altered.
a no
a s
SQL>
) h i d eฺ
m
cano additional
G u10 MB tablespace as
l
15) Execute the flada_tbs2.sql script to create
i ฺ t
the SYS user.
g ma tuden
u k i@ is S
sy se th
SQL> @flada_tbs2
Connected.
a
(M ontoonu
SQL> set serveroutput
SQL> -- set k i
u onnse
verify
a
SQL> setsyterm c e 200
M l
y set pages 44
SQL> set lines i
n l eSQL>
Sta SQL> set pause on
SQL>
SQL> /*== Create another tablespace ==*/
SQL>
SQL> DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
2 /
DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
*
ERROR at line 1:
ORA-00959: tablespace 'FLA_TBS2' does not exist

SQL>
SQL> CREATE SMALLFILE TABLESPACE fla_tbs2
2 DATAFILE '/u01/app/oracle/oradata/orcl/fla_tbs02.dbf'
3 SIZE 10M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 32767M

Oracle Database 11g: Administration Workshop II A - 164


Computer Pride Limited

4 NOLOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE


MANAGEMENT AUTO
5 /

Tablespace created.

SQL> pause Press [Enter] to continue...


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Press [Enter] to continue...

SQL>

16) As the ARCHIVE_ADMIN user, add 5 MB of the FLA_TBS2 tablespace to the FLA1
flashback data archive.
SQL> connect ARCHIVE_ADMIN/ARCHIVE_ADMIN
Connected.
SQL> ALTER FLASHBACK ARCHIVE fla1 ADD TABLESPACE fla_tbs2
QUOTA 5M;
ble
Flashback archive altered.
fe r a
ans
SQL>
n - t r
no
17) All tables in one specific flashback data archive have the same retention time. Change
a
a s
the retention time of the FLA1 flashback data archive to two years.
) h i d eฺ
SQL> ALTER FLASHBACK ARCHIVE fla1 MODIFY m Gu 2 YEAR;
co nRETENTION
i
a del ฺ t
Flashback archive altered. gm
i @ S tu
SQL>
s y uk this
( M a user,udropse the FLA1 flashback data archive.
18) As the ARCHIVE_ADMIN
u kai flashback
e todata archive includes dropping the internal tamper-
y
Note: Dropping
s table.
ahistory s
enYou cannot drop this table directly due to auditing and security
proofed
y M l i c
n l erequirements. Dropping a flashback data archive does not drop the tablespaces in
Sta which they are stored, because the tablespaces might contain other data.
SQL> DROP FLASHBACK ARCHIVE fla1;

Flashback archive dropped.


SQL>

19) Wait a minute or two and connect as SYS user; clean up your environment by
executing the flada_cleanup.sql script.
SQL> @flada_cleanup
SQL> REM Execute this script script for training purposes only
SQL> REM Undo Cleanup for Flashback Data Archive
SQL> REM Execute script as SYSDBA
SQL>
SQL> set echo on
SQL> set serveroutput on
SQL> set term on

Oracle Database 11g: Administration Workshop II A - 165


Computer Pride Limited

SQL> set lines 200


SQL> set pause on
SQL>
SQL> connect / as sysdba
Connected.

SQL> CREATE SMALLFILE UNDO TABLESPACE undotbs1


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2 DATAFILE '/u01/app/oracle/oradata/orcl/undotbs01.dbf'
3 SIZE 105M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 32767M
4 /
Tablespace created.

SQL> ALTER SYSTEM SET UNDO_TABLESPACE=undotbs1


2 /
System altered.

SQL> DROP TABLESPACE fla_tbs1 INCLUDING CONTENTS


2 /
ble
Tablespace dropped.
fe r a
SQL> DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
ans
2 /
n - t r
Tablespace dropped.
a no
a s
SQL> ALTER USER hr PASSWORD EXPIRE ACCOUNThLOCK
) i d eฺ
2 / m
co nt Gu
User altered. i l ฺ
g ma tude
SQL> DROP USER archive_admin
k i@ CASCADE
i s S
2 / u
sy se t h
User dropped. a
(M to u
k i
SQL> DROP
2 /as
yuTABLESPACE
e n se undotbs2 INCLUDING CONTENTS
yM ic
ldropped.
n l e
Tablespace

Sta SQL> host rm -f /u01/app/oracle/oradata/orcl/fla_tbs01.dbf


SQL> host rm -f /u01/app/oracle/oradata/orcl/fla_tbs02.dbf
SQL> host rm -f /u01/app/oracle/oradata/orcl/undotbs02.dbf
SQL>
SQL> prompt Flashback Data Archive cleanup complete.
Flashback Data Archive cleanup complete.
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL> exit

Note: If you execute the DROP command too quickly while internal processing is still
occurring, you might receive an ORA-30013 error. Wait and try again.

Oracle Database 11g: Administration Workshop II A - 166


Computer Pride Limited

Practices for Lesson 13

In these practices, you employ various diagnostic capabilities to solve errors.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 167


Computer Pride Limited

Practice 13-1: Diagnostic Scenario


In this practice, you create a data dictionary corruption that you analyze using Support
Workbench and ADRCI.
1) Execute the hm_setup.sh script from the labs subdirectory. This script
corrupts the data dictionary.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ cd $HOME/labs
$ ./hm_setup.sh

sqlplus / as sysdba

SQL*Plus: Release 11.1.0.5.0 - Beta on Thu May 24 05:35:06


2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

ble
fe r a
Connected to:
ans
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta n - t r
With the Partitioning, OLAP and Data Mining options
a no
a s
)
SQL> select object_id from dba_objects where h i d eฺ
owner='SCOTT' and
object_name='TABJMW'; m
co nt Gu
i l ฺ
no rows selected g ma tude
k S
i@ is number)
u
sy se t h
SQL> create table scott.tabjmw(c tablespace users;
a
(M to u
k
Table created.i
a syu cense
li obj number;
y Mvariable
l e
SQL>
n SQL> begin
Sta select object_id into :obj from dba_objects where
owner='SCOTT' and object_name='TABJMW';
end;
/
2 3 4
PL/SQL procedure successfully completed.

SQL> print obj;

OBJ
----------
70975

SQL> update tab$ set cols=1001 where obj#=:obj;

1 row updated.

Oracle Database 11g: Administration Workshop II A - 168


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


commit;

SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Release 11.1.0.5.0 - Beta


With the Partitioning, OLAP and Data Mining options
$
2) Use EM to trigger a health check on the data dictionary.
a) From the Home page (connected as the SYS user), click Advisor Central at the
bottom of the page in the Related Links section.
b) On the Advisor Central page, click the Checkers tab.
c) On the Checker tabbed page, click Dictionary Integrity Check.
ble
d) On the Run Dictionary Integrity Check page, specify a Run Name: DictCheck
fe r a
and click OK.
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
M to theliAdvisor Central Checkers page, you should see a Confirmation
e) Back
y message
n l e indicating that your check ran successfully.
Sta f) Select your DictCheck run and click Details.
g) This takes you to the Run Details Findings tabbed page, where you can see some
Data Corruption. In particular, you should see the following finding: “SQL
dictionary health check: invalid column number 8 on object TAB$ failed.”

Oracle Database 11g: Administration Workshop II A - 169


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

h) This should correspond to a row in TAB$ that references SCOTT.TABJMW.


3) How would you get a report about the previous finding using SQL*Plus?
$ sqlplus / as sysdba
ble
fe r a
SQL*Plus: Release 11.1.0.5.0 - Beta on Thu May 24 05:57:02
ans
2007
n - t r
Copyright (c) 1982, 2007, Oracle. no
All rights reserved.
a
a s
) h i d eฺ
Connected to: m
co Release
G u
Oracle Database 11g Enterprise Edition i l
a den ฺ t 11.1.0.5.0 -
Beta m
gand Data tuMining options
i @ S
uk this
With the Partitioning, OLAP

SQL> set long 100000 s y


a use
i ( M to
y u kdbms_hm.get_run_report('DictCheck')
s e
a s cen
SQL> select from dual;

yM li
l e
DBMS_HM.GET_RUN_REPORT('DICTCHECK')
n --------------------------------------------------------------------
Sta ------------
Basic Run Information
Run Name : DictCheck
Run Id : 381
Check Name : Dictionary Integrity Check
Mode : MANUAL
Status : COMPLETED
Start Time : 2007-07-25 15:16:27.535007 -04:00
End Time : 2007-07-25 15:16:30.929141 -04:00
Error Encountered : 0
Source Incident Id : 0
Number of Incidents Created : 0

DBMS_HM.GET_RUN_REPORT('DICTCHECK')
-------------------------------------------------------------------

Input Paramters for the Run


TABLE_NAME=ALL_CORE_TABLES
CHECK_MASK=ALL

Oracle Database 11g: Administration Workshop II A - 170


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


Run Findings And Recommendations
Finding
Finding Name : Dictionary Inconsistency
Finding ID : 22
Type : FAILURE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Status : OPEN

DBMS_HM.GET_RUN_REPORT('DICTCHECK')
--------------------------------------------------------------------
Priority : CRITICAL
Message : SQL dictionary health check: invalid column number
8 on
object TAB$ failed
Message : Damaged rowid is AAAAACAABAAASpSAAD - description:
Object
SCOTT.TABJMW is referenced


ble
fe r a
SQL>
ans
4) Go back to your EM Home page. What do you observe? n - t r
n o
s a
a) You should see a new critical alert (Data Failure) for the previously detected
corruption in the Alerts section of the Home page. ha ฺ
m ) u i de
o
a ilฺc ent G
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
a s cen
M li pool and buffer cache first, and then exit and reconnect as the SYS
y your shared
5) Flush
l e
n user. From a SQL*Plus session connected as the SYS user, execute the following
Sta statement: select * from scott.tabjmw;
What do you observe?
$ sqlplus / as sysdba
SQL> alter system flush shared_pool;
SQL> alter system flush buffer_cache;
SQL> exit


$ sqlplus / as sysdba

SQL> select * from scott.tabjmw;


select * from scott.tabjmw
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel

Oracle Database 11g: Administration Workshop II A - 171


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


Process ID: 1487
Session ID: 152 Serial number: 2276

SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

6) Use EM to investigate the previous problem.


a) From the EM Home page, you should see one active incident. Click the Active
Incident link. If not, click Software and Support. On the Software and Support
tabbed page, click Support Workbench in the Support section.

ble
b) On the Support Workbench Problems tabbed page, you should see a new Activefe r a
Incident whose description is similar to ORA 7445 [qcstda()+515].
t r a ns
o n -
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
c) Click the “+” icon
( M a
in u secolumn for this problem.
the Details
d) This showsu e to
i the corresponding
kyou first-time incident.
a y
s cen s
e) Click li
y M that incident number.
l e
n f) This takes you to the corresponding Incident Details page. Make a note of the
Sta incident number (26649).

g) Click the incident number. In the Application Information section of that page,
you can clearly see what caused the incident. It was due to "select * from
scott.tabjmw".

Oracle Database 11g: Administration Workshop II A - 172


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

h) You can also see two dump files generated from the Dump Files tabbed page. The
first one corresponds to the incident dump file and is located in the ADR directory
/u01/app/oracle/diag/rdbms/orcl/orcl/incident/incdir_n
nnnn. The second one is the classical corresponding trace file located in
/u01/app/oracle/diag/rdbms/orcl/orcl/trace.
i) Click the eyeglasses icon in the View Contents column for the incident trace (first
row).
j) If you did not save your Host credentials previously, you end up on the Host
ble
Credentials page, where you can enter oracle/oracle and click Continue.
fe r a
k) This brings you to the Contents page, where you can see the structured trace ans
information. n - t r
n o
l) For example, click the “current sql statement” link below s a
the “incident dump”
h
link. This prints the culprit SQL statement in the window
) a below etheฺ Trace Map.
m i d
m) Click OK.
i l ฺ co nt Gu
mathetProblem
n) On the Incident Details page again,gclick u de Key link.
o) On the Problem Details page, k @ EditistoSthe right of the SR field.
iclick
s y u th
p) Enter 1234 in the a
MSR Number e
uspop-up window that appears and click OK. It is
i ( t o
s y uk younalready
assumed that
s e opened an SR (1234) with MetaLink.
M a lice
y
nle
Sta

q) You should now see the SR number on the Problem Details page.
r) Click the Activity Log tab.
s) This takes you to the Activity Log tabbed page, on which you can now see your
last action on the problem. You can enter a comment here.

Oracle Database 11g: Administration Workshop II A - 173


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


7) Back to your terminal window, locate your incident and your health check report in
ADR.
$ cd $ORACLE_BASE/diag/rdbms/orcl/orcl

$ ls
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

alert cdump hm incident incpkg ir lck metadata stage


sweep trace
$ cd incident
$ ls -la
total 12
drwxr-x--- 3 oracle oinstall 4096 Jul 25 15:35 .
drwxr-x--- 13 oracle oinstall 4096 Jul 18 09:15 ..
drwxr-xr-x 2 oracle oinstall 4096 Jul 25 15:35 incdir_26649

$ cd incdir_26649

$ ls ble
fe r a
orcl_ora_1487_i26649.trc
ans
orcl_ora_1487_i26649.trm
n - t r
$ cd ../..
a no
$ ls
a smetadata
alert cdump hm incident incpkg ir lck
) h i d eฺ stage
sweep trace m
co nt Gu
$ cd hm i l ฺ
$ ls
g ma tude
HMREPORT_DictCheck.hm
u k i@ is S
sy se th
$ cd ..
$ a u
(Myour incident
8) Use ADRCI to k i
locate
u nse t o and problem information.
s y
a lice
M
$ adrci
y
nleADRCI: Release 11.1.0.6.0 - Beta on Wed Jul 25 16:03:42 2007
Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.

ADR base = "/u01/app/oracle"

adrci> set homepath diag/rdbms/orcl/orcl

adrci> show homes


ADR Homes:
diag/rdbms/orcl/orcl
adrci> show incidents

ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:


**************************************************************
***********

Oracle Database 11g: Administration Workshop II A - 174


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


INCIDENT_ID PROBLEM_KEY
CREATE_TIME
-------------------- -----------------------------------------
------------------ ----------------------------------------
26649 ORA 7445 [qcstda()+515]
2007-07-25 15:35:35.107020 -04:0021124 ORA 600
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

[bad_table_name] 2007-05-24
01:10:19.684541 -07:00

adrci>

adrci> show problem

ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:


**************************************************************
ble
***********
PROBLEM_ID PROBLEM_KEY fe r a
LAST_INCIDENT LASTINC_TIME ans
-------------------- ----------------------------------------- n - t r
------------------ -------------------- ----------------------
a no
------------------
a s
1 ORA 7445 [qcstda()+515]
) h i d eฺ
26649 2007-07-25 1 m
co nt Gu
i l ฺ
ma tude
5:35:35.107020 -04:00
1 rows fetched
g
u k i@ is S
adrci>
adrci> a sy se th
k i (M to u
s y u nseto package your problem quickly.
9) Use Enterprise Manager
M a the Problem
a) From l i c e Details page, click Quick Package in the Investigate and
y
nle Resolve section.
Sta

b) On the Quick Packaging: Create New Package page, leave the default package
name (something similar to ORA7445qc_20070725160927) and select No in
front of the “Send to Oracle Support” entry.
c) When the page is refreshed, click Next.

Oracle Database 11g: Administration Workshop II A - 175


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


d) On the Quick Packaging: View Contents page, you can see the list of incidents
that are part of this package. There should be only one incident in your case. On
the Quick Packaging: View Contents page, click Next.
e) On the Quick Packaging: View Manifest page, look at the name of the manifest.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

f) Click Next.
g) On the Quick Packaging: Schedule page, make sure Immediately is selected and
click Submit.
h) The Processing: Generating Upload File for Package page appears. Wait until it is
finished.
i) On the Confirmation page, you should see something similar to: "Upload file
for package: ORA7445qc_20070725160927 has been successfully
generated. The upload file is located at
/u01/app/oracle/product/11.1.0/db_1/stc-raclin06
.us.oracle.com_orcl/sysman/emd/state/
ble
ORA7445qc_20070725160927_COM_1.zip. Please send it manually
fe r a
to Oracle."
ans
j) Click OK. n - t r
n o
k) Back to the Problem Details Activity Log tabbed page, you a
should now see two
sfor
h
new entries in the log reporting about the package creation
) a eฺproblem.
this
m i d
l) In the Summary section, click Yes to the right
i l ฺ t Gu entry.
coof thenPackaged
a wheredyou
mfrom e can see your package.
g
m) This takes you to the Packages page,
S t u
n) Select your package, and u k i@
click View.his
a sy sDetails
e t
o) This takes you toM
i ( the Package
t o u page, where you can see the package
details. uk e
a s y e n s
y M lic tab.
p) Click the Files

nleq) On the Files tabbed page, you can now see the Full Package Content view.
Sta 10) Use ADRCI to determine the list of existing packages.
$ adrci

ADRCI: Release 11.1.0.5.0 - Beta on Thu May 24 07:57:13 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

ADR base = "/u01/app/oracle"


adrci> set homepath diag/rdbms/orcl/orcl
adrci> query ips_package

ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:


**************************************************************
***********
PACKAGE_ID FLAGS STATUS
CREATION_TIME LAST_SEQUENCE

Oracle Database 11g: Administration Workshop II A - 176


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


LAST_COMPLETE_SEQUEN PROBLEM_ID NAME
DESCRIPTION
CORRELATION_LEVEL DRIVING_INCIDENT BEGIN_TIME
END_TIME UPDATE_TIME
-------------------- -------------------- --------------------
---------------------------------------- --------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

-------------------- -------------------- --------------------


--------------------------------------------------------------
------------------- ------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
----------- -------------------- -------------------- --------
-------------------------------- -----------------------------
----------- ----------------------------------------
1 0 4
ble
2007-07-25 16:10:53.351235 -04:00
1 1
1
fe r a
ORA7445qc_20070725160927 ans
2 26649 n - t r
2007-07-25 16:10:53.689763 -04:00
a no
a s
adrci> ) h i d eฺ
m u for TABJMW is
o oft columns
cnumber G
11) After analyzing the problem, you know that the
i l ฺ
a anddeclose n your problem. You can
g mTAB$
wrong in TAB$. Fix the issue by updating u
execute hm_fix.sh from the labs
k i i s Stfor that purpose.
@subdirectory
$ $HOME/labs/hm_fix.sh a syu se th
k i (M to u
sy cense
sqlplus / u as sysdba
M a li
l e y
SQL*Plus: Release 11.1.0.5.0 - Beta on Thu May 24 08:16:40

Stan 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
With the Partitioning, OLAP and Data Mining options

SQL> variable obj number;


SQL> begin
select object_id into :obj from dba_objects where
owner='SCOTT' and object_name='TABJMW';
end;
/
2 3 4
PL/SQL procedure successfully completed.

Oracle Database 11g: Administration Workshop II A - 177


Computer Pride Limited

Practice 13-1: Diagnostic Scenario (continued)


SQL> print obj;

OBJ
----------
70975
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> update tab$ set cols=1 where obj#=:obj;

1 row updated.

SQL> commit;

Commit complete.

SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition
ble
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP and Data Mining options fe r a
$ an s
n - t r
12) Use Enterprise Manager to close your incident.
a no
s right ฺof the
a) On the Package Details page, click the “problem” link toathe
h
)
“Problems in Package” field in the Summary section.
m u i de
o your Gincident and click
ilฺc select
b) On the Problem Details Incidents tabbed page,
a n t
Close. g m tude
c) On the Confirmation page,
u k i@Yes. is S
click
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta

Oracle Database 11g: Administration Workshop II A - 178


Computer Pride Limited

Practice 13-2: Repairing Block Corruption

1) To set up this block corruptions practice, use a terminal window, navigate to the
$HOME/labs directory, and execute the block_corrupt.sh script. This script
creates a tablespace called TBSBC and a user called BC. The tablespace is then
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

populated with data from the HR schema. A backup of the new tablespace is
performed, and then a corruption is introduced into the data file. The EMPLOYEES,
DEPARTMENTS, and REGIONS tables are then queried from the BC schema. Take a
few moments to inspect the script actions before executing it.

$ ./block_corrupt.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Aug 27


10:37:34 2007
ble
Copyright (c) 1982, 2007, Oracle. All rights reserved. fe r a
ans
Connected to:
n - t r
no
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
a
Production
a s
) h d
With the Partitioning, OLAP and Data Mining options
i eฺ
m
co nt Gu
SQL> SQL> i l ฺ
Tablespace dropped.
g ma tude
u k i@ is S
sy se th
SQL> SQL>
a
Tablespace created.
(M to u
k i
syu cense
SQL> SQL>
a li
User dropped.
yM
l e
n SQL> SQL>
Sta User created.

SQL> SQL>
Grant succeeded.

SQL> SQL>
Table created.

SQL> SQL>
Table created.

SQL> SQL>
Commit complete.

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Aug


27 10:38:30 2007

Oracle Database 11g: Administration Workshop II A - 179


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1158576740)


using target database control file instead of recovery catalog

backup tablespace tbsbc;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Starting backup at 27-AUG-07


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=149 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007
name=/u01/app/oracle/oradata/orcl/tbsbc12.dbf
channel ORA_DISK_1: starting piece 1 at 27-AUG-07
channel ORA_DISK_1: finished piece 1 at 27-AUG-07
piece
ble
handle=+FRA/orcl/backupset/2007_08_27/nnndf0_tag20070827t10383
6_0.260.631708727 tag=TAG20070827T103836 comment=NONE fe r a
channel ORA_DISK_1: backup set complete, elapsed time: ans
00:00:01 n - t r
Finished backup at 27-AUG-07
a no
a s Enterprise
SQL> SQL> Disconnected from Oracle Database ) h 11g
i d eฺ
Edition Release 11.1.0.6.0 - Production m
coMining G u
i l ฺ t
ma tuden
With the Partitioning, OLAP and Data options
0+1 records in
g
0+1 records out
u k i@ is S
0+1 records in
0+1 records out as
y e th
i ( M to us
ukoutnse
0+1 records in
s y
0+1 records
a lice
y M
l e
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 26
n 14:42:10 2007
Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options

SQL> select * bc.from employees


*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 12)
ORA-01110: data file 7:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf'

Oracle Database 11g: Administration Workshop II A - 180


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


SQL> select * from bc.departments
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 20)
ORA-01110: data file 7:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf'
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> select * from bc.regions


*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 28)
ORA-01110: data file 7:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf'

SQL> Disconnected from Oracle Database 11g Enterprise Edition


ble
Release 11.1.0.6.0 - Production
With the Partitioning, OLAP and Data Mining options fe r a
ans
$ n - t r
a no
a s
) h
2) Use RMAN to back up the TBSBC tablespace. What happens? i d eฺ
m
co nt Gu
i l ฺ
ma tude
$ rman target / nocatalog
RMAN> backup tablespace tbsbc;
g
u k i@ is S
a y
Starting backup at 27-AUG-07
sORA_DISK_1
e th
allocated channel:
i ( M tSID=118
o us device type=DISK
uk nse starting full datafile backup set
channel ORA_DISK_1:
s y
channel ORA_DISK_1:
a ORA_DISK_1:e
M
channel
y l i c specifying datafile(s) in backup set

nlename=/u01/app/oracle/oradata/orcl/tbsbc12.dbf
input datafile file number=00007

Sta channel ORA_DISK_1: starting piece 1 at 27-AUG-07


RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at
08/27/2007 13:21:42
ORA-19566: exceeded limit of 0 corrupt blocks for file
/u01/app/oracle/oradata/orcl/tbsbc12.dbf
RMAN> exit
The backup fails upon encountering the first corrupt block.

Oracle Database 11g: Administration Workshop II A - 181


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


3) Use the RMAN list failure command to provide details about the errors.
$ rman target / nocatalog

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Aug


27 09:49:50 2007
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

connected to target database: ORCL (DBID=1158576740)

RMAN> list failure detail;

RMAN>
List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
1942 HIGH OPEN 2007-10-07:18:47:21 Datafile 3: ble
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' contains one or
fe r a
more corrupt blocks
ans
Impact: Some objects in tablespace TBSBC might be
n - t r
unavailable
a no
s
List of child failures for parent failure ID 1942
a
Failure ID Priority Status
) h
Time Detected
i d eฺSummary
m
co nt Gu
---------- -------- --------- ------------------- -------
1957 HIGH OPEN i l ฺ
2007-10-07:18:47:21 Block 28
ma tude
in datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is
g
media corrupt
u k i@ is S
sy se th
Impact: Object REGIONS owned by BC might be unavailable
1951 a
HIGH
(M to u
OPEN 2007-10-07:18:47:21 Block 20
i
in datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is
k
syu cense
media corrupt
a Impact: Object DEPARTMENTS owned by BC might be
li
le yM
unavailable
n
Sta
1945 HIGH OPEN 2007-10-07:18:47:21 Block 12
in datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is
media corrupt
Impact: Object EMPLOYEES owned by BC might be unavailable

Recovery Manager complete.


RMAN> exit

4) Alternatively, you can query the V$IR_FAILURE view to garner details about the
failure:
$ sqlplus sys/oracle as sysdba
SQL> select failure_id, time_detected, description, impacts
from V$IR_FAILURE where impacts like '%BC%';

SQL>
FAILURE_ID TIME_DETECTED

Oracle Database 11g: Administration Workshop II A - 182


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


---------- -------------------
DESCRIPTION
--------------------------------------------------------------
------------------
IMPACTS
--------------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

------------------
1942 2007-10-07:18:47:21
Datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf'
contains one or more corr
upt blocks
Some objects in tablespace TBSBC might be unavailable

1945 2007-10-07:18:47:21
Block 12 in datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corr

ble
FAILURE_ID TIME_DETECTED
---------- ------------------- fe r a
DESCRIPTION ans
n
-------------------------------------------------------------- - t r
------------------
a no
IMPACTS
a s
) h d eฺ
--------------------------------------------------------------
i
------------------ m
co nt Gu
i l ฺ
ma tude
upt
g
Object EMPLOYEES owned by BC might be unavailable

u k i@ is S
a
Block 20 in datafile sy3: se th
1951 2007-10-07:18:47:21

k i (M to u
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corr
upt u e
y ens owned by BC might be unavailable
Objectas
yM lic
DEPARTMENTS
l e
n FAILURE_ID TIME_DETECTED
Sta ---------- -------------------
DESCRIPTION
--------------------------------------------------------------
------------------
IMPACTS
--------------------------------------------------------------
------------------

1957 2007-10-07:18:47:21
Block 28 in datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corrupt
Object REGIONS owned by BC might be unavailable

SQL> exit

Oracle Database 11g: Administration Workshop II A - 183


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


5) Run the RMAN advise failure all command to view recovery options.
Alternatively, you can query the V$IR_REPAIR view. The V$IR_REPAIR view
lists the results of the RMAN advise failure command. Query this view.
$ rman target / nocatalog
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Recovery Manager: Release 11.1.0.6.0 - Production on Sun Oct 7


20:24:43 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1159023676)


using target database control file instead of recovery catalog

RMAN> advise failure all;

List of Database Failures


ble
=========================
fe r a
an s
Failure ID Priority Status Time Detected Summary
n - t r
no
---------- -------- --------- ------------------- -------
1137 CRITICAL OPEN 2007-06-11:15:29:10 SQL
s a
a eฺ
dictionary health check: dependency$.dobj# fk 126 on object
) h
DEPENDENCY$ failed
m i d
...
i l ฺ co nt Gu
ma tude
1942 HIGH OPEN 2007-10-07:18:47:21 Datafile 3:
g
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' contains one or
more corrupt blocks
u k i@ is S
a s y e th
analyzing automatic repair
i ( t o us options; this may take some
M ORA_DISK_1 time

s y uk nse SID=149 device type=DISK


allocated channel:
channel ORA_DISK_1:
M a channel:
allocated
l i c e ORA_SBT_TAPE_1
y
nlechannel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
channel ORA_SBT_TAPE_1: SID=111 device type=SBT_TAPE

Sta analyzing automatic repair options complete

Mandatory Manual Actions


========================
1. Please contact Oracle Support Services to resolve failure
2137: SQL dictionary health check: dependency$.dobj# fk 126 on
object DEPENDENCY$ failed
2. Please contact Oracle Support Services to resolve failure
2134: SQL dictionary health check: dependency$.dobj# fk 126 on
object DEPENDENCY$ failed
...

Optional Manual Actions


=======================
no manual actions available

Automated Repair Options

Oracle Database 11g: Administration Workshop II A - 184


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


========================
Option Repair Description
------ ------------------
1 Recover multiple corrupt blocks in datafile 3
Strategy: The repair includes complete media recovery with
no data loss Repair script:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm

$ sqlplus sys/oracle as sysdba

SQL> select * from V$IR_REPAIR;

REPAIR_ID ADVISE_ID SUMMARY


RANK TIME_DETE EXECUTED ESTIMATED_DATA_LOSS
---------- ---------- -------------------------------- -------
--- --------- --------- --------------------
DETAILED_DESCRIPTION
ble
--------------------------------------------------------------
-------------------------------------------------------------- fe r a
-------------------------------------------------------------- ans
REPAIR_SCRIPT n - t r
no
--------------------------------------------------------------
a
s
--------------------------------------------------------------
a
) h d eฺ
--------------------------------------------------------------
i
m
co nt Gu
ESTIMATED_REPAIR_TIME ACTUAL_REPAIR_TIME STATUS
i l ฺ
ma tude
--------------------- ------------------ -------
391
g
390 NO DATA LOSS
1 27-AUG-07
u k i@ is S
UNKNOWN

a sy se th
The repair includes complete media recovery with no data loss
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2681015512.hm
k i (M to u0 0 NOT RUN
syu cense
SQL> exit
a
yM li
t a n6)leRerun the RMAN advise failure all command. After inspecting the results
S of that command, run the RMAN repair failure command ( an advise
failure command must precede a repair command).
Note: Your actual script name will vary somewhat from the example.
$ rman target / nocatalog

Recovery Manager: Release 11.1.0.6.0 - Production on Sun Oct 7


20:24:43 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1159023676)


using target database control file instead of recovery catalog

RMAN> advise failure all;

Oracle Database 11g: Administration Workshop II A - 185


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
1137 CRITICAL OPEN 2007-06-11:15:29:10 SQL
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

dictionary health check: dependency$.dobj# fk 126 on object


DEPENDENCY$ failed
...
1942 HIGH OPEN 2007-10-07:18:47:21 Datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' contains one or
more corrupt blocks
...
Automated Repair Options
========================
Option Repair Description
------ ------------------
ble
1 Recover multiple corrupt blocks in datafile 3
Strategy: The repair includes complete media recovery with fe r a
no data loss Repair script: ans
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm n - t r
a no
RMAN> repair failure;
a s
h
) recovery
i d eฺ
Strategy: The repair includes complete
c o mmedia
G u with no
data loss Repair script: ฺ
ail den t
m
g Stu
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm
i @
y
contents of repair script:
s uk this
# block media a recoveryse for multiple blocks
i ( M to u
u k
recover datafile
y ewant e
3 block 12, 20, 28;
s to execute the above repair (enter YES or
Do youas n
y Myes lic
really
l e
NO)?
n executing repair script
Sta
Starting recover at 2007-10-07:20:26:22
using channel ORA_DISK_1
using channel ORA_SBT_TAPE_1
searching flashback logs for block images until SCN 1111735
finished flashback log search, restored 3 blocks

starting media recovery


media recovery complete, elapsed time: 00:00:03

Finished recover at 2007-10-07:20:26:25


repair failure complete

RMAN> exit

Recovery Manager complete.

Oracle Database 11g: Administration Workshop II A - 186


Computer Pride Limited

Practice 13-2: Repairing Block Corruption (continued)


7) Query the BC.REGIONS table to test the recovery:
$ sqlplus sys/oracle as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Aug 27


11:24:34 2007
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> select * from bc.regions;


ble
REGION_ID REGION_NAME
fe r a
---------- -------------------------
an s
1 Europe
n - t r
2 Americas
a no
3 Asia
a s
4 Middle East and Africa
) h i d eฺ
m
co nt Gu
SQL> exit i l ฺ
g ma tude
u k i@ is S
a s y
8) To clean up the practice environment,
e th the bc_cleanup.sh script from the
run
$HOME/labs directory.
i ( M to us
y uk nse
$ ./bc_cleanup.sh
s
M a lice
y
nle14:56:16 2007
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 26

Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options

SQL> SQL>
Tablespace dropped.

SQL> SQL>
User dropped.

Oracle Database 11g: Administration Workshop II A - 187


Computer Pride Limited

Practice 13-3: SQL Repair Advisor Scenario


In this practice, you simulate a SQL crash and analyze it with the SQL Repair Advisor.
1) Connected as the SYS user from a SQL*plus session, execute the
sql_repair1.sql script located in the labs directory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.5.0 - Beta on Tue May 29 00:58:48


2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
ble
With the Partitioning, OLAP, Data Mining and Real Application
fe r a
Testing options
ans
SQL> @sql_repair1 n - t r
SQL>
a no
a s
SQL> -- This example generates a workaround for a crash. This
bug has already ) h i d eฺ
m
co nt Gu
SQL> -- been fixed but we toggle the bug fix using an
i l ฺ
ma tude
underscore parameter
g
SQL> -- which uses the (internal) feature called bug fix
control.
u k i@ is S
sy se th
SQL> -- This script will pause periodically to allow you to
a
(M to u
read the comments
k i
SQL> -- and see the output of the previous command on the
syu cense
screen. Just press
a
yM li
SQL> -- return to make the demo resume.

nle SQL>

Sta
SQL> pause

2) Press Enter, and then press Enter again to continue. The script now grants privileges
to the user SCOTT that is used for the demo.
SQL>
SQL> -- To begin the demo we will create the user scott and
grant
SQL> -- advisor privileges to him.
SQL>
SQL> pause

SQL>
SQL> grant connect, resource, dba, query rewrite, unlimited
tablespace to scott identified by tiger;

Grant succeeded.

Oracle Database 11g: Administration Workshop II A - 188


Computer Pride Limited

SQL> alter user scott account unlock;

User altered.

SQL>
SQL>
SQL> -- Next we need to create and populate the table used by
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

the demo.
SQL> -- We will also create an index on the table;
SQL>
SQL> pause
3) When you press Enter, a table is created and populated.
SQL> connect scott/tiger;
Connected.
SQL>
SQL> drop table t;
drop table t
ble
*
fe r a
ERROR at line 1:
ans
ORA-00942: table or view does not exist
n - t r
a no
a s
eฺ
SQL>
SQL> create table t(a varchar(40), b number, h
) cuvarchar(240),
i d d
o m
ilฺc ent G
varchar(240));
a
Table created.
@ gm Stud
y u ki this
SQL>
a s tc onset(b, d, a);
SQL> -- create M
i ( index
t o u
SQL> k
syu cinto
SQL> insert
a e nstevalues('a', 1, 'b', 'c');
M li
1yrow created.
n l e
Sta SQL> insert into t values('a', 1, 'x', 'c');

1 row created.

SQL> insert into t values('e', 2, 'f', 'g');

1 row created.

SQL>
SQL> -- In order to crash the system we need to switch off the
code line that
SQL> -- normal protects against this type of crash. We can
switch off the code
SQL> -- using the (internal) feature called bug fix control.
SQL>
SQL> pause

Oracle Database 11g: Administration Workshop II A - 189


Computer Pride Limited

4) Press Enter to continue. This time you need to switch off some code in the system to
intentionally cause a crash when executing a particular SQL statement.
SQL>
SQL> -- switch the code
SQL> alter session set "_fix_control"="5868490:OFF";
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Session altered.

SQL> -- alter session set optimizer_dynamic_sampling = 0;


SQL>
SQL> -- Now that the code line has been switched off lets get
the execution
SQL> -- plan for a simple delete statement.
SQL>
SQL> pause
5) Press Enter to continue. You now explain the delete statement that is used in this lab.
ble
SQL>
fe r a
SQL> --- explain the plan
ans
SQL> explain plan for delete from t t1 where t1.a = 'a' and
n - t r
no
rowid <> (select max(rowid) from t t2 where t1.a= t2.a and
t1.b = t2.b and t1.d=t2.d);
s a
) h a eฺ
Explained.
m i d
i l ฺ co nt Gu
ma tude
SQL>
SQL> --- display the plan g S
k i@ from
SQL> select plan_table_output
u i s
sy se t h
table(dbms_xplan.display('plan_table',null));
a
(M to u
k i
PLAN_TABLE_OUTPUT
s yu ense
--------------------------------------------------------------
a lic 2017343943
y Mhash value:
------------------

n l e
Plan

Sta --------------------------------------------------------------
----------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------
----------------
| 0 | DELETE STATEMENT | | 1 | 507 | 8
(25)| 00:00:01 |
| 1 | DELETE | T | | |
| |
|* 2 | FILTER | | | |
| |
| 3 | HASH GROUP BY | | 1 | 507 | 8
(25)| 00:00:01 |
|* 4 | HASH JOIN | | 1 | 507 | 7
(15)| 00:00:01 |

Oracle Database 11g: Administration Workshop II A - 190


Computer Pride Limited

|* 5 | TABLE ACCESS FULL| T | 2 | 652 | 3


(0)| 00:00:01 |

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
------------------
|* 6 | TABLE ACCESS FULL| T | 2 | 362 | 3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

(0)| 00:00:01 |
--------------------------------------------------------------
----------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter(ROWID<>MAX(ROWID))
4 - access("T1"."A"="T2"."A" AND "T1"."B"="T2"."B" AND
"T1"."D"="T2"."D")
5 - filter("T2"."A"='a')
ble
6 - filter("T1"."A"='a')
fe r a
PLAN_TABLE_OUTPUT
an s
--------------------------------------------------------------
n - t r
------------------
a no
a s
Note
) h i d eฺ
----- m
o t Gu
cstatement
i l ฺ
ma tuden
- dynamic sampling used for this
g
26 rows selected.
u k i@ is S
SQL> a sy se th
i
SQL> -- The plan (Mshows
t o uthat we we will do a full table scan
k
oun r. yu
a nse this simple system it will crash the
sIf weceexecut
SQL> --
yM li
l e
system.
n SQL>
Sta SQL> Pause

6) Press Enter to continue. Now you execute the statement and see that it crashed.
SQL> --- This statement caused the system to crash.
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);
delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d)
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [13011], [71129],
[16777631], [0],
[16777631], [17], [], []

Oracle Database 11g: Administration Workshop II A - 191


Computer Pride Limited

SQL>
7) You now need to use the SQL Repair Advisor to analyze the situation and find a
better alternative. Remain connected in your SQL*Plus session and execute the
sql_repair2.sql script.
SQL> @sql_repair2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> connect scott/tiger


Connected.
SQL> set lines 10000;
SQL> set pages 10000;
SQL> set long 20000;
SQL> set serveroutput on;
SQL> SET TRIMSPOOL ON;
SQL> SET TAB OFF;
SQL> SET FEEDBACK 1;
SQL>
SQL> alter system flush shared_pool;
ble
System altered.
fe r a
ans
SQL>
n - t r
SQL> set echo on;
SQL> a no
a s
) h i d eฺ
SQL> -- At this point your previous session has crashed due to
a problem m
co nt Gu
i l ฺ
SQL> -- with our delete statement. We now want to use the SQL
Repair Advisor
g ma tude
u k i@ is S
SQL> -- to fit that problem. Before we begin to fix this

sy se th
problem lets ensure
a
SQL> -- that the actual code that prevents this issue in real
(M to u
life is switched off.
k i
syu cense
SQL>
a
SQL> pause
li
le yM
8) Press Enter to continue. Make sure that the code for the previous issue is still
n
Sta disabled.
SQL>
SQL> alter session set "_fix_control"="5868490:OFF";

Session altered.

SQL>
SQL> -- Before we can run the SQL Repair Advisor we need to
create a
SQL> -- diagnosis task using dbms_sqldiag. We need to specify
the SQL text
SQL> -- for the statement that causes the crash and a task
name. We also need
SQL> -- to specify the problem type. There are three possible
problem types
SQL>
SQL> -- PROBLEM_TYPE_COMPILATION_ERROR

Oracle Database 11g: Administration Workshop II A - 192


Computer Pride Limited

SQL> -- PROBLEM_TYPE_EXECUTION_ERROR
SQL> -- WRONG_RESULTS
SQL>
SQL> -- In this cause since the statement failed during
execution we will use
SQL> -- PROBLEM_TYPE_EXECUTION_ERROR. When the SQL Repair
Advisor completes we will run
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> -- dbms_sqldiag.report_diagnosis_task to output the


results report to the screen.
SQL>
SQL> pause
9) Press Enter to continue. You now need to analyze the situation using the SQL Repair
Advisor. You can see that a SQL Patch was found during the analysis.
SQL>
SQL> exec
dbms_sqldiag.drop_diagnosis_task('sqldiag_bug_5869490');
BEGIN dbms_sqldiag.drop_diagnosis_task('sqldiag_bug_5869490');
ble
END;
fe r a
ans
*
n - t r
ERROR at line 1:
a no
ORA-13605: The specified task or object sqldiag_bug_5869490
a s
does not exist for the current user.
) h i d eฺ
m
ORA-06512: at "SYS.PRVT_ADVISOR", line 1967
co nt Gu
l ฺ
ORA-06512: at "SYS.DBMS_ADVISOR", line 172
i
g ma tude
ORA-06512: at "SYS.DBMS_SQLTUNE", line 759
ORA-06512: at "SYS.DBMS_SQLDIAG", line 838
ORA-06512: at line 1
u k i@ is S
a sy se th
k i (M to u
yu ense
SQL>
a s
SQL> declare
lic
y23M rep_out clob;
n l e t_id varchar2(50);
Sta 4 begin
5 t_id := dbms_sqldiag.create_diagnosis_task(
6 sql_text => 'delete from t t1 where t1.a = ''a'' and
rowid <> (select max(rowid) from t t2 where t1.a= t2.a and
t1.b = t2.b and t1.d=t2.d)',
7 task_name => 'sqldiag_bug_5869490',
8 problem_type
=>DBMS_SQLDIAG.PROBLEM_TYPE_COMPILATION_ERROR);
9
10 dbms_sqltune.set_tuning_task_parameter(
11 t_id,
12 '_SQLDIAG_FINDING_MODE',
13 dbms_sqldiag.SQLDIAG_FINDINGS_FILTER_PLANS);
14
15 dbms_output.put_line ('t_id = ' || t_id);
16
17 dbms_sqldiag.execute_diagnosis_task (t_id);

Oracle Database 11g: Administration Workshop II A - 193


Computer Pride Limited

18
19 dbms_output.put_line ('executed t_id = ' || t_id);
20
21 rep_out := dbms_sqldiag.report_diagnosis_task (t_id,
DBMS_SQLDIAG.TYPE_TEXT);
22
23 dbms_output.put_line ('Report : ' || rep_out);
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

24
25 end;
26 /
t_id = sqldiag_bug_5869490
executed t_id = sqldiag_bug_5869490
Report : GENERAL INFORMATION SECTION
--------------------------------------------------------------
-----------------
Tuning Task Name : sqldiag_bug_5869490
Tuning Task Owner : SCOTT
Tuning Task ID : 47
ble
Workload Type
Execution Count
: Single SQL Statement
: 1 fe r a
Current Execution : EXEC_47
ans
Execution Type : SQL DIAGNOSIS
n - t r
Scope : COMPREHENSIVE
a no
Time Limit(seconds) : 1800
a s
Completion Status
)
: COMPLETED h i d eฺ
Started at m
co nt Gu
: 05/29/2007 01:19:49
Completed at i l ฺ
: 05/29/2007 01:20:07
g ma tude
u k i@ is S
--------------------------------------------------------------
-----------------
Schema Name: SCOTT a sy se th
SQL ID
k (M to u
: if5z1dvyudh0hj
s cense from t t1 where t1.a = 'a' and rowid <>
SQL Text yu: delete
a
(select
yM li max(rowid) from t t2 where t1.a= t2.a and t1.b =
l e
n t2.b and
Sta t1.d=t2.d)

--------------------------------------------------------------
-----------------
FINDINGS SECTION (1 finding)
--------------------------------------------------------------
-----------------

1- SQL Patch Finding (see explain plans section below)


------------------------------------------------------
A potentially better execution plan was found for this
statement.

Recommendation
--------------
- Consider accepting the recommended SQL patch.

Oracle Database 11g: Administration Workshop II A - 194


Computer Pride Limited

execute dbms_sqldiag.accept_sql_patch(task_name =>


'sqldiag_bug_5869490',
task_owner => 'SCOTT', replace => TRUE);

Rationale
---------
Recommended plan with hash value 4122352137 has number of
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

rows 0, check
sum 0, execution time 22 and 16 buffer gets

--------------------------------------------------------------
-----------------
ADDITIONAL INFORMATION SECTION
--------------------------------------------------------------
-----------------
- Strategy execution Original plan failed with error code 600
and error
message
ble
- Recommended plan with hash value 4122352137 has number of
rows 0, check sum fe r a
0, execution time 22 and 16 buffer gets
ans
- Alternative plan with hash value 3804998351 has number of
n - t r
rows 0, check sum
a no
0, execution time 1 and 16 buffer gets
a s
) h d eฺ
- Alternative plan with hash value 4122352137 has number of
i
rows 0, check sum m
co nt Gu
i l ฺ
0, execution time 22 and 16 buffer gets
g ma tude
- Plan for strategy outline based feature toggle with plan
directive (hint)
u k i@ is S
plan hash valuea sy se th
NO_USE_HASH_AGGREGATION(@"SEL$80F8B8C6") has cost 7 with

i
4117267572
k (M to u
syu cense
- Plan for strategy outline based feature toggle with plan
a li
directive (hint)
yM
nle NO_USE_HASH(@"SEL$80F8B8C6" "T1"@"DEL$1") has cost 7 with

Sta
plan hash value
2017343943
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_UNNEST(@"SEL$1") has cost 6 with plan hash value
4122352137
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_MERGE(@"SEL$7D4DB4AA") has cost 7 with plan hash value
3804998351
- Plan for strategy avoid umbrella features with plan
directive (hint)
NOREWRITE has cost 7 with plan hash value 2017343943
- Plan for strategy avoid umbrella features with plan
directive (hint)
STAR_TRANSFORMATION TEMP_DISABLE has cost 7 with plan hash
value 2017343943

Oracle Database 11g: Administration Workshop II A - 195


Computer Pride Limited

- Plan for strategy avoid umbrella features with plan


directive (hint)
NO_STAR_TRANSFORMATION has cost 7 with plan hash value
2017343943
- Plan for strategy avoid umbrella features with plan
directive (hint)
NO_QUERY_TRANSFORMATION has cost 6 with plan hash value
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

4122352137
- Plan for strategy rule optimizer has cost 0 with plan hash
value 4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.0') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.4') has cost 1 with
ble
plan hash value
4122352137 fe r a
- Plan for strategy optimizer features enabled toggle with
ans
plan directive
n - t r
no
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.5') has cost 1 with
a
plan hash value
a s
4122352137
) h i d eฺ
m
co nt Gu
- Plan for strategy optimizer features enabled toggle with
plan directive i l ฺ
g ma tude
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.6') has cost 1 with
plan hash value
u k i@ is S
4122352137
a sy se th
- Plan for strategy optimizer features enabled toggle with
i (M to u
plan directive
k
syu cense
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.0') has cost 1 with
a li
plan hash value
yM
nle 4122352137

Sta
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.5') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.6') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.7') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive

Oracle Database 11g: Administration Workshop II A - 196


Computer Pride Limited

(hint) OPTIMIZER_FEATURES_ENABLE('9.0.0') has cost 7 with


plan hash value
4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('9.2.0') has cost 9 with
plan hash value
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0') has cost 7 with
plan hash value
4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.3') has cost 7 with
plan hash
value 4117267572
ble
- Plan for strategy optimizer features enabled toggle with
plan directive fe r a
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.4') has cost 7 with
ans
plan hash
n - t r
value 4117267572
a no
s
- Plan for strategy optimizer features enabled toggle with
a
plan directive
) h i d eฺ
m
co nt Gu
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.5') has cost 7 with
plan hash i l ฺ
value 4117267572
g ma tude
u k i@ is S
- Plan for strategy optimizer features enabled toggle with
plan directive
a sy se th
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.1') has cost 7 with
plan hash
k i (M to u
syu cense
value 2017343943
a li
- Plan for strategy optimizer features enabled toggle with
yM
nle plan directive

Sta
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.2') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.3') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.4') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('11.1.0.1') has cost 7 with
plan hash
value 2017343943

Oracle Database 11g: Administration Workshop II A - 197


Computer Pride Limited

- Plan for strategy validation history has cost 7 with plan


hash value
2017343943
- Strategy execution compilation history failed with error
code 600 and error
message ORA-00600: internal error code, arguments: [13011],
[71129],
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

[16777631], [0], [16777631], [17], [], []

--------------------------------------------------------------
-----------------
EXPLAIN PLANS SECTION
--------------------------------------------------------------
-----------------

1- Original
-----------
Plan hash value: 2017343943
ble
-------------------------------------------------------------- fe r a
n s
----------------
| Id | Operation | Name | Rows | Bytes |-tCost
n ra
(%CPU)| Time | n o
s a
--------------------------------------------------------------
---------------- h a eฺ |
) 1 |uid507
| 0 | DELETE STATEMENT |
c o|m G 8
(25)| 00:00:01 | ฺ
il | en | t
|a
m d
| 1 | DELETE
g T
t u |
| |
u k i@ |is S |
|* 2 |
|
FILTER
| a sy se th | |

| 3 |
k i
HASH (MGROUPtoBYu | | 1 | 507 | 8
u
y HASH
(25)| 00:00:01 | e
sJOIN
|* 4 a|s c e n
y M l i | | 1 | 507 | 7

nle|* 5 |
(15)| 00:00:01 |

Sta
TABLE ACCESS FULL| T | 2 | 652 | 3
(0)| 00:00:01 |
|* 6 | TABLE ACCESS FULL| T | 2 | 362 | 3
(0)| 00:00:01 |
--------------------------------------------------------------
----------------

Query Block Name / Object Alias (identified by operation id):


-------------------------------------------------------------

1 - SEL$80F8B8C6
5 - SEL$80F8B8C6 / T2@SEL$1
6 - SEL$80F8B8C6 / T1@DEL$1

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter(ROWID<>MAX(ROWID))

Oracle Database 11g: Administration Workshop II A - 198


Computer Pride Limited

4 - access("T1"."A"="T2"."A" AND "T1"."B"="T2"."B" AND


"T1"."D"="T2"."D")
5 - filter("T2"."A"='a')
6 - filter("T1"."A"='a')

Column Projection Information (identified by operation id):


-----------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2 - "T2"."A"[VARCHAR2,40], "T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240], ROWID[ROWID,10],
ROWID[ROWID,10], MAX(ROWID)[10]
3 - (#keys=5) "T2"."A"[VARCHAR2,40], "T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240], ROWID[ROWID,10],
ROWID[ROWID,10], MAX(ROWID)[10]
4 - (#keys=3) "T2"."A"[VARCHAR2,40], "T1"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22], "T1"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240],
"T1"."D"[VARCHAR2,240], ROWID[ROWID,10],
ble
"T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22], "T2"."D"[VARCHAR2,240], fe r a
ROWID[ROWID,10]
ans
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
n - t r
"T2"."B"[NUMBER,22],
a no
"T2"."D"[VARCHAR2,240]
a s
6 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
) h i d eฺ
"T1"."B"[NUMBER,22], m
co nt Gu
"T1"."D"[VARCHAR2,240] i l ฺ
g ma tude
Note
u k i@ is S
-----
a
- dynamic sampling
th this statement
sy usedsefor
k i (M to u
syu cWith
2- Original e
nsAdjusted Cost
a li e
------------------------------
l e y Mhash value:
Plan 4122352137
n
Sta --------------------------------------------------------------
---------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------
---------------
| 0 | DELETE STATEMENT | | 1 | 169 | 6
(0)| 00:00:01 |
| 1 | DELETE | T | | |
| |
|* 2 | FILTER | | | |
| |
|* 3 | TABLE ACCESS FULL | T | 2 | 338 | 3
(0)| 00:00:01 |
| 4 | SORT AGGREGATE | | 1 | 169 |
| |

Oracle Database 11g: Administration Workshop II A - 199


Computer Pride Limited

|* 5 | TABLE ACCESS FULL| T | 1 | 169 | 3


(0)| 00:00:01 |
--------------------------------------------------------------
---------------

Query Block Name / Object Alias (identified by operation id):


-------------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1 - DEL$1
3 - DEL$1 / T1@DEL$1
4 - SEL$1
5 - SEL$1 / T2@SEL$1

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter(ROWID<> (SELECT /*+ NO_UNNEST */ MAX(ROWID) FROM


"T" "T2"
ble
"T2"."D"=:B3))
WHERE "T2"."A"=:B1 AND "T2"."B"=:B2 AND
fe r a
3 - filter("T1"."A"='a')
ans
5 - filter("T2"."A"=:B1 AND "T2"."B"=:B2 AND "T2"."D"=:B3)
n - t r
n o
Column Projection Information (identified by s a
operation id):
) h a eฺ
m i d
-----------------------------------------------------------

l ฺ o t Gu
c"T1"."A"[VARCHAR2,40],
i
ma tuden
2 - (cmp=2,3,4) ROWID[ROWID,10],
g
"T1"."B"[NUMBER,22], "T1"."D"[VARCHAR2,240]
i@ is S
3 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22], uk
a sy se th
"T1"."D"[VARCHAR2,240]
i
4 - (#keys=0)
t u
(MMAX(ROWID)[10]
o
k
a syu cense
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
li
"T2"."B"[NUMBER,22],
y M "T2"."D"[VARCHAR2,240]
n l e
Sta Note
-----
- dynamic sampling used for this statement

--------------------------------------------------------------
-----------------

PL/SQL procedure successfully completed.

SQL>
SQL> -- The above report tells us that the statement fails
during execute
SQL> -- and it has found a SQL patch for this statement that
will prevent
SQL> -- it from crashing in the future. However, unning the
repair advisor

Oracle Database 11g: Administration Workshop II A - 200


Computer Pride Limited

SQL> -- wont fix the problem automatically. If we run our


problematic SQL
SQL> -- statement now the session will crash.
SQL>
SQL> pause

10) Press Enter to continue. If you execute the statement again, you get the same error.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

This is because you have not yet accepted the proposed SQL Patch.
SQL>
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);
delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d)
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [13011], [71129],
ble
[16777631], [0], [16777631], [17], [], []
fe r a
ans
n - t r
SQL>
SQL> -- connect scott/tiger a no
a s
SQL>
) h i d eฺ
m
SQL> -- We need to accept the SQL Patch that the SQL Repair
co nt Gu
Advisor recommended before
i l ฺ
g ma tude
SQL> -- our SQL statement will be able to run without
crashing. To accept the SQL Patch
k i@ is S
SQL> -- we must execute dbms_sqldiag.accept_sql_patch and pass
u
it task name
a sy se th
SQL>
k i (M to u
yu ense
SQL> pause
a s
11) Press
y lic This time you accept the SQL Patch.
MEnter to continue.
nleSQL> execute dbms_sqldiag.accept_sql_patch(task_name =>
Sta 'sqldiag_bug_5869490', task_owner => 'SCOTT', replace =>
TRUE);

PL/SQL procedure successfully completed.

SQL>
SQL> -- Now that we have successfully accepted the SQL patch
we should be able to
SQL> -- run our statement without it crashing. Lets first look
at the execution
SQL> -- plan to see if it has changed.
SQL>
SQL> pause
12) Press Enter to continue. You now look at the alternative execution plan for the culprit
SQL statement.
SQL>

Oracle Database 11g: Administration Workshop II A - 201


Computer Pride Limited

SQL> explain plan for delete from t t1 where t1.a = 'a' and
rowid <> (select max(rowid) from t t2 where t1.a= t2.a and
t1.b = t2.b and t1.d=t2.d);

Explained.

SQL> -- display the plan


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> select plan_table_output from


table(dbms_xplan.display('plan_table',null,'advanced'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
----------------------------------------------------
Plan hash value: 4122352137

ble
--------------------------------------------------------------
--------------- fe r a
| Id | Operation | Name | Rows | Bytes | Cost
ans
(%CPU)| Time |
n - t r
no
--------------------------------------------------------------
a
---------------
a s
| 0 | DELETE STATEMENT | |
) h 1 |
i d eฺ
169 | 6
(0)| 00:00:01 | m
co nt Gu
| 1 | DELETE i l
| Tฺ | | |
| |
g ma tude
|* 2 | FILTER
u k i@ is S| | | |
|
|* 3 |
|
a sy se th
TABLE ACCESS FULL | T | 2 | 338 | 3
i (M to u
(0)| 00:00:01 |
k
|
a syu cense
4 | SORT AGGREGATE | | 1 | 169 |
|
yM li |

nle |* 5 | TABLE ACCESS FULL| T | 1 | 169 | 3

Sta
(0)| 00:00:01 |
--------------------------------------------------------------
---------------

Query Block Name / Object Alias (identified by operation id):


-------------------------------------------------------------

1 - DEL$1
3 - DEL$1 / T1@DEL$1
4 - SEL$1
5 - SEL$1 / T2@SEL$1

Outline Data
-------------

/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$1" "T2"@"SEL$1")

Oracle Database 11g: Administration Workshop II A - 202


Computer Pride Limited

FULL(@"DEL$1" "T1"@"DEL$1")
OUTLINE_LEAF(@"DEL$1")
OUTLINE_LEAF(@"SEL$1")
ALL_ROWS
DB_VERSION('11.1.0.1')
OPTIMIZER_FEATURES_ENABLE('11.1.0.1')
IGNORE_OPTIM_EMBEDDED_HINTS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

END_OUTLINE_DATA
*/

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter(ROWID<> (SELECT /*+ NO_UNNEST */ MAX(ROWID) FROM


"T" "T2"
WHERE "T2"."A"=:B1 AND "T2"."B"=:B2 AND
"T2"."D"=:B3))
3 - filter("T1"."A"='a')
ble
5 - filter("T2"."A"=:B1 AND "T2"."B"=:B2 AND "T2"."D"=:B3)
fe r a
Column Projection Information (identified by operation id):
ans
-----------------------------------------------------------
n - t r
n o
s a
2 - (cmp=2,3,4) ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
) h a eฺ
"T1"."B"[NUMBER,22], "T1"."D"[VARCHAR2,240]
m i d
"T1"."B"[NUMBER,22], i l co nt Gu
3 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],

"T1"."D"[VARCHAR2,240]ma de
g t u
u k i@ is S
4 - (#keys=0) MAX(ROWID)[10]

a
"T2"."B"[NUMBER,22],sy se th
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],

i (M to u
"T2"."D"[VARCHAR2,240]
k
Note as
yu ense
yM lic
l e
-----
n - dynamic sampling used for this statement
Sta - SQL patch "SYS_SQLPTCH_0144b5bb2a078000" used for this
statement

60 rows selected.

SQL>
SQL> -- Now lets execute it.
SQL>
SQL> pause

13) Press Enter to continue. This time you try to execute the statement again. You should
see that it no longer generates the error. The end of the script reestablishes the
original code path.
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);

Oracle Database 11g: Administration Workshop II A - 203


Computer Pride Limited

1 row deleted.

SQL>
SQL> -- Finally we need to restore the system back the way we
found it.
SQL> -- We must drop the SQL Patch we have accepted and turn
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

back on the
SQL> -- original code path that prevented this problem in the
first place.
SQL>
SQL> -- execute dbms_sqldiag.drop_sql_patch(
SQL>
SQL> alter session set "_fix_control"="5868490:ON";

Session altered.

SQL>
ble
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition fe r a
Release 11.1.0.5.0 - Beta
ans
With the Partitioning, OLAP, Data Mining and Real Application
n - t r
Testing options
a no
$
a s
) h i d eฺ
c m
o t Gu
i l ฺ
g
Get the patch name under the Note section den
main steptu12.
14) Finally, drop the patch using the DBMS_SQLDIAG.DROP_SQL_PATCH procedure.

u k i@ is S
a sy se th
SQL> execute DBMS_SQLDIAG.DROP_SQL_PATCH (name =>

(M to u
‘SYS_SQLPTCH_0144b5bb2a078000’);
k i e
a syu censsuccessfully
PL/SQL Procedure completed.

l e y Mexit li
SQL>

Stan

Oracle Database 11g: Administration Workshop II A - 204


Computer Pride Limited

Practices for Lesson 14

In this practice, you use various new memory management capabilities.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 205


Computer Pride Limited

Practice 14-1: Using Automatic Memory Management


In this practice, you use Automatic Memory Management to show that you no longer
need to manually modify SGA_TARGET and PGA_AGGREGATE_TARGET. You observe
the memory distribution when you run an expensive parallel query that consumes a lot of
SGA memory, as well as when you run an expensive PL/SQL block that consumes a lot
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

of PGA memory.
1) Before you start this lab, stop Enterprise Manager Database Control.
$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release
11.1.0.4.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights
reserved.
https://stc-
raclin06.us.oracle.com:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
ble
... Stopped.
fe r a
$
t r a ns
2) Shut down your database instance and make a copy of your SPFILE. Then
o n -restart
your database instance.
s an
) h a eฺ
$ sqlplus / as sysdba
o m u id
ilฺcon eFri
n t G
SQL*Plus: Release 11.1.0.5.0 - a
m tud May 25 01:41:28
Beta
g
2007
u k i@ is S
Copyright (c) 1982, a th All rights reserved.
sy2007,seOracle.
k i (M to u
a
Connectedsyuto:cense
y M Database
Oracle li 11g Enterprise Edition Release 11.1.0.5.0 -
l e
n Beta
Sta With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP and Data Mining options

$ cp $ORACLE_HOME/dbs/spfileorcl.ora /tmp/spfileorcl_bu.ora
$ export ORACLE_SID=orcl
$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.5.0 - Beta on Fri May 25 01:43:38
2007

Oracle Database 11g: Administration Workshop II A - 206


Computer Pride Limited

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Total System Global Area 292933632 bytes


Fixed Size 1298204 bytes
Variable Size 188743908 bytes
Database Buffers 96468992 bytes
Redo Buffers 6422528 bytes
Database mounted.
Database opened.
SQL>

3) Connected as SYS in SQL*Plus, set the following parameters to the given value in
your SPFILE only. You can use the change_parameters.sql file. ble
_PX_use_large_pool = TRUE fe r a
ans
_memory_broker_stat_interval = 5
_memory_management_tracing = 31 n - t r
parallel_execution_message_size = 36864 a no
a s
parallel_max_servers = 200
) h i d eฺ
parallel_adaptive_multi_user = FALSE
m
co nt Gu
processes = 200
i l ฺ
sga_target = 0
g ma tude
pga_aggregate_target = 0
u k i@ is S
memory_target = 280M
a s y e th
( M to us
SQL> @change_parameters.sql
i
uk n20000
SQL> set pages
s y se
SQL>
a ic e
l e y MALTER lSYSTEM
SQL> SET "_PX_use_large_pool" = TRUE
n SCOPE=SPFILE;
Sta System altered.

SQL> ALTER SYSTEM SET "_memory_broker_stat_interval" = 5


SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET "_memory_management_tracing" = 31


SCOPE=SPFILE;

System altered.

SQL>
SQL> ALTER SYSTEM SET "parallel_execution_message_size" =
36864 SCOPE=SPFILE;

Oracle Database 11g: Administration Workshop II A-207


Computer Pride Limited

System altered.

SQL> ALTER SYSTEM SET "parallel_max_servers" = 200


SCOPE=SPFILE;

System altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> ALTER SYSTEM SET "parallel_adaptive_multi_user" = FALSE


SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET "processes" = 200 SCOPE=SPFILE;


System altered.

SQL> ALTER SYSTEM SET "pga_aggregate_target" = 0 SCOPE=SPFILE;

System altered.
ble
SQL> ALTER SYSTEM SET "sga_target" = 0 SCOPE=SPFILE; fe r a
ans
System altered.
n - t r
n o
SQL> ALTER SYSTEM SET "memory_target" = 280M s a
SCOPE=SPFILE;
) h a eฺ
m i d
System altered.
i l ฺ co nt Gu
SQL>
g ma tude
k i@session
4) Remain connected in your SQL*Plus i s S
as the SYS user and execute the
s y u t h
amm_setup.sql script.
( M a use
u ki se to
SQL> @amm_setup.sql
y
M as tablespace
SQL> drop
l i c entbssgatbssga including contents and datafiles;
y
drop tablespace including contents and datafiles
nle*
Sta ERROR at line 1:
ORA-00959: tablespace 'TBSSGA' does not exist

SQL>
SQL> create tablespace tbssga datafile 'tbssga12.dbf' size
20m;

Tablespace created.

SQL>
SQL> drop tablespace mytemp including contents and datafiles;
drop tablespace mytemp including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'MYTEMP' does not exist

Oracle Database 11g: Administration Workshop II A-208


Computer Pride Limited

SQL>
SQL> create temporary tablespace mytemp tempfile 'temp12.f'
size 40m reuse;

Tablespace created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL>
SQL> drop user amm cascade;
drop user amm cascade
*
ERROR at line 1:
ORA-01918: user 'AMM' does not exist

SQL>
SQL> create user amm identified by amm
2 default tablespace tbssga
ble
3 temporary tablespace mytemp;
fe r a
User created.
ans
n - t r
SQL>
a no
SQL> grant connect,resource,dba to amm;
a s
) h i d eฺ
Grant succeeded. m
co nt Gu
i l ฺ
SQL>
g ma tude
i@ 0,
SQL> select substr(COMPONENT,
s S COMP, CURRENT_SIZE
10) CS,
USER_SPECIFIED_SIZE USuk t h i
CURRENT_SIZE!=0; as
y from v$memory_dynamic_components
e
where

(M to u s
k i
COMP
a e n seCS ----------
syu---------- US

y M poo lic58720256
----------

n l e
shared 0

Sta
large pool 4194304 0
java pool 4194304 0
SGA Target 176160768 0
DEFAULT bu 100663296 0
Shared IO 8388608 8388608
PGA Target 117440512 0

7 rows selected.

SQL>
SQL> connect amm/amm
Connected.
SQL>
SQL> drop table tabsga purge;
drop table tabsga purge
*
ERROR at line 1:
ORA-00942: table or view does not exist

Oracle Database 11g: Administration Workshop II A-209


Computer Pride Limited

SQL>
SQL> create table tabsga(a number, b number) tablespace
tbssga;

Table created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL>
SQL> begin
2 for i in 1..100000 loop
3 insert into tabsga values (i, i);
4 end loop;
5 end;
6 /

PL/SQL procedure successfully completed.

ble
SQL> commit;
fe r a
Commit complete.
ans
n - t r
SQL>
a no
SQL> alter table tabsga parallel 64;
a s
) h i d eฺ
Table altered. m
co nt Gu
i l ฺ
SQL>
g ma tude
SQL> create or replace procedure
k S
i@ is testpga( psize number ) as
2 begin u
sy se t h
3 declare a
(M to u
u k i
4 TYPE nAllotment_tabtyp
e
IS TABLE OF char(2048) INDEX BY
BINARY_INTEGER;
a e ns
sy cnAllotment_tabtyp;
y6Mbegin li
5 myarray
l e
n 7 for i in 1..psize loop
Sta 8 myarray(i) := to_char(i);
9 end loop;
10 end;
11 end;
12 /

Procedure created.

SQL>
SQL> show errors
No errors.
SQL>
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;

COMP CS US

Oracle Database 11g: Administration Workshop II A-210


Computer Pride Limited

---------- ---------- ----------


shared poo 58720256 0
large pool 4194304 0
java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 117440512 0
PGA Target 100663296 0
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

7 rows selected.

SQL>
SQL> connect / as sysdba
Connected.
SQL>
SQL>

5) Still connected as SYS in your SQL*Plus session, shut down and start your database
instance and connect as the AMM user:
ble
SQL> shutdown immediate;
fe r a
Database closed.
ans
Database dismounted.
n - t r
ORACLE instance shut down.
SQL> a no
a s
SQL> startup quiet;
) h i d eฺ
ORACLE instance started. m
co nt Gu
Database mounted.
i l ฺ
Database opened.
g ma tude
SQL>
u k i@ is S
sy se th
SQL> connect amm/amm
Connected.
SQL>
a
(M to u
k i
6) Still connected
a se user in your SQL*Plus session, determine the current
syu ascethenAMM
M for thelivarious memory buffers as well as the list of resized operations that
settings
y
l e
n were done since you started your instance. You can use the components.sql
Sta script for that purpose.
SQL> @$HOME/labs/components.sql
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;

COMP CS US
---------- ---------- ----------
shared poo 62914560 0
large pool 4194304 0
java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 104857600 0
Shared IO 8388608 8388608
PGA Target 100663296 0

Oracle Database 11g: Administration Workshop II A-211


Computer Pride Limited

7 rows selected.

SQL> select substr(COMPONENT, 0, 10), FINAL_SIZE, OPER_TYPE,


OPER_MODE, status from v$memory_resize_ops order by
START_TIME;

SUBSTR(COM FINAL_SIZE OPER_TYPE OPER_MODE STATUS


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

---------- ---------- ------------- --------- ---------


DEFAULT bu 113246208 STATIC IMMEDIATE COMPLETE
shared poo 62914560 GROW IMMEDIATE COMPLETE
shared poo 54525952 STATIC COMPLETE
large pool 4194304 STATIC COMPLETE
java pool 4194304 STATIC COMPLETE
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
RECYCLE bu 0 STATIC COMPLETE
ble
DEFAULT 2K
DEFAULT 4K
0 STATIC
0 STATIC
COMPLETE
COMPLETE fe r a
DEFAULT 8K 0 STATIC COMPLETE
ans
DEFAULT 16 0 STATIC COMPLETE
n - t r
DEFAULT 32 0 STATIC COMPLETE
a no
PGA Target 100663296 STATIC COMPLETE
a s
ASM Buffer 0 STATIC
)
COMPLETE h i d eฺ
m
co nt Gu
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
DEFAULT bu 109051904 SHRINK i l ฺ
IMMEDIATE COMPLETE
shared poo 58720256 GROW
g ma tude
IMMEDIATE COMPLETE
DEFAULT bu 104857600 SHRINK
u k i@ is S
IMMEDIATE COMPLETE
large pool
sy se th
4194304 GROW
a
IMMEDIATE COMPLETE

i (M to u
22 rows selected.
k
SQL> as
yu ense
y M lic
l e
n7) Remain connected as the AMM user in your SQL*Plus session and execute the
Sta following query. Immediately after that, determine the component sizes and resized
operations. You can use query1.sql script for that purpose. What do you observe?
select /*+ PARALLEL(s 24) */ count(*) from (select /*+
parallel(s 24) */ * from tabsga s group by a);
a) Execute the $HOME/labs/query1.sql script. You can see that the large pool
has a much bigger size while the buffer cache is smaller. This memory transfer
was automatically done by the system.
SQL> @$HOME/labs/query1.sql
SQL> select /*+ PARALLEL(s 24) */ count(*)
from (select /*+ parallel(s 24) */ * from tabsga s group by
a);

COUNT(*)
----------
100000

Oracle Database 11g: Administration Workshop II A-212


Computer Pride Limited

SQL>
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;

COMP CS US
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

---------- ---------- ----------


shared poo 62914560 0
large pool 83886080 0
java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 25165824 0
PGA Target 100663296 0

7 rows selected.

SQL> select substr(COMPONENT, 0, 10), FINAL_SIZE, OPER_TYPE,


ble
OPER_MODE, status from v$memory_resize_ops order by
START_TIME; fe r a
ans
OPER_MODE STATUS -tr
on
SUBSTR(COM FINAL_SIZE OPER_TYPE
---------- ---------- ------------- --------- ---------
DEFAULT bu 113246208 STATIC a n
IMMEDIATEsCOMPLETE
a
large pool 4194304 GROW IMMEDIATE
m i deฺ
) h uCOMPLETE
shared poo 62914560 GROW o t G COMPLETE
IMMEDIATE
lฺcIMMEDIATE
COMPLETE
i
den COMPLETE
DEFAULT bu 104857600 SHRINK
a
m tuIMMEDIATE
shared poo 58720256 GROW
g
DEFAULT bu 109051904 SHRINK
k i@ is S IMMEDIATE
DEFAULT bu 113246208 uINITIALIZING
COMPLETE

sy0 STATIC
e t h IMMEDIATE COMPLETE
ASM Buffer
( a us
M toSTATIC COMPLETE

u k i
PGA Target 100663296
e
COMPLETE
sy ce4194304
shared poo
large apool ns STATIC
54525952 STATIC COMPLETE

y M l i COMPLETE

n l e
java pool 4194304 STATIC COMPLETE

Sta
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
RECYCLE bu 0 STATIC COMPLETE
DEFAULT 2K 0 STATIC COMPLETE
DEFAULT 4K 0 STATIC COMPLETE
DEFAULT 8K 0 STATIC COMPLETE
DEFAULT 16 0 STATIC COMPLETE
DEFAULT 32 0 STATIC COMPLETE
DEFAULT bu 100663296 SHRINK IMMEDIATE COMPLETE
large pool 8388608 GROW IMMEDIATE COMPLETE
DEFAULT bu 88080384 SHRINK IMMEDIATE COMPLETE
large pool 16777216 GROW IMMEDIATE COMPLETE
DEFAULT bu 92274688 SHRINK IMMEDIATE COMPLETE
large pool 12582912 GROW IMMEDIATE COMPLETE
DEFAULT bu 96468992 SHRINK IMMEDIATE COMPLETE
large pool 20971520 GROW IMMEDIATE COMPLETE

Oracle Database 11g: Administration Workshop II A-213


Computer Pride Limited

DEFAULT bu 83886080 SHRINK IMMEDIATE COMPLETE


large pool 25165824 GROW IMMEDIATE COMPLETE
DEFAULT bu 79691776 SHRINK IMMEDIATE COMPLETE
large pool 29360128 GROW IMMEDIATE COMPLETE
large pool 71303168 GROW IMMEDIATE COMPLETE
DEFAULT bu 37748736 SHRINK IMMEDIATE COMPLETE
large pool 67108864 GROW IMMEDIATE COMPLETE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DEFAULT bu 41943040 SHRINK IMMEDIATE COMPLETE


large pool 62914560 GROW IMMEDIATE COMPLETE
DEFAULT bu 75497472 SHRINK IMMEDIATE COMPLETE
large pool 33554432 GROW IMMEDIATE COMPLETE
DEFAULT bu 71303168 SHRINK IMMEDIATE COMPLETE
large pool 37748736 GROW IMMEDIATE COMPLETE
DEFAULT bu 71303168 SHRINK IMMEDIATE COMPLETE
large pool 37748736 GROW IMMEDIATE COMPLETE
DEFAULT bu 67108864 SHRINK IMMEDIATE COMPLETE
large pool 41943040 GROW IMMEDIATE COMPLETE
DEFAULT bu 62914560 SHRINK IMMEDIATE COMPLETE
ble
large pool
DEFAULT bu
46137344
58720256
GROW
SHRINK
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE fe r a
large pool 50331648 GROW IMMEDIATE COMPLETE
ans
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
n - t r
large pool 50331648 GROW
a no
IMMEDIATE COMPLETE
DEFAULT bu 54525952 SHRINK
a s IMMEDIATE COMPLETE
large pool 54525952 GROW
) h i d eฺ
IMMEDIATE COMPLETE
DEFAULT bu 50331648 SHRINKm
co nt Gu IMMEDIATE COMPLETE
large pool 58720256 i l ฺ
GROW IMMEDIATE COMPLETE
DEFAULT bu 46137344
g ma tude
SHRINK IMMEDIATE COMPLETE
DEFAULT bu
u k i@ is S
33554432 SHRINK IMMEDIATE COMPLETE
large pool
large pool a sy se th
75497472
79691776
GROW
GROW
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE
DEFAULT bu
k i (M to u
29360128 SHRINK IMMEDIATE COMPLETE

a syu cense
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE

yM li
large pool 83886080 GROW IMMEDIATE COMPLETE

nle64
Sta
rows selected.

SQL>
8) Redo the same thing as in the previous step, but this time use the following query.
You can use query2.sql script for that purpose. What do you observe?
a) The same trend continues.
SQL> @$HOME/labs/query2.sql
SQL> select /*+ PARALLEL(s 26) */ count(*)
2 from (select /*+ parallel(s 26) */ * from tabsga s group
by a);

COUNT(*)
----------
100000

SQL>

Oracle Database 11g: Administration Workshop II A-214


Computer Pride Limited

SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,


USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;

COMP CS US
---------- ---------- ----------
shared poo 62914560 0
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

large pool 100663296 0


java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 8388608 0
Shared IO 8388608 8388608
PGA Target 100663296 0

7 rows selected.

SQL> select substr(COMPONENT, 0, 10), FINAL_SIZE, OPER_TYPE,


OPER_MODE, status from v$memory_resize_ops order by
ble
START_TIME;
fe r a
SUBSTR(COM FINAL_SIZE OPER_TYPE OPER_MODE STATUS
ans
---------- ---------- ------------- --------- ---------
n - t r
DEFAULT bu 113246208 STATIC no
IMMEDIATE COMPLETE
a
large pool 4194304 GROW s
IMMEDIATE COMPLETE
a
shared poo 62914560 GROW
) h d eฺ
IMMEDIATE COMPLETE
i
DEFAULT bu 104857600 SHRINK m
co nt Gu
IMMEDIATE COMPLETE
shared poo 58720256 GROW i l ฺ IMMEDIATE COMPLETE
g
DEFAULT bu 109051904 SHRINKma tude IMMEDIATE COMPLETE

u k i@ is S
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
ASM Buffer
a sy se th
0 STATIC
PGA Target 100663296 STATIC
COMPLETE
COMPLETE
DEFAULT 32
k i (M to u0 STATIC COMPLETE

a syu cense
DEFAULT 16 0 STATIC COMPLETE

yM li
shared poo 54525952 STATIC COMPLETE

nle large pool 4194304 STATIC COMPLETE

Sta
java pool 4194304 STATIC COMPLETE
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
RECYCLE bu 0 STATIC COMPLETE
DEFAULT 2K 0 STATIC COMPLETE
DEFAULT 4K 0 STATIC COMPLETE
DEFAULT 8K 0 STATIC COMPLETE
large pool 8388608 GROW IMMEDIATE COMPLETE
DEFAULT bu 100663296 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 92274688 SHRINK IMMEDIATE COMPLETE
large pool 12582912 GROW IMMEDIATE COMPLETE
large pool 16777216 GROW IMMEDIATE COMPLETE
DEFAULT bu 88080384 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 96468992 SHRINK IMMEDIATE COMPLETE
large pool 20971520 GROW IMMEDIATE COMPLETE
DEFAULT bu 83886080 SHRINK IMMEDIATE COMPLETE

Oracle Database 11g: Administration Workshop II A-215


Computer Pride Limited

large pool 25165824 GROW IMMEDIATE COMPLETE


DEFAULT bu 79691776 SHRINK IMMEDIATE COMPLETE
large pool 29360128 GROW IMMEDIATE COMPLETE
DEFAULT bu 75497472 SHRINK IMMEDIATE COMPLETE
large pool 33554432 GROW IMMEDIATE COMPLETE
DEFAULT bu 71303168 SHRINK IMMEDIATE COMPLETE
large pool 37748736 GROW IMMEDIATE COMPLETE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DEFAULT bu 71303168 SHRINK IMMEDIATE COMPLETE


large pool 37748736 GROW IMMEDIATE COMPLETE
DEFAULT bu 67108864 SHRINK IMMEDIATE COMPLETE
large pool 41943040 GROW IMMEDIATE COMPLETE
DEFAULT bu 62914560 SHRINK IMMEDIATE COMPLETE
large pool 46137344 GROW IMMEDIATE COMPLETE
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
large pool 50331648 GROW IMMEDIATE COMPLETE
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
large pool 50331648 GROW IMMEDIATE COMPLETE
DEFAULT bu 54525952 SHRINK IMMEDIATE COMPLETE
ble
large pool
DEFAULT bu
54525952
50331648
GROW
SHRINK
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE fe r a
large pool 58720256 GROW IMMEDIATE COMPLETE
ans
DEFAULT bu 46137344 SHRINK IMMEDIATE
n
COMPLETE - t r
large pool 62914560 GROW IMMEDIATE
a noCOMPLETE
DEFAULT bu 41943040 SHRINK s
IMMEDIATE
a COMPLETE
large pool 67108864 GROW
) h
IMMEDIATE
i d eฺ
COMPLETE
DEFAULT bu 37748736 SHRINK m
co nt Gu
IMMEDIATE COMPLETE
large pool 71303168 GROWi l ฺ IMMEDIATE COMPLETE
large pool 75497472
g ma tude
GROW IMMEDIATE COMPLETE
DEFAULT bu 33554432
u k i@ is S
SHRINK IMMEDIATE COMPLETE
DEFAULT bu
large pool a sy se th
29360128
79691776
SHRINK
GROW
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE
DEFAULT bu
k i (M to u
25165824 SHRINK IMMEDIATE COMPLETE

a syu cense
large pool 83886080 GROW IMMEDIATE COMPLETE

yM li
large pool 83886080 GROW IMMEDIATE COMPLETE

nle DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE

Sta
DEFAULT bu 20971520 SHRINK IMMEDIATE COMPLETE
large pool 88080384 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
large pool 92274688 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
large pool 92274688 GROW IMMEDIATE COMPLETE
DEFAULT bu 12582912 SHRINK IMMEDIATE COMPLETE
large pool 96468992 GROW IMMEDIATE COMPLETE
DEFAULT bu 8388608 SHRINK IMMEDIATE COMPLETE
large pool 100663296 GROW IMMEDIATE COMPLETE

76 rows selected.

SQL>

Oracle Database 11g: Administration Workshop II A-216


Computer Pride Limited

9) Still connected as the AMM user from your SQL*Plus session, execute the following
command and, immediately afterward, determine the memory component sizes and
the list of resize operations. You can use query3.sql for that purpose. What do
you observe?
a) You can now see that SGA is automatically shrunk while PGA is automatically
raised. This is because query 3 needs a lot of untunable PGA memory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> @$HOME/labs/query3.sql
SQL> exec testpga(700000);

PL/SQL procedure successfully completed.

SQL>
SQL> -- Same values as previously observed
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;
ble
COMP CS US fe r a
---------- ---------- ----------
ans
shared poo 79691776 0
n - t r
large pool 4194304 0
a no
java pool 4194304 0
a s
SGA Target 113246208 0
) h i d eฺ
DEFAULT bu 8388608 0 m
co nt Gu
Shared IO 8388608 i
8388608 l ฺ
PGA Target 180355072
g ma tude
0

u k i@ is S
sy se th
7 rows selected.
a
(M to u
u k i
SQL> select substr(COMPONENT,
e
0, 10), FINAL_SIZE, OPER_TYPE,

a sy cens
OPER_MODE,
START_TIME;
status from v$memory_resize_ops order by

y M li
l e
n SUBSTR(COM FINAL_SIZE OPER_TYPE
Sta
OPER_MODE STATUS
---------- ---------- ------------- --------- ---------
DEFAULT bu 113246208 STATIC IMMEDIATE COMPLETE
large pool 4194304 GROW IMMEDIATE COMPLETE
shared poo 62914560 GROW IMMEDIATE COMPLETE
DEFAULT bu 104857600 SHRINK IMMEDIATE COMPLETE
shared poo 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 109051904 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
ASM Buffer 0 STATIC COMPLETE
PGA Target 100663296 STATIC COMPLETE
shared poo 54525952 STATIC COMPLETE
large pool 4194304 STATIC COMPLETE
java pool 4194304 STATIC COMPLETE
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE

Oracle Database 11g: Administration Workshop II A-217


Computer Pride Limited

RECYCLE bu 0 STATIC COMPLETE


DEFAULT 2K 0 STATIC COMPLETE
DEFAULT 4K 0 STATIC COMPLETE
DEFAULT 8K 0 STATIC COMPLETE
DEFAULT 16 0 STATIC COMPLETE
DEFAULT 32 0 STATIC COMPLETE
DEFAULT bu 100663296 SHRINK IMMEDIATE COMPLETE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

large pool 8388608 GROW IMMEDIATE COMPLETE


DEFAULT bu 88080384 SHRINK IMMEDIATE COMPLETE
large pool 16777216 GROW IMMEDIATE COMPLETE
DEFAULT bu 92274688 SHRINK IMMEDIATE COMPLETE
large pool 12582912 GROW IMMEDIATE COMPLETE
DEFAULT bu 96468992 SHRINK IMMEDIATE COMPLETE
large pool 20971520 GROW IMMEDIATE COMPLETE
DEFAULT bu 83886080 SHRINK IMMEDIATE COMPLETE
large pool 25165824 GROW IMMEDIATE COMPLETE
DEFAULT bu 79691776 SHRINK IMMEDIATE COMPLETE
large pool 29360128 GROW IMMEDIATE COMPLETE
ble
large pool
DEFAULT bu
71303168
37748736
GROW
SHRINK
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE fe r a
large pool 67108864 GROW IMMEDIATE COMPLETE
ans
DEFAULT bu 41943040 SHRINK IMMEDIATE
n
COMPLETE - t r
large pool 62914560 GROW IMMEDIATE
a noCOMPLETE
DEFAULT bu 75497472 SHRINK s
IMMEDIATE
a COMPLETE
large pool 33554432 GROW
) h
IMMEDIATE
i d eฺ
COMPLETE
DEFAULT bu 71303168 SHRINK m
co nt Gu
IMMEDIATE COMPLETE
large pool 37748736 GROWi l ฺ IMMEDIATE COMPLETE
DEFAULT bu 71303168
g ma tude
SHRINK IMMEDIATE COMPLETE
large pool 37748736
u k i@ is S
GROW IMMEDIATE COMPLETE
DEFAULT bu
large pool a sy se th
67108864
41943040
SHRINK
GROW
IMMEDIATE
IMMEDIATE
COMPLETE
COMPLETE
DEFAULT bu
k i (M to u
62914560 SHRINK IMMEDIATE COMPLETE

a syu cense
large pool 46137344 GROW IMMEDIATE COMPLETE

yM li
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE

nle large pool 50331648 GROW IMMEDIATE COMPLETE

Sta
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
large pool 50331648 GROW IMMEDIATE COMPLETE
DEFAULT bu 54525952 SHRINK IMMEDIATE COMPLETE
large pool 54525952 GROW IMMEDIATE COMPLETE
DEFAULT bu 50331648 SHRINK IMMEDIATE COMPLETE
large pool 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 46137344 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 33554432 SHRINK IMMEDIATE COMPLETE
large pool 75497472 GROW IMMEDIATE COMPLETE
large pool 79691776 GROW IMMEDIATE COMPLETE
DEFAULT bu 29360128 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
DEFAULT bu 20971520 SHRINK IMMEDIATE COMPLETE
large pool 88080384 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE

Oracle Database 11g: Administration Workshop II A-218


Computer Pride Limited

large pool 92274688 GROW IMMEDIATE COMPLETE


DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
large pool 92274688 GROW IMMEDIATE COMPLETE
DEFAULT bu 12582912 SHRINK IMMEDIATE COMPLETE
large pool 96468992 GROW IMMEDIATE COMPLETE
DEFAULT bu 8388608 SHRINK IMMEDIATE COMPLETE
large pool 100663296 GROW IMMEDIATE COMPLETE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

shared poo 58720256 SHRINK DEFERRED ERROR


DEFAULT bu 12582912 GROW DEFERRED ERROR
DEFAULT bu 8388608 SHRINK IMMEDIATE COMPLETE
shared poo 62914560 GROW IMMEDIATE COMPLETE
shared poo 62914560 SHRINK DEFERRED ERROR
DEFAULT bu 8388608 GROW DEFERRED ERROR
shared poo 62914560 SHRINK DEFERRED ERROR
DEFAULT bu 8388608 GROW DEFERRED ERROR
large pool 12582912 SHRINK DEFERRED COMPLETE
DEFAULT bu 96468992 GROW DEFERRED COMPLETE
shared poo 62914560 SHRINK DEFERRED ERROR
ble
DEFAULT bu
large pool
96468992
8388608
GROW
SHRINK
DEFERRED
DEFERRED
ERROR
COMPLETE fe r a
DEFAULT bu 100663296 GROW DEFERRED COMPLETE
ans
SGA Target 176160768 SHRINK DEFERRED
n
COMPLETE - t r
DEFAULT bu 79691776 SHRINK DEFERRED
a noCOMPLETE
PGA Target 117440512 GROW s
DEFERRED
a COMPLETE
SGA Target 167772160 SHRINK
) h
DEFERRED
i d eฺ
COMPLETE
DEFAULT bu 71303168 SHRINK m
co nt Gu
DEFERRED COMPLETE
PGA Target 125829120 GROWi l ฺ DEFERRED COMPLETE
SGA Target 159383552
g ma tude
SHRINK DEFERRED COMPLETE
DEFAULT bu 62914560
u k i@ is S
SHRINK DEFERRED COMPLETE
PGA Target
large pool a sy se th
134217728
4194304
GROW
SHRINK
DEFERRED
DEFERRED
COMPLETE
COMPLETE
DEFAULT bu
k i (M to u
67108864 GROW DEFERRED COMPLETE

a syu cense
SGA Target 146800640 SHRINK DEFERRED COMPLETE

yM li
DEFAULT bu 54525952 SHRINK DEFERRED COMPLETE

nle PGA Target 146800640 GROW DEFERRED COMPLETE

Sta
SGA Target 142606336 SHRINK DEFERRED COMPLETE
DEFAULT bu 50331648 SHRINK DEFERRED COMPLETE
PGA Target 150994944 GROW DEFERRED COMPLETE
SGA Target 138412032 SHRINK DEFERRED COMPLETE
DEFAULT bu 46137344 SHRINK DEFERRED COMPLETE
PGA Target 155189248 GROW DEFERRED COMPLETE
SGA Target 134217728 SHRINK DEFERRED COMPLETE
DEFAULT bu 41943040 SHRINK DEFERRED COMPLETE
PGA Target 159383552 GROW DEFERRED COMPLETE
SGA Target 130023424 SHRINK DEFERRED COMPLETE
DEFAULT bu 37748736 SHRINK DEFERRED COMPLETE
PGA Target 163577856 GROW DEFERRED COMPLETE
SGA Target 125829120 SHRINK DEFERRED COMPLETE
DEFAULT bu 33554432 SHRINK DEFERRED COMPLETE
PGA Target 167772160 GROW DEFERRED COMPLETE
DEFAULT bu 29360128 SHRINK DEFERRED COMPLETE
SGA Target 121634816 SHRINK DEFERRED COMPLETE
PGA Target 171966464 GROW DEFERRED COMPLETE

Oracle Database 11g: Administration Workshop II A-219


Computer Pride Limited

DEFAULT bu 25165824 SHRINK DEFERRED COMPLETE


SGA Target 117440512 SHRINK DEFERRED COMPLETE
PGA Target 176160768 GROW DEFERRED COMPLETE
SGA Target 113246208 SHRINK DEFERRED COMPLETE
DEFAULT bu 20971520 SHRINK DEFERRED COMPLETE
PGA Target 180355072 GROW DEFERRED COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

shared poo 71303168 GROW IMMEDIATE COMPLETE


DEFAULT bu 12582912 SHRINK IMMEDIATE COMPLETE
shared poo 75497472 GROW IMMEDIATE COMPLETE
DEFAULT bu 8388608 SHRINK IMMEDIATE COMPLETE
shared poo 79691776 GROW IMMEDIATE COMPLETE

134 rows selected.

SQL>
SQL>
SQL> exit
ble
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.5.0 - Beta fe r a
With the Partitioning, OLAP and Data Mining options
ans
$
n - t r
a no
10) From a terminal window, restart Enterprise Manager Database Control and look at the
a s
) h i d eฺ
memory variations that happened during this lab. What do you observe?
c m
o t Gu
$ emctl start dbconsole
i l ฺ n
11.1.0.4.0 g ma tudeControl
Oracle Enterprise Manager 11g Database Release

Copyright (c) 1996, 2007 k i@ S


OracleisCorporation. All rights
s y u t h
se
reserved.
( M a u
https://stbbv07.us.oracle.com:1158/em/console/aboutApplication
u
Starting Oracle to
ki Enterprise
e Manager 11g Database Control
y
.......sstarted.
a licen s
M
--------------------------------------------------------------
y
nle----
Sta Logs are generated in directory
/u01/app/oracle/product/11.1.0/db_2/stbbv07.us.oracle.com_orcl
/sysman/log
$

a) Go to the Enterprise Manager Home page.


b) Click the Server tab.
c) On the Server tabbed page, click Memory Advisors in the Database Configuration
section.
d) On the Memory Advisors page, look at the first two graphics.
e) You should see that the large pool was raised, the total SGA was also raised, and
then the SGA was shrunk for the benefit of the PGA.

Oracle Database 11g: Administration Workshop II A-220


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
t r a ns
n
11) To clean up your environment, shut down your database instance, restore
o - original
the
a n
SPFILE, and restart your database instance. Running the amm_cleanup.sh script
accomplishes the same task. s
ha ideฺ
)
m Gu
$ sqlplus sys/oracle as sysdba
ฺ c o t
SQL> shutdown immediate;
a il e n
SQL> exit m tud
g$ORACLE_HOME/dbs/spfileorcl.ora
$ cp /tmp/spfileorcl_bu.ora i @
ksysdba i s S
$ sqlplus sys/oracleyas
s u t h
a u s e
(M
SQL> startup;
SQL> drop user
k i t o
amm cascade;
SQL> drop
a s y e n se tbssga including contents and datafiles;
utablespace
y Mexit lic
SQL> drop tablespace mytemp including contents and datafiles;
leSQL>

Stan

Oracle Database 11g: Administration Workshop II A-221


Computer Pride Limited

Practices for Lesson 15

Practice 15-1: Monitoring Services


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In your database there are several running applications. You want to monitor the
resources that are being used by each application. Create a service configuration for each
application or application function that uses your database.

In this practice, you create the following configuration in the orcl database:

Service Name Usage Response Time (sec)–


Warning/Critical
SERV1 Client service 0.4, 1.0
ble
fe r a
1) Use the DBMS_SERVICE package to create a service called SERV1. Then make sure
ans
that you add your service name to your tnsnames.ora file.
n - t r
no
a) The recommended method for adding a service name to the tnsnames.ora file
a
a s
) i d eฺ
is to use Net Manager. For this exercise, execute the add_service.sh script.
h
m
co nt Gu
Review the tnsnames.ora file at $ORACLE_HOME/network/admin to
i l ฺ
confirm that the following lines are included. Substitute the output of the
ma tude
hostname command for <hostname> below.
g
u k i@ is S
SERV1 =
(DESCRIPTION = asy e th
(ADDRESS =(M
i o
(PROTOCOL
t us= TCP)
y
(HOSTu k= <hostname>.us.oracle.com)(PORT
s e = 1521))
s
a(SERVER
(CONNECT_DATA
c n
e= DEDICATED)
=
M l i
y (SERVICE_NAME = SERV1.us.oracle.com)
nle
Sta )
)

$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ cd /home/oracle/labs
$ ./add_service.sh
edrsr3p1
$

b) Use the DBMS_SERVICE.CREATE_SERVICE procedure to create a service.


$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 8


00:48:43 2005

Oracle Database 11g: Administration Workshop II A - 222


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Production
With the Partitioning, OLAP and Data Mining options

SQL> EXEC -
DBMS_SERVICE.CREATE_SERVICE('SERV1','SERV1.us.oracle.com')

PL/SQL procedure successfully completed.

SQL> exit;
Disconnected from Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Production
ble
With the Partitioning, OLAP and Data Mining options
fe r a
ans
2) After you have created your services, try connecting to your database by using your
service name. What happens? Why?
n - t r
a no
Answer: You cannot connect using your service because although it is defined, it is
a s
) i d eฺ
not started on your instance. You can verify this by looking at the SERVICE_NAME
h
m
o t Gu
initialization parameter and by looking at the services known to the listener.
c
i l ฺ
m tuden
[oracle@edrsr3p1 labss]$ lsnrctla services
g
LSNRCTL for Linux: Versionk i S - Production on 16-MAY-
i@11.1.0.6.0
s
2008 02:38:51 u
sy se t h
a
M t2007,
(1991, u Oracle. All rights reserved.
k i o
yu ense
Copyright (c)
a s
yM
Connecting ic
lto
n l e
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
Sta Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for
this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "orcl.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
Service "orclXDB.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):

Oracle Database 11g: Administration Workshop II A-223


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


"D000" established:0 refused:0 current:0 max:1022
state:ready
DISPATCHER <machine: edrsr3p1, pid: 8787>

(ADDRESS=(PROTOCOL=tcp)(HOST=edrsr3p1.us.oracle.com)(PORT=2796
9))
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Service "orcl_XPT.oracle.com" has 1 instance(s).


Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
Service "prod.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:21 refused:0 state:ready
ble
LOCAL SERVER
Service "orclXDB.oracle.com" has 1 instance(s). fe r a
Instance "orcl", status READY, has 1 handler(s) for this ans
service... n - t r
Handler(s):
a no
"D000" established:0 refused:0 current:0 max:1022
a s
state:ready ) h i d eฺ
m
co nt Gu
DISPATCHER <machine: edrsr3p1, pid: 5119>
i l ฺ
g ma tude
(ADDRESS=(PROTOCOL=tcp)(HOST=edrsr3p1.us.oracle.com)(PORT=5940
6))
k i@ has i s S
y u
Service "prod_XPT.oracle.com"
sstatus h
t has 1 instance(s).
a
Instance "prod",
u s e
READY, 1 handler(s) for this
service... i (M
y u k se to
Handler(s):
s cen established:21 refused:0 state:ready
a"DEDICATED"
y M li SERVER
l e LOCAL
n The command completed successfully
Sta
[oracle@edrsr3p1 solutions]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 8


00:56:30 2005

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
Production
With the Partitioning, OLAP and Data Mining options

SQL> show parameter service

NAME TYPE VALUE

Oracle Database 11g: Administration Workshop II A-224


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


----------------------------- ----------- ----------------
service_names string orcl.oracle.com
SQL> connect system/oracle@SERV1
ERROR:
ORA-12514: TNS:listener does not currently know of service
requested in connect
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

descriptor

Warning: You are no longer connected to ORACLE.


SQL> exit
$

3) How would you make sure that you can connect using your service? Do it and
connect to your instance using your service.
Answer: You must start your service on your instance.
ble
$ sqlplus / as sysdba
fe r a
s
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug n8-t
ran
13:01:54 2007
a no
a s
Copyright (c) 1982, 2007, Oracle. All rights ) h i d eฺ
reserved.
m
co nt Gu
i l ฺ
Connected to: g ma tude
k i@ iEdition
Oracle Database 11g Enterprise
s S Release 11.1.0.6.0 -
Production u
sy Oracle h
t Label Security, OLAP, Data
a s e
(M to u
With the Partitioning,
Mining
k i
s u cense Testing options
and Real yApplication
a
yM li
l e
n SQL> show parameter service
Sta
NAME TYPE VALUE
----------------------------- ----------- ----------------
service_names string orcl.us.oracle.com

SQL> EXEC DBMS_SERVICE.START_SERVICE('SERV1');

PL/SQL procedure successfully completed.

SQL> show parameter service

NAME TYPE VALUE


------------------------- ----------- --------------------
service_names string SERV1.us.oracle.com

SQL> host lsnrctl services

Oracle Database 11g: Administration Workshop II A-225


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 08-AUG-
2007 13:08:08

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Connecting to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:50 refused:0 state:ready
LOCAL SERVER
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this
service...
ble
Handler(s):
"DEDICATED" established:50 refused:0 state:ready fe r a
LOCAL SERVER ans
Service "SERV1.us.oracle.com" has 1 instance(s). n - t r
no
Instance "orcl", status READY, has 1 handler(s) for this
a
service...
a s
Handler(s): ) h i d eฺ
m
co nt Gu
"DEDICATED" established:0 refused:0 state:ready
i l ฺ
ma tude
LOCAL SERVER
g
Service "orcl.us.oracle.com" has 1 instance(s).

u k i@ is S
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):a sy se th
k i (M to u
"DEDICATED" established:0 refused:0 state:ready

a syu cense
LOCAL SERVER

yM li
Service "orclXDB.us.oracle.com" has 1 instance(s).

nle Instance "orcl", status READY, has 1 handler(s) for this

Sta
service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022
state:ready
DISPATCHER <machine: edsor6p2.us.oracle.com, pid:
17352>

(ADDRESS=(PROTOCOL=tcp)(HOST=edsor6p2.us.oracle.com)(PORT=3614
0))
Service "orcl_XPT.us.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully

SQL> connect system/oracle@SERV1

Oracle Database 11g: Administration Workshop II A-226


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


Connected.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

and Real Application Testing options

4) Execute the serv1_load.sh script as SYSDBA. This script creates a new user and
then connects to your instance using this user and the SERV1 service. The script then
executes the following query:
SELECT COUNT(*) FROM DBA_OBJECTS,DBA_OBJECTS,DBA_OBJECTS

Note: Do not wait for the script to complete before proceeding to the next step.
$ cd /home/oracle/labs
$ ./serv1_load.sh
ble
fe r a
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 8
an s
13:16:24 2007
n - t r
Copyright (c) 1982, 2007, Oracle. a no
All rights reserved.
a s
) h i d eฺ
c m
o t Gu
Connected to:
i l ฺ
ma tuden
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production g S Security, OLAP, Data
With the Partitioning, k
u i@ Label
Oracle
i s
Mining syTesting
e t h
(
and Real Application a s
M to u options
i
k SQL>
s
SQL> SQL>
a y uSQL>
e n se SQL> drop user jfv cascade
M at line*lic
y
nle
ERROR 1:
Sta ORA-01918: user 'JFV' does not exist

SQL> SQL> 2 3
User created.

SQL> SQL>
Grant succeeded.

SQL> SQL> Connected.


SQL> SQL>

5) After the execution starts, access the EM Top Consumers page from the Performance
tabbed page, and check if SERV1 is using more resources. Also, check the statistics
on your service with V$SERVICE_STATS from a SQL*Plus session connected as
SYSDBA.

Oracle Database 11g: Administration Workshop II A-227


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


a) On the home page, click the Performance tab. In the middle of the Performance
page, click the Services tab. An Active Session graph with the activity aggregated
by service name is displayed. The network service name of each connection is
recorded as a separate service. So all the connections made without a service
name are aggregated, as are all the connections made as SERV1.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

b) Click the Top Consumers link in the Related Links section. Refresh the Top
Consumers Overview page several times. The names and number of services
listed in the Top Services Graph depends on the number and type of connections
to the database.
c) You can also see the detailed statistics by clicking the Top Services tab…
d) … and then by clicking the SERV1 link…
e) … and then by clicking the Statistics tab.
f) Make sure that you stop your running workload by pressing Ctrl + C in your
terminal window if necessary. ble
fe r a
SQL> SQL> select count(*) from
ans
dba_objects,dba_objects,dba_objects
n - t r
ERROR at line 1:
*
a no
a s
ORA-01013: user requested cancel of current operation
) h i d eฺ
m
co nt Gu
i
a del ฺ
g m tu
k i @
SQL> SQL> Disconnected from Oracle Database
i s S 11g Enterprise

syu Oracle thLabel Security, OLAP, Data


Edition Release 11.1.0.6.0 - Production
With the Partitioning,
a
M to us e
Mining
i (
s y uk nse Testing options
and Real Application

M athresholds
6) Set alert l i c efor your SERV1 service by using Database Control. Specify the
y
nlevalues defined at the beginning of this practice.
Sta a) On the Database Control home page, click the Metric and Policy Settings link in
the Related Links section.
b) On the Metric and Policy Settings page, select View All Metrics. Find the metric
called Service Response Time (per user call) (microseconds).
c) Click the multiple-edit icon in the right column of the row.
d) On the Edit Advanced Settings: Service Response Time (per user call)
(microseconds) page, click Add. Enter SERV1 in the Service Name field,
40000000 in the Warning Threshold field, and 100000000 in the Critical
Threshold field. Click Continue.
e) Back on the Metric and Policy Settings page, click OK.
f) On the Confirmation page, click OK.
g) Back on the home page, click the All Metrics link in the Related Links section.

Oracle Database 11g: Administration Workshop II A-228


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


h) On the All Metrics page, expand the Database Services link.
i) On the All Metrics page, click the “Service Response Time (per user call)
(microseconds)” link.
j) On the Service Response Time (per user call) (microseconds) page, click the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SERV1 link in the Service Name column.


k) On the Service Response Time (per user call) (microseconds): Service Name
SERV1 page, select “Real Time: 30 Second Refresh” from the View Data drop-
down list. Do not close this window; you will return to it in the next step.
7) From your terminal emulator session, execute the serv1_load2.sh script. This
script executes a workload under the SERV1 service. Observe the Metric Value graph
on the Service Response Time (per user call) (microseconds): Service Name SERV1
page. What is your conclusion? You see that the metric passes the warning threshold.
Soon after, you see an alert raised on the Database Console.
a) Execute the script. It takes a while to complete. Do not wait until it completes. ble
Look at the corresponding threshold history by using Database Control. Return to fe r a
the Service Response Time (per user call) (microseconds): Service Name SERV1 an s
page from the previous step. n - t r
a no
$ ./serv1_load2.sh
a s
) h i d eฺ
SQL*Plus: Release 11.1.0.6.0 - Production m
co ntonGWedu Aug 8
i l ฺ
ma tude
14:45:27 2007
g SAll rights reserved.
Copyright (c) 1982, 2007,
u k i@Oracle.
i s
sy se t h
a u
Connected to:i (M t o
k se Enterprise Edition Release 11.1.0.6.0
a syu cen11g
Oracle Database -
li
y Mthe Partitioning,
Production
l e
With
n Mining
Oracle Label Security, OLAP, Data

Sta and Real Application Testing options

SQL> SQL> SQL> SQL> Connected.


SQL> SQL> 2 3 4 5 6 7 8

b) On the Service Response Time (per user call) (microseconds): Service Name
SERV1 page, monitor the Metric Value graph. The graph should show the Service
Response Time in the warning region.
8) Use Database Control to remove the thresholds that you specified during this practice.
a) On the Database Control home page, click the Metric and Policy Settings link in
the Related Links section.
b) On the Metrics and Policy Settings page, select View All Metrics. Find the metric
called “Service Response Time (per user call) (microseconds)”.
c) Click the multiple-edit icon button in the right column of the row.

Oracle Database 11g: Administration Workshop II A-229


Computer Pride Limited

Practice 15-1: Monitoring Services (continued)


d) On the Edit Advanced Settings: Service Response Time (per user call)
(microseconds) page, select the SERV1 service, click Remove, and then click
Continue.
e) On the Metric and Policy Settings page, click OK.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

f) On the Confirmation page, click OK.

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-230


Computer Pride Limited

Practice 15-2: Using SQL Tuning Advisor


In this practice/task, you use Enterprise Manager Performance Pages to identify a high-
load SQL statement and the SQL Tuning advisor to tune it.

Identifying a High-Load SQL Statement


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

1) Open a command-line window. Start a SQL*Plus session, connect as sys and disable
Flashback Database, and then exit SQL*Plus. Change to the $HOME/labs directory
under workshop directory. Then run the setup_perflab.sh script:
$ sqlplus sys/oracle as sysdba
SQL> ALTER DATABASE FLASHBACK OFF;
exit
$ cd $HOME/labs
$ ./setup_perflab.sh

Note: This script takes a few minutes to run. The script starts a number of user e
sessions to use up resources. If you run this script but for any reason do not complete r a bl
the workshop immediately, run the cleanup script cleanup_perflab.sh as s fe
instructed at the end of this workshop ($./cleanup_perflab.sh) to stop the- t r an
no n
sessions. When you complete the entire workshop as instructed, your machine returns
a
to optimum performance. But Oracle still recommends that you run the cleanup script
s
h a
at the end so that the other labs and workshops are not affected.
) eฺ
m u i d
2) Run the start_perflab.sh script to startlthe
i ฺ coworkload.
t G Do not wait for this
script to finish before moving on to the following
g den
ma tusteps.
$ ./start_perflab.sh
u k i@ is S
a s y e th
3) Open a browser andM
i ( t o us URL:
enter the following

y uk nse
https://<hostname>:1158/em
s
M
Specify
asys aslithe
c eusername and oracle as the password. Select SYSDBA from
y
nlethe Connect As drop-down list, and then click Login.
Sta 4) Click the Performance tab.
5) In the Performance window, view the Average Active Sessions graph. A chart
representing the current workload of your database is shown. (It may take a minute
for the chart to be populated with data.) To the side of the graph is the legend. Each
legend entry is coded to a different color. Wait at this step for about two minutes until
the active sessions graph starts to flatten out.
6) Below the legend and to the right of the Active Sessions graph, click Top Activity.
7) In the Top SQL area on the Top Activity page, there is one SQL statement causing
the majority of the database wait. Drill down to find the root cause. Click the SQL ID
for that SQL statement.

Oracle Database 11g: Administration Workshop II A - 231


Computer Pride Limited

8) On the SQL Details page, the activity graph is displayed. Click the Statistics tab to
view the statistics. The statistical analysis chart for this SQL statement is displayed.
In the Execution Statistics area the statistic of interest for this statement is Buffer
Gets. Note the value of Buffer Gets per execution and CPU Time per execution.
______________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

______________________
9) Click the Plan tab and scroll down to determine the reason for the high value of
Buffer Gets. Look for Table Access Full in the Explain Plan Operations column.
10) From the displayed charts, it can be determined that CPU resource usage is the
primary resource bottleneck. Buffer Gets is the primary source of the CPU usage.
Sessions wait on the CPU resources. You are now ready to tune the SQL statement by
using the SQL Tuning Advisor.

Tuning a SQL Statement by Using the SQL Tuning Advisor


ble
As determined in the previous section, the targeted SQL statement needs tuning. The fe r a
SQL Tuning Advisor tunes the execution plan for you. Perform the following steps: ans
n - t r
a no
11) Click Schedule SQL Tuning Advisor. a s
12) In the Schedule Advisor window, make sure that them
h i d eฺ is
) Comprehensive
selected and that the job is scheduled immediately.i l ฺ
Scope
t Gu
coClicknSubmit.
m a de
13) The SQL Tuning Advisor creates a task
i @ g to analyze
S tuthe SQL statement and on
completion of this task, displays
y is recommendations.
uka set ofthtuning
s
a usepage appears, click the New Explain Plan
14) When the Tuning Recommendations
( M o
eyeglasses iconktoi view the tsuggested changes for each recommendation.
Note: One y u
s or more n s e
M
indexes
aremovesl i c erecommendations may be given. The recommendation to add
all full table scans from the explain plan and may have the highest
l y It removes full-table scans by creating new indexes. After reviewing the New
ebenefit.
n
ta Explain Plan, click the Back button on the browser to return to the Recommendations
S
page.

Oracle Database 11g: Administration Workshop II A-232


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
t r a ns
n
15) On the Recommendations page, select the Index recommendation thatocreates -
an
indexes, and then click the Implement button to implement the tuning
s
recommendation.
) ha ideฺ
16) On the Implement Recommendation page, clickcOK. o m Gu
a ฺ t
il the Create
n
17) A confirmation message appears indicating
g that e
m tud indexes job was
@ istabSand then the Performance tab.
successfully submitted. Click the iDatabase
k
u
sy for
Reviewing SQL Execution Details th Statement
a SQL
a s e
i (M totheutuning
Now that you havekimplemented suggestion, review the SQL statement and its
y u
execution details. Perform s e
the following steps:
M as licen
l e y down to the Average Active sessions chart. Wait for about a minute and then
18) Scroll

Stan observe how the CPU Usage and Average Load behave. There may be an increase in
the graph corresponding the index creation.
19) The graph of CPU usage in the Average Active Session Graph may or may not
decrease depending on the machine type you use. Click Top Activity again.
20) Select the SQL statement with the highest activity. Click the SQL ID. This is the
same statement as before. There may be multiple entries for this statement but both
take you to the same detail page.
21) On the SQL Details page, click the Plan tab. Then check each Plan Hash Value in
turn until you find the plan that uses the index with name starting with IDX$$%.
Leave the plan hash value set to that value and click the Statistics tab to view the
statistics for that plan.
Note: While checking, some plan hash values may show that the plan is not available.
These are plans that have aged out or not captured by the ASH sampling.
22) Observe the Buffer Gets per execution and CPU Time per execution for this plan.

Oracle Database 11g: Administration Workshop II A-233


Computer Pride Limited

______________
______________
23) Reducing Buffer Gets is good, but this plan is not good enough. The CPU time has
not changed significantly. Click the Plan tab.
24) In the explain plan there is still a Table Access Full shown. Only one of the indexes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

recommended by the previous tuning task was created.


25) Click the Tuning History tab. Note the time of the last tuning task ___________.
26) Click the name of the latest tuning task. On the Tuning Results page, Click View.
27) On the Recommendations page, note that there are two indexes recommended:
SH.CUSTOMERS("CUST_FIRST_NAME")and SH.SALES("CUST_ID").
28) Navigate to the Index listing. Click the Database tab, the Schema tab, and then the
Index link in the Database Objects section.
29) On the Indexes page, enter SH in the Schema field, and click Go. Click the Table
ble
heading to sort the listing by table name.
fe r a
a) Find the index on SH.CUSTOMERS("CUST_FIRST_NAME"). Note that it has ans
a system-generated name starting with IDX$$. n - t r
n o
b) Find the index on SH.SALES("CUST_ID"). Note that s a
this index is a
partitioned index named SALES_CUST_BIX. The )existence of h a ethisฺ index
m i d
uone index can be
prevented the recommended index from being
l ฺ c ocreated.t Only
G
i
created over a unique set of columns. a
g m tuden
30) Navigate to the SQL Detail page iand
k @Statistics
i s Stab for the most active statement. Wait
s y
until a few minutes have elapsed u since t h
the last tuning task was executed. This is the
time you recorded inM a
step 25. Selecte
us the most active SQL statement (this should be the
same SQL_ID as i
k sein( t
previous osteps), and then click Schedule SQL Tuning Advisor.
y u
s cSQL
31) On the a
M Schedule
l i enTuning Advisor page, confirm the job is scheduled to execute
l y
eimmediately, and then click Submit. If the Tuning Advisor does not return a
ta n recommendation, schedule it again.
S 32) When the SQL Profile recommendation appears, click the New Explain Plan
eyeglasses. Check the new explain plan for table access methods.
Question: Are there any Table Access Full operations?
Answer: No.
33) Click the browser Back button. Then, on the Recommendations page, click
Implement. On the Confirmation page, click Yes.
34) Navigate to the Performance page and observe the Average Load graph and the
Average Active Sessions graph. The value of each should drop significantly; wait
until the graph drops to near zero.

Oracle Database 11g: Administration Workshop II A-234


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

35) Navigate to the SQL ID Detail page, click the Plan tab, and set each plan hash value ble
in turn until you find the one that does not have a Table Access Full operation and fe r a
does use both indexes, SALES_CUST_BIX and IDX$$%. If the plan does not ans
n - t r
appear in the list, wait for a few moments, refresh the page, and then check for a new
plan. a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

36) Leaving the plan hash value set to the one found in the previous step, click the
Statistics tab. Note that the statistics graph for this plan statistics may appear blank
because the values are so small. View the statistics. Note that the CPU Time per
execution and Buffer Gets per execution have decreased significantly.

Oracle Database 11g: Administration Workshop II A-235


Computer Pride Limited

37) To clean up your environment, execute the following command from your command-
line window. This script can take up to 15 minutes to finish.

$ cd $HOME/labs
$ ./cleanup_perflab.sh
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

38) Close your browser.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-236


Computer Pride Limited

Practices for Lesson 16

In this practice, you use the segment advisor capabilities.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A - 237


Computer Pride Limited

Solution for Practice 16-1: Managing Storage


Background: To prepare for an upcoming merger, you want to set the warning and
critical thresholds to a lower value than the default. Ensure that you receive early
warnings to give you more time to react. When you finish your test case, drop the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

tablespace that you used.


Log in as the SYS user (with oracle password, connect as SYSDBA) and perform the
necessary tasks through Enterprise Manager Database Control or through SQL*Plus. All
scripts for this practice are in the /home/oracle/labs directory.

1. Using the DBMS_SERVER_ALERT.SET_THRESHOLD procedure, reset the


databasewide threshold values for the Tablespace Space Usage metric.

a. Connect to a SQL*Plus session and execute the procedure as in the following:


ble
$ sqlplus / as sysdba
SQL> exec DBMS_SERVER_ALERT.SET_THRESHOLD(- fe r a
dbms_server_alert.tablespace_pct_full,- ans
NULL,NULL,NULL,NULL,1,1,NULL,- n - t r
dbms_server_alert.object_type_tablespace,NULL);
a no
a s
)
2. From a SQL*Plus session, check the databasewide threshold h values
i d eforฺ the
Tablespace Space Usage metric using the following m
co command:
G u
i l ฺ t
g ma query: u d en
k i @ is St
a. Log in to SQL*Plus and run the following
$ sqlplus / as sysdba
a syu se th
(M to u
SQL> SELECT warning_value,critical_value
FROM
k i
dba_thresholds

AND as
yu enseIS NULL;
WHERE metrics_name='Tablespace Space Usage'

yM lic
object_name
l e
n WARNING_VALUE
Sta --------------------------------------------------------------------
CRITICAL_VALUE
--------------------------------------------------------------------
85
97

3. Create a new tablespace called TBSALERT with a 120 MB file called


tbsalert.dbf. Make sure that this tablespace is locally managed and uses
Automatic Segment Space Management. Do not make it autoextensible, and do not
specify any thresholds for this tablespace. Use Enterprise Manager Database Control
to create it. If this tablespace already exists in your database, drop it first, including its
files.

a. In Enterprise Manager, select Server > Tablespaces.

b. Click the Create button.

Oracle Database 11g: Administration Workshop II A-238


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


c. Enter TBSALERT as the name, and click the Add button in the Datafiles region.

d. Select File System as Storage Type, enter tbsalert.dbf as File Name,


/u01/app/oracle/oradata/orcl/ as File Directory and 120 MB as File
Size, and select the Reuse Exisiting File check box.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
e. Click Continue and then click OK to create the tablespace. n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
TablespaceSSpace Usage thresholds of the
u
TBSALERT tablespace. Setyits ki@
4. In Enterprise Manager, change the
warningt h is to 55 percent and its critical level to 70
level
percent.
s
a use
( M to
y u ki spage,
e
a. On the
a s cen
Tablespaces select TBSALERT, click Edit, and then click
M li
y Thresholds.
n l e
Sta b. Select Specify Thresholds, and enter 55 as Warning (%) and 70 as Critical (%)
under the Space Used section.

Oracle Database 11g: Administration Workshop II A-239


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

c. Click Apply to modify the threshold values.


ble
fe r a
5. Using SQL*Plus, check the new threshold values for the TBSALERT tablespace.
ans
n - t r
a. In your SQL*Plus session, enter:
a no
a s
SQL> select warning_value,critical_value
) h i d eฺ
from dba_thresholds
c m
oUsage't G u
where metrics_name='Tablespace Space
i l ฺ and
object_name='TBSALERT';
g ma tuden
The result should be: u k i@ is S
a s y e th
WARNING_VALUE M
i ( t o us
CRITICAL_VALUE

55
s y uk n70se
--------------- ---------------

M a lice
y
n6. leQuery the reason and resolution columns from DBA_ALERT_HISTORY for
Sta the TBSALERT tablespace.

a. In your SQL*Plus session, enter:


SQL> select reason,resolution
from dba_alert_history
where object_name='TBSALERT';

The result should be (if you are repeating this practice, look at the last row):
REASON
RESOLUT
-------------------------------------------------------- ----
---
Threshold is updated on metrics "Tablespace Space Usage"
cleared

Oracle Database 11g: Administration Workshop II A-240


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


7. From the labs directory, execute the seg_advsr_setup.sh script that creates and
populates new tables in the TBSALERT tablespace.
$ cd ~/labs
$ ./seg_advsr_setup.sh
create table employees1 tablespace tbsalert as select * from
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

hr.employees;
create table employees2 tablespace tbsalert as select * from
hr.employees;
create table employees3 tablespace tbsalert as select * from
hr.employees;
create table employees4 tablespace tbsalert as select * from
hr.employees;
create table employees5 tablespace tbsalert as select * from
hr.employees;

alter table employees1 enable row movement;


alter table employees2 enable row movement;
alter table employees3 enable row movement;
ble
alter table employees4 enable row movement;
fe r a
alter table employees5 enable row movement;
ans
BEGIN
n - t r
FOR i in 1..10 LOOP
a no
s
insert into employees1 select * from employees1;
a
) h
insert into employees2 select * from employees2;
i d eฺ
m
co nt Gu
insert into employees3 select * from employees3;
l ฺ
insert into employees4 select * from employees4;
i
commit; g ma tude
insert into employees5 select * from employees5;

END LOOP;
u k i@ is S
END;
a sy se th
(M to u
/
k i
insert into employees1 select * from employees1;

a syu cense
insert into employees2 select * from employees2;
insert into employees3 select * from employees3;
yM
commit; li
t a nle
S 8. Check the fullness level of the TBSALERT tablespace by using Database Control or
SQL*Plus. The current level should be around 60%. Wait a few minutes and check
that the warning level is reached for the TBSALERT tablespace.

a. In Enterprise Manager on the Tablespaces page, see Used (%).

b. Navigate to the Database home page. You should see the new alert in the Space
Summary section. It might take several minutes for the alert to appear.

Oracle Database 11g: Administration Workshop II A-241


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

c. In SQL*Plus, enter:
SQL> select sum(bytes) *100 /125829120
from dba_extents
where tablespace_name='TBSALERT';

SUM(BYTES)*100/125829120
------------------------
60

d. Enter the following query. Your results should be similar to the following: ble
fe r a
SQL> select reason
ans
from dba_outstanding_alerts
n - t r
where object_name='TBSALERT';
a no
a s
REASON
) h i d eฺ
m
co nt Gu
--------------------------------------------------------------
Tablespace [TBSALERT] is [60 percent] ฺfull
i
a del
9. Execute the inserts below to add more g m
data to S tu Wait a few moments and
k i @ i s
TBSALERT.

TBSALERT fullness is a syuthe75%.


view the critical level in both th and Database Control. Verify that
database
e
i ( M to us
around
$ sqlplus u /kas sysdba e
a s
SQL> insert
y e
inton semployees4 select * from employees4;
y
SQL>M commit; l i c
nleSQL> insert into employees5 select * from employees5;
Sta SQL> commit;

a. Wait a few minutes and view the critical level in both the database and Database
Control. Verify that TBSALERT fullness is around 75%. In SQL*Plus, enter:

SQL> select sum(bytes) *100 /125829120


from dba_extents
where tablespace_name='TBSALERT';

SUM(BYTES)*100/125829120
------------------------
75

b. Wait a few minutes. In SQL*Plus, enter:

Oracle Database 11g: Administration Workshop II A-242


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


SQL> select reason, message_level
from dba_outstanding_alerts
where object_name='TBSALERT';

REASON MESSAGE_LEVEL
-------------------------------------------- -------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Tablespace [TBSALERT] is [75 percent] full 1

c. In Enterprise Manager, on the Tablespaces page, see Used (%).

d. Navigate to the Database home page. You should see the new alert in the Space
Summary region. It will take several minutes for the change in status to take
effect. Note the red flag instead of the yellow one.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l
a rowsฺ
10. Execute the following delete statements m to delete efrom tables in TBSALERT.
These statements will take severali@ g
minutes to S tud
complete.
s y uk this
SQL> delete employees1;
SQL> commit; (Ma u se
i
SQL> deletekemployees2;
u e to
y
as employees3;
SQL> commit;
en s
M
SQL> deletelic
l y commit;
eSQL>
ta n
S 11. Now, run the Segment Advisor for the TBSALERT tablespace by using Database
Control. Make sure that you run the Advisor in Comprehensive mode without time
limitation. Accept and implement its recommendations. After the recommendations
have been implemented, check whether the fullness level of TBSALERT is below
55%.

a. From the Database home page, select Advisor Central under Related Links and
then click Segment Advisor.

b. On the Scope page, select Tablespaces and click Next. On the Objects page, click
Add, select TBSALERT, and click OK.

Oracle Database 11g: Administration Workshop II A-243


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

c. Click Next when returned to the Objects page. When returned to the Objects page,
click the Show Advanced Options link. Then click the Limited option button and
enter 30 for Time Limit (mins) and click Next.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
syuandcclick
d. On the Schedule e make sure Immediately is selected. Select the proper
page,
nsNext.
a
timezone
li e
l e yM
n e. On the Segment Advisor: Review page, click the Submit button.
Sta
f. This takes you back to the Advisor Central page, where you can see the progress
of your task. Click the Refresh button until your job is completed.

g. Select your Segment Advisor task and click the View Result button.

h. On the Segment Advisor Task page, click the Recommendation Details button.

Oracle Database 11g: Administration Workshop II A-244


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


i. Click the Select All link and then click the Implement button.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
j. On the Shrink Segment: Options page, make sure that you click the “Compact
fe r a
Segments and Release Space” option button. Click Implement.
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
sySchedule
k. On the Shrink Segment:
a e th click the Submit button.
page,
i ( M to us
s y uk nse
M a lice
y
nle
Sta

l. On the Scheduler Jobs page, click Refresh until you see your job in the Running
table. Continue to click Refresh until you no longer see your job in the Running
table. It should take approximately two minutes to complete.

Oracle Database 11g: Administration Workshop II A-245


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


m. Navigate to the Tablespaces page and verify that the TBSALERT tablespace usage
is now below 55%.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
h
) outstanding
i d eฺ
c o m
12. Wait a few minutes and check that there are no longer any
G u alerts for the
TBSALERT tablespace. ฺ
ail den t
m tu see Problem Tablespaces: 0.
g YouSshould
i
a. Navigate to the Database home @ page.
s y uk this
( M a use
y u ki se to
M as licen
y
nle
Sta

13. Retrieve the history of the TBSALERT Tablespace Space Usage metric for the last 24
hours.

a. On the Database home page, select All Metrics in the Related Links region.

b. Expand the Tablespaces Full category, and click the Tablespace Space Used (%)
link.

c. Make sure that you select Real Time: Manual Refresh from the View Data drop-
down list. Then click the TBSALERT link.

Oracle Database 11g: Administration Workshop II A-246


Computer Pride Limited

Solution for Practice 16-1: Managing Storage (continued)


d. This takes you to the Tablespace Space Used (%): Tablespace Name TBSALERT
page. Select “Last 24 hours” from the View Data drop-down list.

14. Reset the databasewide default thresholds from the Tablespace Space Usage metric
for the TBSALERT tablespace.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

a. From the context of the Tablespace Space Used (%): Tablespace Name
TBSALERT page, click the Edit Tablespace link at the bottom of the page.

b. This opens the Edit Tablespace: TBSALERT page. Click the Thresholds tab.

c. Select the Use Database Default Thresholds option in the Space Used (%) section.
Click the Apply button.

15. Note: This is your mandatory cleanup step. Because you have finished with your test
case, execute the seg_advsr_cleanup.sh script from the labs directory to e
drop your TBSALERT tablespace. r a bl
s fe
$ ./seg_advsr_cleanup.sh
- t r an
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 9 no n
08:44:31 2007 s a
) h a eฺ
m i d
Copyright (c) 1982, 2007, Oracle. All
i l ฺ co nt Gu
rights reserved.

SQL> Connected.
g ma tude
SQL>
u k i@ is S
System altered.
a sy se th
M to u
SQL> Databasei (closed.
k
u nse
Database ydismounted.
ORACLEas c e shut down.
y M i
instance
l
n l e
SQL> ORACLE instance started.

Sta Total System Global Area 627732480 bytes


Fixed Size 1301728 bytes
Variable Size 415236896 bytes
Database Buffers 205520896 bytes
Redo Buffers 5672960 bytes
Database mounted.
Database opened.
SQL> drop tablespace tbsalert including contents and datafiles

Tablespace dropped.

Oracle Database 11g: Administration Workshop II A-247


Computer Pride Limited

Practices for Lesson 17

You received complaints that certain batch jobs are using too many system resources and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

that a specific user is known to start data warehouse processes during regular business
hours. You decide to use the Database Resource Manager for better system-resource
utilization and control.
Your first effort to balance the situation includes creating an APPUSER consumer group
and assigning it to the default DEFAULT_PLAN resource plan. You then map a couple of
Oracle users and your major OS user to resource groups. Activate the resource plan and
test your assignments. Regularly click Show SQL to review all statements that are new to
you.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-248


Computer Pride Limited

Practice 17-1: Managing Resources


In this practice, you create an APPUSER consumer group and assign it to the default
DEFAULT_PLAN resource plan. Then you map a couple of Oracle users and your major
OS user to resource groups. Activate the resource plan and test your assignments.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Log in as the SYS user (with oracle password, connect as SYSDBA) and perform the
necessary tasks through Enterprise Manager Database Control or through SQL*Plus. All
scripts for this practice are in the /home/oracle/labs directory.

Whenever you open a new terminal window, execute the oraenv script to set
environment variables for the orcl database.
1) Using Enterprise Manager Database Control, create a resource group called
APPUSER. At this point, do not add users to the group.
a) In Enterprise Manager, select Server > Consumer Groups (in the Resource
ble
Manager section).
fe r a
b) On the Consumer Groups page, click the Create button. ans
n - t r
no
c) Enter APPUSER as Consumer Group and click Show SQL.
a
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta d) Review the statements.
Question 1: What does the ROUND-ROBIN parameter value mean?
Possible Answer: ROUND-ROBIN indicates that CPU resources are fairly allocated to
the APPUSER consumer group, according to the active resource plan directives.
e) Click Return, and then click OK to create the consumer group.
f) A confirmation message appears and the new consumer group is displayed. After
confirming its creation, click the “Database Instance:orcl.us.oracle.com” link.

Oracle Database 11g: Administration Workshop II A-249


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a
2) Add the APPUSER and LOW_GROUP consumer groups to the DEFAULT_PLAN no
a s
) i d eฺ
resource plan. Change the level 3 CPU resource allocation percentages: 60% for the
h
m
o t Gu
APPUSER consumer group and 40% for the LOW_GROUP consumer group.
c
i l ฺ
ma tuden
a) In Enterprise Manager, select Server > Plans.
g
k i s S
i@ DEFAULT_PLAN
b) On the Resource Plans page, select and click the Edit button.
c) Click Modify.
u
sy se t h
a
(M to u page, move APPUSER and LOW_GROUP to the
k
d) On the Select i Groups/Subplans
“Resource
a e se
syuAllocations.”
n
yM lic
n l e
Sta

e) Click OK.
f) Enter 60 for APPUSER Level 3 and 40 for LOW_GROUP Level 3.
g) Click Show SQL, review the statements, and then click Return.

Oracle Database 11g: Administration Workshop II A-250


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

h) Click Apply to assign the APPUSER consumer group to the DEFAULT_PLAN


resource plan. (You activate this plan later.)
3) Configure Consumer Group Mappings, so that the HR Oracle user belongs to the
APPUSER consumer group, and the SCOTT user to the OTHER_GROUPS consumer
group. For the SCOTT user, confirm that his ORACLE_USER attribute has a higher ble
priority than the CLIENT_OS_USER attribute. fe r a
an s
a) In Enterprise Manager, select Server > Consumer Group Mappings. n - t r
a no
s button.
b) Select Oracle User and click the “Add Rule for SelectedaType”
) h i d eฺ
c) On the Consumer Group Mappings page, ensure m Gu is selected as
co thatnAPPUSER
i l ฺ t
“Selected Consumer Group.”
g ma tude
k i@ Oracle
d) Move the HR user into the Selected
i s SUser region, and then click OK.
u
syMappings h
tGeneral Page, click Show SQL.
a
e) On the Consumer Group s e
k i (M to u
a syu cense
yM li
n l e
Sta

f) Review the statements and click Return.


g) Click Apply to assign the HR user to the APPUSER consumer group.
h) Select Oracle User again, and click the “Add Rule for Selected Type” button.
i) Select LOW_GROUP from the Selected Consumer Group drop-down list, and
move SCOTT into the Selected Oracle User area, and then click OK.
j) On the Consumer Group Mappings page, click the Priorities tab.

Oracle Database 11g: Administration Workshop II A-251


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
k) Confirm that “Oracle User” has a higher priority than “Client OS User.”
fe r a
l) Click Apply to assign the SCOTT user to the LOW_GROUP consumer group. ans
n - t r
a no
4) Configure Consumer Group Mappings so that the oracle a
h s user belongs
OS
ฺ to the
SYS_GROUP consumer group. ) id e
o m G u
ilฺc eGroup
a) In Enterprise Manager, select Server > Consumer
a n t Mappings.
b) Select Client OS User and click the
m Rule
g“Add t d Selected Type” button.
ufor
@
kiSelected S
isConsumer Group drop-down list, move
c) Select SYS_GROUP from s y uthe t h
oracle into the( M a Client
Selected u seOS User area, and click OK.
u ki se SQL, to review the statements, and click Return.
a y
d) (Optional)
s cenClick Show
M li to assign the oracle OS user to the SYS_GROUP consumer group.
e)y Click Apply
n l e
Sta

Oracle Database 11g: Administration Workshop II A-252


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
o t Gu
5) Assign the PM Oracle user to the following a ilฺc egroups:
consumer n APPUSER,
LOW_GROUP, and SYS_GROUP. m
g Stu d
i @
a) In Enterprise Manager, y
s uk Serverth>isUsers (in the Security section).
select
(
b) Select the PM user M a utheseEdit button.
and click
ki seGroups
uConsumer to
c) Clicks
a y
the
e n Privileges tab. If you see an error regarding the
M
y password licthe PM user, enter pm in both the password fields.
for
l e
n d) Click the Edit List button.
Sta e) Move the APPUSER, LOW_GROUP, and SYS_GROUP consumer groups to
Selected Consumer Groups and click OK.

Oracle Database 11g: Administration Workshop II A-253


Computer Pride Limited

f) Click Show SQL.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
g) Review the statements and click Return. ) h i d eฺ
m Gu
co ngroups.
h) Click Apply to assign the PM user to these i l ฺ
consumer t
g ma tude
u k i@ is S
6) Execute the unlock_accts.sh
a sy sscripte thto unlock the HR, SCOTT, OE, and PM
(Min the torcl
Oracle user accounts
i o u database. The script sets the passwords in
lowercase to u k
y matchethe e
susername.
a s n
a) As lic user in a terminal window, execute the oraenv script to set
Mthe oracle
y environment
n l e variables for the orcl database.
Sta $ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$

Your output may be different, depending on your previously executed tasks.


b) To unlock the HR, SCOTT, OE, and PM Oracle user accounts, enter from your
working directory:
$ ./unlock_accts.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Jul 20


09:59:56 2007

Oracle Database 11g: Administration Workshop II A-254


Computer Pride Limited

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Testing options

SQL> SQL>
User altered.

SQL>
User altered.

SQL>
User altered.

ble
SQL>
User altered. fe r a
t r a ns
SQL> SQL> Disconnected from Oracle Database 11g Enterprise
o n -
Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and s Reala nApplication
Testing options
) ha ideฺ
[oracle@edt3r10p1 labs]$
c o m Gu
a ฺ
il altered.
n t not, resolve any problems
c) You should see that the four users have
gm Studbeen e If
that might have occurred. @
u i
kresource is
7) Activate the DEFAULT_PLAN s y t h
plan.
( Ma tselect u se
a) In Enterprise iManager,
u k e o Server > Plans.
b) On a y enPlans
sResource
the s page, select DEFAULT_PLAN, select Activate from the
M drop-down
y Actions lic list, and click Go.
n l e
Sta c) Click Yes to confirm your activation.
You should see a success message.
8) Test the consumer group mappings. Start two SQL*Plus sessions: the first with the
system/oracle@orcl connect string and the second with the
scott/scott@orcl connect string.
a) As the oracle user in a terminal window, execute the oraenv script to set
environment variables for the orcl database.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$

Your output may be different depending on your previously executed tasks.

Oracle Database 11g: Administration Workshop II A-255


Computer Pride Limited

b) To start a SQL*Plus session with the system/oracle@orcl connect string


and to set your SQL prompt to “FIRST,” enter:
$ sqlplus system/oracle@orcl

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Jul 20


10:38:03 2007
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> SET SQLPROMPT "FIRST>"


FIRST> ble
fe r a
c) As the oracle user in a terminal window, execute the oraenv script to set
an s
environment variables for the orcl database.
n - t r
$ . oraenv a no
a s
ORACLE_SID = [orcl] ? orcl
) h i d eฺ
The Oracle base for
m
co nt Gu
l ฺ
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
i
/u01/app/oracle
g ma tude
$
u k i@ is S
Your output may be different
a e thon your previously executed tasks.
sy depending
( M session s the scott/scott@orcl connect string and
uwith
d) To start a SQL*Plus
i
k prompt t o
a s y uSQL
to set your
e n se to “SECOND,” enter:
M
$ysqlplus lic
scott/scott@orcl
n l e
Sta SQL*Plus: Release 11.1.0.6.0 - Production on Fri Jul 20
10:43:39 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> SET SQLPROMPT "SECOND>"


SECOND>

e) In your FIRST SQL*Plus session, enter:

Oracle Database 11g: Administration Workshop II A-256


Computer Pride Limited

FIRST>@query_rsc_groups.sql

SCHEMANAME RESOURCE_CONSUMER_GROUP
------------------------------ ------------------------------
SCOTT LOW_GROUP
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

FIRST>

f) Question: To which consumer group does the SCOTT user belong?


Answer: SCOTT is in the LOW_GROUP consumer group.
Note: Your output for this step (and the following steps) may not look exactly
like the output shown. The information of concern here is for the specific users
being mentioned.

g) In the SECOND terminal window, enter: ble


fe r a
SECOND>connect pm/pm@orcl
ans
Connected.
n - t r
SECOND>
a no
h) In your FIRST SQL*Plus session, enter “/” to executea s previous
statement again. ) h the
i d eฺ SQL
c o m Gu
a il ฺ n t
FIRST>/
g m tud e
SCHEMANAME k i @ i s S
RESOURCE_CONSUMER_GROUP
u h
sy se t -------------------------------
------------------------------
PM
( a
M to u SYS_GROUP
DBSNMP i
k se OTHER_GROUPS
DBSNMP syu n OTHER_GROUPS
a lic e
l e yM
FIRST>
n
Sta i) Question: To which consumer group does the PM user belong?

Answer: PM is in the SYS_GROUP consumer group.

j) In the SECOND terminal window, enter:


SECOND>connect oe/oe@orcl
Connected.
SECOND>

k) In your FIRST SQL*Plus session, enter “/” to execute the previous SQL
statement again.
FIRST>/

SCHEMANAME RESOURCE_CONSUMER_GROUP

Oracle Database 11g: Administration Workshop II A-257


Computer Pride Limited

------------------------------ -------------------------------
OE OTHER_GROUPS
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS

FIRST>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

l) Exit both the SQL*Plus sessions.

m) Question: When testing your OE Oracle user, you notice that OE is in the
OTHER_GROUPS consumer group. Why is that?
Possible Answer: The OE user is not explicitly assigned to another consumer
resource group.

9) Revert to your original configuration by deactivating the DEFAULT_PLAN resource


group, locking accounts, undoing all consumer group mappings, and finally by ble
deleting the APPUSER resource group.
fe r a
an s
n - t r
a) To deactivate the DEFAULT_PLAN resource plan in Enterprise Manager, select
Server > Plans.
a no
b) On the Resource Plans page, select the DEFAULT_PLAN,
h a sselect Deactivate
ฺ from
the Actions drop-down list, and click Go. ) id e
o m G u
c) Click Yes to confirm your deactivation. ilฺc n t
a d e
d) To lock accounts and reconfigure gormundo alltu
consumer group mappings, enter
@
ki this
from your working directory:
S
s y u
$ ./rsc_cleanup.sh
( M a u se
SQL*Plus: Release
u to
ki se11.1.0.6.0 - Production on Wed Oct 3
16:55:46 y
as licen
2007

y M
nleCopyright (c) 1982, 2007, Oracle. All rights reserved.
Sta
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

SQL> SQL>
User altered.

SQL>
User altered.

SQL>
User altered.

Oracle Database 11g: Administration Workshop II A-258


Computer Pride Limited

SQL>
User altered.

SQL> undo lab step 5


SQL> SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.

SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.

SQL> undo lab step 4


SQL> SQL> 2 3 4 5 6 7 8 9 10 11
PL/SQL procedure successfully completed.

SQL> undo lab step 3


ble
SQL> SQL>
12 13 14
2 3
15 16
4
17
5
18
6
19
7
20
8
21
9
22
10
23
11
24 fe r a
25 26
an s
PL/SQL procedure successfully completed.
n - t r
n o
SQL> undo lab step 2 s a
8 a 9 eฺ
h
SQL> SQL> 2 3 4 5 6 7
m ) u id
PL/SQL procedure successfully completed. o
c nt G
SQL> Disconnected from Oraclem ailฺ de11g
g Database
t u Enterprise Edition

With the Partitioning,uk


i@ is S Security, OLAP, Data
Release 11.1.0.6.0 - Production
OraclethLabel
Mining a sy se
i
and Real Application u options
(M toTesting
k
$
a syu cense
li APPUSER resource group in Enterprise Manager, select Server >
Mdelete the
e)y To
l e
n Consumer Groups.
Sta f) On the Consumer Groups page, select APPUSER and click the Delete button.
g) Confirm your deletion by clicking Yes.
h) Exit Enterprise Manager and close all terminal windows.

Oracle Database 11g: Administration Workshop II A-259


Computer Pride Limited

Practices for Lesson 18


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In these practices, you explore Oracle Scheduler capabilities.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-260


Computer Pride Limited

Practice 18-1: Creating Scheduler Components


In this practice, you use Enterprise Manager Database Control to create Scheduler objects
and automate tasks.

1. While logged in to the database as the HR user in Database Control, create a simple
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

job that runs a SQL script:


• General:
Name: CREATE_LOG_TABLE_JOB
Owner: HR
Description: Create the SESSION_HISTORY table for the next part of this
practice
Logging Level: RUNS
Command Type: PL/SQL
PL/SQL Block: BEGIN execute immediate('create table
ble
session_history(snap_time TIMESTAMP WITH LOCAL TIME ZONE,
fe r a
num_sessions NUMBER)'); END;
ans
• Schedule: n - t r
Repeating: Do not Repeat a no
a s
Start: Immediately
) h i d eฺ
• Options: m
co nt Gu
i l ฺ
No special options
g ma tude
k i@ RESOURCE,
a. As the SYS user, grant CONNECT, i s S and DBA roles to the HR user.
u t
sy assesysdbah
a
M to u
SQL> connect sys/oracle
Connected. ki (
syuconnect,
SQL> grant
a e n se resource, dba to hr;
M
y Log lic
n l e
b. in to Enterprise Manager Database Control as the HR user. Then click the
Sta Server folder tab. Click Jobs in the Oracle Scheduler region.

c. On the Scheduler Jobs page, click the Create button.

d. On the Create Job - General page, enter and confirm the following values:
Name: CREATE_LOG_TABLE_JOB
Schema: HR
Enabled: Yes
Description: Create the SESSION_HISTORY table
Logging Level: Log job runs only (RUNS)
Command Type: PL/SQL
PL/SQL Block:
BEGIN
execute immediate
('create table session_history(

Oracle Database 11g: Administration Workshop II A-261


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)');
END;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ n
g ma tuthedefollowing
e. On the Schedule folder tab, enter and confirm values:

u k i@ is S
Timezone: Your_local_timezone
Repeating: Do noty Repeat th
a s se
M
Start: Immediately
( u
y u ki se to
f. Clicks
M a ShowliSQL
c enif you want to view the SQL statement defining your job.
y
nleg. Review the statements and click Return.
Sta h. Click Apply to create the job.

i. If the job does not appear on the Scheduler Jobs page, click the Refresh button
until it succeeds.
2. Create a program called LOG_SESS_COUNT_PRGM that logs the current number of
database sessions into a table. Use the following code:
DECLARE
sess_count NUMBER;
BEGIN
SELECT COUNT(*) INTO sess_count FROM V$SESSION;
INSERT INTO session_history VALUES (systimestamp,
sess_count);
COMMIT;
END;

Oracle Database 11g: Administration Workshop II A-262


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


a. In Enterprise Manager, click the Server folder tab and then select Programs.
b. On the Scheduler Programs page, click the Create button.
c. On the Create Program page, enter and confirm the following values:
Name: LOG_SESS_COUNT_PRGM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Schema: HR
Enabled: Yes
Type: PLSQL_BLOCK
Source:

DECLARE
sess_count NUMBER;
BEGIN
SELECT COUNT(*) INTO sess_count FROM V$SESSION;
INSERT INTO session_history VALUES (systimestamp,
ble
sess_count);
fe r a
COMMIT;
an s
END;
n - t r
d. Click Show SQL.
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

e. Review the statements, and then click Return.

f. Click OK to create the program.

Oracle Database 11g: Administration Workshop II A-263


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
3. Create a schedule named SESS_UPDATE_SCHED owned by HR that executes every fe r a
n s
three seconds. Use SQL*Plus and the DBMS_SCHEDULER.CREATE_SCHEDULE
n - t ra
procedure to create the schedule.
a no
BEGIN
a s
DBMS_SCHEDULER.CREATE_SCHEDULE ( ) h i d eฺ
schedule_name => 'SESS_UPDATE_SCHED', m
co nt Gu
start_date => SYSTIMESTAMP, ailฺ
g m tude
repeat_interval => 'FREQ=SECONDLY;INTERVAL=3',
comments => 'Every three
k i S
i@ seconds');
s
END; u
sy se t h
/ a
(M to u
k i
u nManager
Return to Enterprise e Database Control and verify that the
a s y e s schedule was created.
M lic
SESS_UPDATE_SCHED
y
nleHint: You may have to refresh the page for the Schedule to appear.
Sta
a. In a terminal window, enter:
$ sqlplus hr/hr

b. In your SQL*Plus session, enter:


BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
schedule_name => 'SESS_UPDATE_SCHED',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=SECONDLY;INTERVAL=3',
comments => 'Every three seconds');
END;
/

c. In Enterprise Manager, select Server > Schedules.

Oracle Database 11g: Administration Workshop II A-264


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


d. Verify that the SESS_UPDATE_SCHED schedule has been created. (You may
have to refresh the page for the Schedule to appear.)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

4. Using Enterprise Manager Database Control, create a job named ble


LOG_SESSIONS_JOB that uses the LOG_SESS_COUNT_PRGM program and the fe r a
SESS_UPDATE_SCHED schedule. Make sure that the job uses FULL logging. ans
n - t r
no
a. In Enterprise Manager, select Server > Jobs, and then click Create.
a
a s
b. On the Create Job page, enter and confirm the following) h d
values:
i eฺ
m
co nt Gu
Name: LOG_SESSIONS_JOB i l ฺ
Owner: HR
g ma tude
Description: Count sessionsi@
k i s S
with HR.LOG_SESS_COUNT_PRGM
Logging level: Log u
syeverything h
t (FULL)
a s e
u and on the Select Command Option page, select
c. Click Change k i (M Type,
Commandto
Program
a
u and
syName, e n seenter HR.LOG_SESS_COUNT_PRGM in the field next to it,
lic (flashlight) icon to select the program. Click OK.
y orMuse the Lookup
n l e
Sta

d. Click the Schedule tab.

Oracle Database 11g: Administration Workshop II A-265


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


e. Change the Schedule Type to “Use Pre-Defined Schedule,” and select the
HR.SESS_UPDATE_SCHED schedule by using the Lookup icon.
f. Click Show SQL.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
g. Review the statements and then click Return. a s
) h i d eฺ
h. Click OK to create the job. m
co nt Gu
i l ฺ
g ma tude
5. In your SQL*Plus session, check the HR.SESSION_HISTORY table for rows.
i @ S
a. Enter: s y uk this
se
Ma SESSION_HISTORY
u
SQL> SELECT *i (FROM to
u k s e
ORDER BY snap_time;

YourM asylooks
result lic e n
different but the second values should be three seconds apart:
y
nleSNAP_TIME
Sta --------------------------------------------------------------
-----
NUM_SESSIONS
------------
30-Jul-07 08.05.24.113274 AM
24
30-Jul-07 08.05.27.112987 AM
24

Question: If there are rows in the table, are the time stamps three seconds apart?

Answer: Yes, there are rows. Yes, the time stamps are three seconds apart.

6. Use Enterprise Manager Database Control to alter the SESS_UPDATE_SCHED


schedule from every three seconds to every three minutes. Then use SQL*Plus to

Oracle Database 11g: Administration Workshop II A-266


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


verify that the rows are now being added every three minutes: query the
HR.SESSION_HISTORY table, ordered by the SNAP_TIME column.

a. In Enterprise Manager, select Server > Schedules.

b. Click the SESS_UPDATE_SCHED link.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

c. On the View Schedule page, click Edit.

d. Change the description to “Every three minutes.”

e. Change Available to Start to Immediately.

f. Change the value in the Repeat drop-down list from By Seconds to By Minutes.

g. Ensure that the interval is 3 and then click Show SQL.


ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a s y e th
i Mstatements,
h. Review(the
t o usclick Return, and then click Apply.
s
h. In your y uk se query the HR.SESSION_HISTORY table, ordered by the
SQL*Plusnsession,
M a liccolumn.
e (Wait for three minutes after you update the schedule.) Enter:
y SNAP_TIME
nle
Sta SQL> SELECT * FROM HR.SESSION_HISTORY ORDER BY snap_time;

Your result looks different (but the minute values should be three minutes apart):
SNAP_TIME
------------------------------------------------------------------
---
NUM_SESSIONS
--------------
30-Jul-07 08.15.30.024307 PM
23
30-Jul-07 08.18.00.113159 PM
23

7. This is your mandatory cleanup task. Use Enterprise Manager to drop the
LOG_SESSIONS_JOB and CREATE_LOG_TABLE_JOB jobs, the

Oracle Database 11g: Administration Workshop II A-267


Computer Pride Limited

Practice 18-1: Creating Scheduler Components (continued)


LOG_SESS_COUNT_PRGM program, and the SESS_UPDATE_SCHED schedule.
Use SQL*Plus to drop the SESSION_HISTORY table, and exit from your session.

Note: Make sure that you do not delete the wrong schedule.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

a. In Enterprise Manager, select Server > Jobs.

b. With the LOG_SESSIONS_JOB job selected, click the Delete button. Select
“Drop the job and stop any running instance,” and then click Yes.

c. Go back to the Scheduler Jobs page, select CREATE_LOG_TABLE_JOB, and


click Delete. Click Yes to confirm.

d. Click the Database Instance breadcrumb at the upper-left corner of the page to
return to the Server page. Then click Programs.
ble
f. With the LOG_SESS_COUNT_PRGM program selected, click the Delete button.
fe r a
Click Yes to confirm.
t r a ns
g. Click the Database Instance breadcrumb at the upper-left corner ofothen -page to
return to the Server page. Click Schedules.
s an
) h a eฺ
h. With the SESS_UPDATE_SCHED schedule selected,
o m clicku idDelete button.
the
Make sure that you do not delete the wrong c nt
ilฺschedule. G
a
m tude
i. Select “If there are dependenti@
g S not be dropped,” and then click Yes
objects, it will
u k h i s
to confirm.
a sy se t
j. i
In your SQL*Plus (Msession
t o u
as the HR user, delete the SESSION_HISTORY table,
k se Enter:
u thensession.
a syexit
and then
e
y M lic
n l e
SQL> DROP TABLE session_history PURGE;

Sta SQL> EXIT

Oracle Database 11g: Administration Workshop II A-268


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs


Create and run a lightweight scheduler job. View the metadata for a lightweight scheduler
job.
1) Create a job template for the lightweight job. The template must be a PL/SQL
procedure or a PL/SQL block. Run the cr_test_log.sql script to create the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

test_log table. Then run prog_1.sql. The prog_1.sql script in the


$HOME/labs directory creates a job template.
Note: The job template has a subset of the attributes of a scheduler program. Most of
the attributes of a template cannot be changed for the job.
a) View the prog_1.sql script.
$ cat $HOME/labs/prog_1.sql
set echo on

BEGIN ble
fe r a
ans
-- This will produce an error the first
n - t r
n o
-- time it is run since PROG_1 does not exists a
) ha ideฺ
DBMS_SCHEDULER.DROP_PROGRAM (
c o m Gu
program_name il ฺ n t
=> '"SYSTEM"."PROG_1"');
a
gm Stud e
END; @
ki this
s y u
/
( M a u se
y u ki se to
BEGIN as en
y M l i c
DBMS_SCHEDULER.CREATE_PROGRAM(
l e
n program_name=>'"SYSTEM"."PROG_1"'
Sta ,program_action=>'DECLARE
time_now DATE;
BEGIN

INSERT INTO test_log VALUES(''LWT'',''DONE'',SYSTIMESTAMP);

END;'
, program_type=>'PLSQL_BLOCK'
, number_of_arguments=>0,
comments=>'Insert a timestamp into the test_log'
,enabled=>TRUE);
END;
/
$

b) Execute the cr_test_log.sql and prog_1.sql scripts as the system user.


The password for the system user is “oracle.”

Oracle Database 11g: Administration Workshop II A-269


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs (continued)


$ cd $HOME/labs
$ sqlplus system/oracle

SQL*Plus: Release 11.1.0.5.0 - Beta on Tue May 29 11:10:55


2007
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
SQL> @cr_test_log.sql
SQL> create table system.test_log
(job_type VARCHAR2(10)
ble
,
fe r a
timemark VARCHAR2(10)
ans
,
act_time TIMESTAMP with TIME ZONE) n - t r
a no
/
a s
2 3 4 5 6 7 SQL> ) h i d eฺ
Table created. m
co nt Gu
i l ฺ
ma tude
PL/SQL procedure successfully completed.
g
SQL> @prog_1.sql
u k i@ is S
SQL> BEGIN
a sy se th
k i (M to u
2 DBMS_SCHEDULER.CREATE_PROGRAM(
3 program_name=>'"SYSTEM"."PROG_1"'
s yu ense
4 ,program_action=>'DECLARE
a
y lic DATE;
5M time_now

nle 7
6 BEGIN

Sta 8 INSERT INTO test_log


VALUES(''LWT'',''DONE'',SYSTIMESTAMP);
9
10 END;'
11 , program_type=>'PLSQL_BLOCK'
12 , number_of_arguments=>0,
13 comments=>'Insert a timestamp into the test_log'
14 ,enabled=>TRUE);
15 END;
16 /

PL/SQL procedure successfully completed.

Oracle Database 11g: Administration Workshop II A-270


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs (continued)


2) Create a lightweight job, using the PL/SQL API. The job will run the my_prog
template daily with an interval of 2, starting immediately.
Note: EM does not expose the JOB_STYLE setting at this time.
a) View the my_lwt_job.sql script.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

$ cat $HOME/labs/my_lwt_job.sql
set echo on
BEGIN
-- the drop procedure will give and error the first time
-- this script is run

sys.DBMS_SCHEDULER.DROP_JOB('my_lwt_job');
END;
/

DECLARE
jobname VARCHAR2(30); ble
fe r a
BEGIN
an s
-- Create the Job
n - t r
jobname := 'my_lwt_job';
a no
a s
sys.dbms_scheduler.create_job(
) h i d eฺ
job_name => '"SYSTEM"."MY_LWT_JOB"', m
co nt Gu
i
program_name => '"SYSTEM"."PROG_1"',
a del ฺ
g m
job_class => '"DEFAULT_JOB_CLASS"',
tu
i @
job_style => 'LIGHTWEIGHT',
repeat_interval =>uk is S
s y t h
'FREQ=DAILY;INTERVAL=2',

enabled =>(M
a
comments => 'Lightweight
TRUE);o u
se job',

y u ki se t
END; as e n
/y M l i c
l
n $e
Sta b) Execute the my_lwt_job.sql script as the system user.
$ sqlplus system/oracle
SQL> @my_lwt_job.sql
SQL> BEGIN
2 -- the drop procedure will give and error the first
time
3 -- this script is run
4
5 sys.DBMS_SCHEDULER.DROP_JOB('my_lwt_job');
6 END;
7 /
BEGIN
*
ERROR at line 1:
ORA-27475: "SYSTEM.MY_LWT_JOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 182

Oracle Database 11g: Administration Workshop II A-271


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs (continued)


ORA-06512: at "SYS.DBMS_SCHEDULER", line 615
ORA-06512: at line 5

SQL>
SQL> DECLARE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2 jobname VARCHAR2(30);
3
4 BEGIN
5 -- Create the Job
6 jobname := 'my_lwt_job';
7
8 sys.dbms_scheduler.create_job(
9 job_name => '"SYSTEM"."MY_LWT_JOB"',
10 program_name => '"SYSTEM"."PROG_1"',
11 job_class => '"DEFAULT_JOB_CLASS"',
12 job_style => 'LIGHTWEIGHT',
ble
13
14
repeat_interval => 'FREQ=DAILY;INTERVAL=2',
comments => 'Lightweight job', fe r a
15 enabled => TRUE); ans
16 n - t r
17 END;
a no
18 /
a s
) h i d eฺ
PL/SQL procedure successfully completed. m
co nt Gu
i l ฺ
SQL>
g ma tude
u k i@ is S
a s y e th
3) Check the SchedulerM
i ( t o us USER_SCHEDULER_JOBS, _PROGRAMS,
metadata views
DBA_JOBS. uk
a s y ense
a) Select
y M JOB_NAME,
l ic JOB_STYLE, and PROGRAM_NAME from
nle USER_SCHEDULER_JOBS.
Sta SQL> SELECT job_name, job_style, program_name FROM
USER_SCHEDULER_JOBS;

JOB_NAME JOB_STYLE
------------------------------ -----------
PROGRAM_NAME
----------------------------------------------------------
MY_LWT_JOB LIGHTWEIGHT
PROG_1

4) Check the Enterprise Manager Scheduler Jobs page, find the MY_LWT_JOB, and
view the attributes.
a) Navigate to the Scheduler Jobs page. Then click the History tab.

Oracle Database 11g: Administration Workshop II A-272


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs (continued)


View the history of MY_LWT_JOB.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

b) Click the Job Name to view the job attributes.

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
le
5) Drop the job from the EM Scheduler Jobs page.
n
Sta a) Navigate to the Scheduler jobs page, select MY_LWT_JOB, and click Delete.

Oracle Database 11g: Administration Workshop II A-273


Computer Pride Limited

Practice 18-2: Creating Lightweight Scheduler Jobs (continued)


b) On the Confirmation page, select “Drop the job and any running instance.” Click
Yes.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-274


Computer Pride Limited

Practice 18-3: Monitoring the Scheduler


Background: Because your job tasks are regularly increasing, you decide to automate
routine tasks. You first monitor existing scheduler elements, and then you create
scheduler components and test them.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

In this practice, you use Enterprise Manager Database Control to define and monitor the
Scheduler and automate tasks. Click Show SQL regularly to review all statements that are
new to you.
Log in as the SYS user (with oracle password, connect as SYSDBA) or as HR user
(with HR password, connect as Normal), as indicated. Perform the necessary tasks either
through Enterprise Manager Database Control or through SQL*Plus. All scripts for this
practice are in the /home/oracle/labs directory.
1) Log in to Enterprise Manager Database Control as the SYS user and grant the
following roles to the HR user: e
r a bl
• CONNECT role
sfe
• RESOURCE role
- t r an
• DBA role
no n
a
Because you are going to use the HR user to administer jobs through Database
s
h a eฺ
Control, you need to make sure that HR is registered as a possible administrator.
)
m i d
a. In Enterprise Manager, select Server > Users.i l ฺ co nt Gu
g ma tude
k @user and
b. On the Users page, select the iHR
i s Sclick Edit.
y u
sclick t h
c. On the Edit UserM a
page, s
theeRoles tab. Then click the Edit List button on the
i
right side ofkthe(page. to u
a syu cense
M the Modify
d. On
y roles li Roles page, make sure that the DBA, CONNECT, and RESOURCE
n l e are selected. Click Apply.
Sta

e. Click the Setup link in the upper-right region of the page.

f. Click the Administrators link. On the Administrators page, click the Create
button.

Oracle Database 11g: Administration Workshop II A-275


Computer Pride Limited

g. On the “Create Administrators: Properties” page, enter HR in the Name,


Password, and Confirm Password fields.
h. Click the Review button.
i. On the “Create Administrator: Review” page, click the Finish button.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
an s
n - t r
a no
a s
j. Click the Logout link at the upper-right corner of the ) h
page.
i d eฺ
m
casothe HR G uOn the Server tabbed
2) Log in to Enterprise Manager Database Control
i l ฺ tuser.
page, click the Jobs link in the Databasem
g
a dregion.
Scheduler
u en Are there any jobs?
k i @ i s St
a. Click the Login button to u
sy se th
log in as the HR user.
b. For the username
a u enter HR, accept Connect As Normal, and click
(Mand password,
k i t o
s cense
Login. yu
a
MEnterprise
c.y In li Manager, select Server > Jobs in the Database Scheduler region.
n l e
Sta Question: Are there any jobs?

Answer: There are some jobs.

Oracle Database 11g: Administration Workshop II A-276


Computer Pride Limited

3) Review the Programs page in Enterprise Manager. Are there any existing programs?
(Hint: Use the browser’s Back button).

a. In Enterprise Manager, select Server > Programs in the Database Scheduler


region.
Question: Are there any existing programs?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Answer: There are some existing programs.

ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
4) Review the Scheduler Schedules k i s S Manager. Are there any existing
@ in Enterprise
ipage
schedules? u
sy se t h
a
(M tselect u
k
a. In Enterprise i
u nseManager, o Server > Schedules.
s y
a Are lthere e any existing schedules?
M
Question:
y i c
nle
Sta Answer: There are two schedules, DAILY_PURGE_SCHEDULE and
BSLN_MAINTAIN_STATS_SCHED.

Oracle Database 11g: Administration Workshop II A-277


Computer Pride Limited

5) Review the Scheduler Windows page in Enterprise Manager. Are there any existing
windows? Which resource plan is associated with each window?

a. In Enterprise Manager, select Server > Windows.

Question 1: Are there any existing windows? Are any enabled?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Answer: There are several windows. All are enabled except WEEKNIGHT_WINDOW
and WEEKEND_WINDOW.

b. Click the MONDAY_WINDOW link.

Question 2: Which resource plan is associated with this window?

Answer: DEFAULT_MAINTENANCE_PLAN.

c. Click OK.
ble
6) Review the Scheduler Job Classes page in Enterprise Manager. Are there any existing
fe r a
n s
job classes? If so, which resource consumer group is associated with each job class?
n - tra
a. In Enterprise Manager, select Server > Job Classes.
a no
a s
Question 1: Are there any existing job classes?
) h i d eฺ
m
co nt Gu
Answer: There are many job classes. i l ฺ
g ma tude
b. Click the DEFAULT_JOB_CLASS
k i@ link. i s S
u
syconsumer t h
a
Question 2: Which resource s e
M to u group is associated with the job class?
i (
y
Answer: None.
s uk nse
M a lice
y
nlec. Click OK, and then click the ORA$AT_JCURG_OS link.
Sta Question 3: Which resource consumer group is associated with the job class?

Answer: ORA$AT_JCURG_OS is associated with


ORA$AUTOTASK_URGENT_GROUP.

d. Click OK, and then exit Enterprise Manager.

Oracle Database 11g: Administration Workshop II A-278


Computer Pride Limited

Practices for Lesson 19

There are no practices for lesson 19.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-279


Computer Pride Limited

Practices for Lesson 20

Practice 20-1: Using Globalization Support


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Your company has bought another company that has a large user community speaking
French. In general, you are not supposed to change the database itself, but you are
supposed to use a lower granularity to accommodate their needs. So you decide to use
primarily session-specific settings for changing the language, changing the date and time
formats, and addressing a sorting issue. Use system/oracle@orcl as your database
login and /home/oracle/labs as your working directory.
1) Start SQL Developer binaries. Log in as SYS as SYSDBA.
a) Change to the sqldeveloper directory.
$ cd $ORACLE_HOME/sqldeveloper/sqldeveloper/bin
ble
fe r a
b) Start the sqldeveloper executable.
ans
$ ./sqldeveloper n - t r
n o
a
c) If asked whether you would like to migrate settings from asprevious release, click
No.
) ha ideฺ
c o
d) Right-click Connections and select New Connection.
m Enter
G uthe following
i l ฺ t
information for the connection:
g ma tuden
Connection Name: SYSTEM
u k i@ is S
Username:
a y
ssystem e th
Password:
i ( M oracle
t o us
s y uk nseCheck the checkbox
Save Password:
a lice default
Role:
M
y SID:
nle
orcl

Sta e) Click Save, and then click Connect. Enter any subsequent queries in the area at
the top of the window where you see “Enter SQL Statement:”.
2) Determine the database and the national character set.
SELECT * FROM NLS_DATABASE_PARAMETERS
WHERE parameter LIKE '%CHARACTER%';

3) Familiarize yourself with NLS settings and modify the current date format.

a. Select the current date.

Oracle Database 11g: Administration Workshop II A-280


Computer Pride Limited

SELECT SYSDATE FROM dual;

b. The year is not displayed using a four-digit year. Change your session to display a
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

four-digit year and the current time (including seconds).


ALTER SESSION SET NLS_DATE_FORMAT='mon-dd-yyyy:hh:mi:ss';
SELECT SYSDATE FROM dual;

c. Let your session speak French. Display the current system date and time.
ble
alter session set nls_language=FRENCH;
select sysdate from dual; fe r a
ans
n - t r
a no
a s
4) Import the WORDS table (which is in the words.dmp m
h
) Runuithe
file). deฺ
o
load_words.sh script to do this. a ilฺc ent G
@ gm Stud
ki this
$ cd $HOME/labs
$ ./load_words.sh
s y u
( M a u se
ki creates
Note that the script ato
table named WORDS that has four rows.
y u s e
as licendisplay the content of the WORDS table.
5) In sqldeveloper,
M
y
nleSELECT * FROM words;
Sta

6) Set NLS_SORT to BINARY for your session. Select the table contents and order the
results by the FR_WORD column. In what order are the numbers in the NUM column
displayed?
ALTER SESSION SET NLS_SORT=BINARY;
SELECT * FROM words
ORDER BY fr_word;

Oracle Database 11g: Administration Workshop II A-281


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

7) Set NLS_SORT to FRENCH. Select the table contents and order the results by the
FR_WORD column. In what order are the numbers in the NUM column displayed?
ALTER SESSION SET NLS_SORT=FRENCH;
SELECT * FROM words
ORDER BY fr_word;

ble
fe r a
an s
n - t r
a no
a s
8) Set NLS_SORT to FRENCH_M. Select the table contents
h
) and order
i d eฺ results by the
the
m
coin thenNUM u displayed?
Gcolumn
l
FR_WORD column. In what order are the numbers
i ฺ t
g ma tude
i@ is S
ALTER SESSION SET NLS_SORT=FRENCH_M;
SELECT * FROM wordsyuk th
a s e
i ( M to us
ORDER BY fr_word;

s y uk nse
M a lice
y
nle
Sta

9) Set NLS_SORT to BINARY. Now retrieve the table contents in the same order as the
last query, without using another ALTER SESSION command.
ALTER SESSION SET NLS_SORT=BINARY;
SELECT * FROM words
ORDER BY NLSSORT(fr_word,'NLS_SORT=FRENCH_M');

Oracle Database 11g: Administration Workshop II A-282


Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

10) Drop the table and also remove it from the recycle bin.
DROP TABLE words PURGE;

11) Exit SQL Developer by selecting File > Exit on the menu. If you are prompted with a
Save Files alert window, click No.

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta

Oracle Database 11g: Administration Workshop II A-283


Computer Pride Limited

Index
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited

A
Active session pool 17-5, 17-17, 17-18, 17-19, 17-28
ADDM 15-20, 15-27, 17-26
Advanced Security Option 5-28
Alert 1-12, 1-13, 1-26, 2-28, 6-6, 6-39, 10-9, 10-32, 13-3, 13-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

13-6, 13-8, 13-11, 13-33, 13-34, 13-38, 15-9, 16-10, 16-11, 16-25, 16-41
Application Server 15-17
Archive 1-12, 1-21, 2-2, 2-10, 2-12, 2-15, 2-16, 2-17, 2-18,
2-23, 2-25, 2-26, 2-30, 2-34, 3-16, 5-22, 6-28, 6-29, 6-30, 6-31,
6-33, 6-34, 6-40, 6-41, 6-42, 7-7, 10-3, 11-3, 11-7, 11-29, 12-2,
12-12, 12-25, 12-26, 12-27, 12-28, 12-29, 12-30, 12-31, 12-32, 13-38, 15-9
archivelog 2-2, 2-11, 2-12, 2-13, 2-14, 2-30, 2-34, 2-35, 3-18,
ble
3-27, 4-3, 4-5, 4-12, 4-13, 5-4, 5-6, 5-15, 5-17, 6-22, 6-25,
fe r a
6-26, 7-5, 7-6, 7-14, 8-16, 12-11, 12-12, 12-20, 13-37
t r a ns
Archiver 1-11, 2-11, 2-12, 2-25 o n -
ARCn 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 2-11, 2-12, 14-13 s an
ASM 1-1, 1-2, 1-11, 1-20, 1-21, 1-22, 1-23, 1-24, 1-25, 1-26,) ha ideฺ
c o m Gu
a il
1-27, 1-28, 1-29, 1-30, 1-31, 1-32, 1-33, 1-34,ฺ 1-35,
n t 1-37,
1-36,
gm 1-45,
1-38, 1-39, 1-40, 1-41, 1-42, 1-43, 1-44,
e
d 1-47, 1-48,
u1-46,
@ S t
8-17, 10-29, 13-4, 16-36
y u ki this
a s se
+ASM 1-24, 1-25
( M u
o 1-25, 1-26, 1-27, 1-28, 1-29,
ASM Instance 1-20,y u ki 1-23,
1-22, s e t1-24,
M as1-38,lic1-39,
1-35, 1-37, en 1-48, 13-4
n l ey
ASM_DISKGROUPS 1-24, 1-25
t a
SASM_DISKSTRING 1-24
ASM_POWER_LIMIT 1-24, 1-34, 1-42
ASMM 14-21, 14-22, 14-23, 14-25, 14-28, 14-34, 14-36
ASSM 16-14
Audit 11-20, 12-25, 13-43
autobackup 3-27, 4-2, 4-3, 4-7, 4-8, 4-9, 4-15, 4-16, 5-6,
5-15, 5-20, 7-17, 7-18, 7-19, 7-22, 7-24, 7-25, 7-27, 7-28
Automatic PGA Memory Management 14-2, 14-32, 14-40
Automatic Segment Space Management 16-3, 16-4, 16-7
Automatic Shared Memory Management 1-8, 10-32, 14-21, 14-22, 14-23,
14-24, 14-28

Oracle Database 11g: Administration Workshop II Index - 2


Computer Pride Limited

A
Automatic Storage Management 1-2, 1-20, 1-21, 1-23, 1-47, 13-4,
16-36
Automatic Workload Repository 15-18, 15-20, 15-21, 16-3, 16-9, 16-15
Auxiliary database 8-6, 8-7, 8-11, 9-15, 9-17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

AWR 15-18, 15-20, 15-21, 15-23, 15-27, 15-28, 15-30, 16-3, 16-9, 16-15,
16-16
B
BACKGROUND_DUMP_DEST 13-4
Backup piece 3-18, 5-14, 10-8, 10-14, 10-20, 10-27, 10-29
Backup set 3-3, 4-3, 4-6, 4-10, 5-2, 5-3, 5-5, 5-6, 5-8,
5-9, 5-14, 5-15, 5-24, 5-39, 10-4, 10-7, 10-14, 10-15, 10-25, 10-27,
a ble
10-29
e r
BACKUP_TAPE_IO_SLAVES 10-16, 10-17, 10-18, 10-19, 10-32 a n sf
Block 1-14, 1-15, 1-16, 1-18, 1-19, 1-30, 1-37, 1-44, 2-6, 2-9, o n -tr
2-10, 3-24, 4-3, 4-6, 4-12, 5-4, 5-8, 5-9, 5-10, 5-11, 5-12, s an
5-13, 5-25, 5-26, 5-40, 6-23, 7-11, 7-14, 7-15, 7-25, ) ha 8-8,ideฺ
8-6,
c o m Gu
8-11, 10-10, 10-23, 10-26, 11-6, 12-8, 12-9,a ฺ t 13-32, 13-33,
il 13-28,en13-29,
gm S
13-35, 13-36, 13-37, 13-38, 13-39, 13-42,
@ t ud 14-4, 14-5, 14-6, 14-7,
13-45,
y
14-25, 14-36, 15-9, 16-7, 16-8,u ki17-6,th17-21,
is 18-4, 18-6, 18-8, 18-11,
s
a use
18-12, 18-15 ( M to
y u
Block change tracking
ki4-6, s5-11,
e 5-12, 5-13, 5-40
as e n
y M 13-32,
Block corruption lic 13-33, 13-36, 13-38, 13-45
l e
tanMedia Recovery 2-6, 13-36, 13-37, 13-38
SBlock
Buffer cache 1-8, 1-19, 12-9, 12-25, 14-4, 14-5, 14-6, 14-7, 14-8,
14-11, 14-12, 14-13, 14-19, 14-21, 14-25, 14-34, 14-36, 14-37, 15-14
C
chains 18-22, 18-23, 18-25, 18-26, 18-28, 18-29, 19-2, 19-16, 19-18
Change tracking file 5-11, 5-12, 5-13, 12-12
Channel 2-9, 2-10, 3-15, 3-24, 4-5, 4-12, 4-13, 5-3, 5-17,
5-24, 5-30, 5-31, 5-32, 7-11, 8-11, 8-12, 9-12, 9-17, 10-3, 10-5,
10-6, 10-9, 10-10, 10-11, 10-12, 10-14, 10-15, 10-16, 10-25, 10-26, 10-27,
10-28, 10-29, 10-31, 10-32
Checkpoint 1-11, 2-21, 6-8, 6-9, 6-34, 14-6, 14-7
CKPT 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22, 6-9

Oracle Database 11g: Administration Workshop II Index - 3


Computer Pride Limited

C
Cluster 1-15, 1-20, 1-21, 1-23, 1-31, 3-8, 13-4, 14-9, 15-12,
15-19, 16-5
COMPATIBLE 1-31, 1-38, 1-39, 1-41, 5-24, 5-26, 12-20, 15-21, 16-28,
16-30, 16-34, 16-37, 16-38
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Configuration assistant 1-23


Control file 2-11, 2-22, 2-24, 2-25, 3-2, 3-3, 3-4, 3-5, 3-10,
3-11, 3-17, 3-18, 3-20, 3-27, 3-28, 3-36, 4-2, 4-3, 4-5, 4-6,
4-7, 4-8, 4-15, 4-16, 5-4, 5-6, 5-12, 5-15, 5-37, 5-38, 5-40,
6-2, 6-24, 6-27, 6-28, 6-31, 6-47, 6-48, 6-49, 7-2, 7-11, 7-16,
7-17, 7-18, 7-19, 7-22, 7-25, 7-27, 7-28, 7-29, 8-7, 8-8, 8-13,
9-5, 9-6, 9-9, 9-15, 10-9, 12-17, 12-18, 12-19, 13-37, 20-31
ble
CONTROL_FILE_RECORD_KEEP_TIME 2-22, 3-20, 7-13
fe r a
CONTROL_FILES 7-19, 8-7
t r a ns
CORE_DUMP_DEST 13-4 o n -
an
Corruption 6-4, 9-7, 11-3, 13-2, 13-32, 13-33, 13-34, 13-35, 13-36,
s
13-38, 13-39, 13-45, 13-47, 13-48 ) ha ideฺ
c o m Gu
CRS 13-4
a il ฺ n t
CURSOR_SHARING 14-38, 14-39 gm tud e
u k i@ is S
D
a sy se th
Data block 1-15, 1-18, 4-3,
i o u 13-29, 13-32, 13-33, 13-38,
(M5-9, t13-28,
14-7, 16-8 syu
k se
a e n
l e y M cachelic1-7, 14-10
Data dictionary
tanfile 1-12, 1-14, 1-16, 1-18, 1-22, 1-30, 2-11, 2-21, 2-24,
SData 2-25, 3-4, 3-18, 3-20, 5-4, 5-5, 5-6, 5-8, 5-9, 5-13, 5-14,
5-22, 5-24, 5-25, 5-31, 5-38, 6-2, 6-7, 6-10, 6-13, 6-23, 6-24,
6-28, 6-29, 6-31, 6-32, 6-34, 6-36, 6-45, 6-47, 6-49, 7-2, 7-3,
7-5, 7-6, 7-7, 7-10, 7-11, 7-12, 7-29, 9-5, 9-17, 10-7, 10-10,
10-15, 10-20, 10-21, 10-33, 12-18, 12-19, 12-20, 13-36, 13-37, 13-38, 16-3,
16-6, 16-10, 16-28, 16-29, 18-18, 18-26, 20-31
Database Control 2-27, 2-32, 3-11, 3-17, 5-12, 5-37, 9-6, 11-15,
14-27, 15-20, 15-33, 16-15, 16-17, 17-7, 17-22, 17-26, 18-31, 19-6
Database writer 1-11, 10-31
DB_BLOCK_CHECKING 13-35
DB_BLOCK_SIZE 1-18, 8-6, 14-6, 14-7

Oracle Database 11g: Administration Workshop II Index - 4


Computer Pride Limited

D
DB_CACHE_SIZE 14-6, 14-7, 14-8, 14-15, 14-26, 14-28
DB_CREATE_FILE_DEST 2-25, 5-12, 8-8
DB_CREATE_ONLINE_LOG_DEST_n 2-25
DB_FILE_NAME_CONVERT 8-7, 8-8, 9-17, 9-19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

DB_FLASHBACK_RETENTION_TARGET 12-10
DB_KEEP_CACHE_SIZE 14-6, 14-8, 14-15, 14-25, 14-27
DB_NAME 3-33, 3-35, 7-17, 8-6, 8-12
DB_nK_CACHE_SIZE 14-7, 14-15, 14-25
DB_RECOVERY_FILE_DEST 2-26, 2-28, 2-30, 4-13, 8-8, 12-12, 12-23
DB_RECOVERY_FILE_DEST_SIZE 2-26, 2-28, 2-30, 12-23
DB_RECYCLE_CACHE_SIZE 14-6, 14-8, 14-15, 14-25
ble
DB_UNIQUE_NAME 1-24
fe r a
DBA 1-26, 1-34, 1-45, 2-29, 3-34, 5-26, 6-26, 10-10, 11-9, 11-10,
t r a ns
11-11, 11-12, 11-13, 11-15, 11-16, 11-37, 12-14, 12-29, 13-3, 13-28,
o n - 13-32,
14-8, 15-19, 15-42, 16-4, 16-13, 16-23, 16-25, 17-17, 17-25,
n 18-11,
a 18-9,
s
ha ideฺ
18-14, 18-18, 18-29, 19-14, 19-16, 19-17, 20-4 )
m Gu
ฺ c o t
DBCA 1-23, 14-32
a il e n
DBV 13-36
@ gm Stud
DBVERIFY 6-35, 13-38
y u ki this
a s 1-19,s14-6,
e 14-7, 14-13
DBWn 1-4, 1-6, 1-9, 1-10,M
( 1-11,
i 10-19, u
to 10-31, 10-32
DBWR_IO_SLAVES y u k10-14, s e
DDL 11-16,M as 11-25,
11-22, l i c en11-28, 12-7, 12-26, 12-30, 14-13, 15-39, 15-43,
n l ey 16-26, 20-30
16-22,
ta
SDedicated server 1-9, 14-30
disk group 1-21, 1-22, 1-27, 1-29, 1-30, 1-31, 1-32, 1-33, 1-34,
1-35, 1-36, 1-37, 1-38, 1-39, 1-40, 1-41, 1-42, 1-44, 1-45, 1-46,
1-48
DML 6-23, 9-7, 11-4, 11-16, 11-28, 11-36, 12-7, 12-18, 12-25, 14-13,
15-26, 15-39, 15-43, 16-12, 16-13, 16-22, 16-26, 17-5, 20-29
Dynamic Performance Views 5-36, 14-33, 15-16

Oracle Database 11g: Administration Workshop II Index - 5


Computer Pride Limited

E
Encoded character set 20-5, 20-7
Enterprise Manager 1-8, 1-17, 1-28, 1-41, 2-13, 2-21, 2-27, 2-32,
3-8, 3-12, 3-13, 3-14, 3-17, 4-2, 4-6, 4-7, 4-13, 4-14, 4-15,
5-21, 5-33, 5-37, 7-4, 7-5, 8-15, 9-14, 11-5, 11-13, 11-21, 11-24,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

11-26, 11-28, 11-30, 11-31, 12-4, 12-5, 12-6, 12-11, 13-3, 13-5, 13-8,
13-9, 13-10, 13-11, 13-12, 13-28, 13-29, 14-18, 14-37, 15-7, 15-8, 15-15,
15-17, 15-18, 15-21, 15-28, 15-43, 15-44, 15-45, 16-6, 16-9, 16-33, 16-34,
16-35, 16-41, 17-7, 17-13, 17-18, 17-24, 18-3, 18-6, 18-7, 18-8, 18-17,
18-26, 18-28, 18-31, 19-6, 19-9
Enterprise Manager Database Control 2-32, 3-17, 17-7, 18-31, 19-6
Environment variable 3-9, 7-23, 13-4, 13-7, 20-16, 20-22, 20-30,
ble
20-31
fe r a
EVENT 2-24, 3-3, 5-34, 13-7, 15-12, 15-13, 15-16, 15-17, 15-18, 16-21,
t r a ns
16-25, 18-2, 18-3, 18-5, 18-8, 18-10, 18-16, 18-17, 18-18, 18-19,
o n -
18-20,
n
18-22, 18-23, 18-25, 18-26, 18-30, 19-3 sa
ha ideฺ
F )
m Gu
ฺ c o t
Factor 1-31, 1-45, 14-20 a il e n
Flash recovery area 2-2, 2-11, 2-19, 2-20,
@ gm2-24,S t
2-25,ud2-26,
2-27, 2-28, 2-29, 2-30, 2-31,y u ki this2-34, 2-35, 3-18, 4-4,
2-32, 2-33,
4-8, 5-6, 5-14, 5-20,(M
as us7-18,
5-29, 7-17,
e 12-8, 12-10, 12-12, 12-18,
u ki 12-23
e to
12-19, 12-20,
a y 12-22,
s cen s
Flashback
l e y buffer 12-9li
M
tan Database 2-11, 2-19, 2-25, 4-4, 11-3, 11-39, 12-2, 12-8,
SFlashback
12-9, 12-10, 12-11, 12-12, 12-13, 12-14, 12-15, 12-16, 12-17, 12-18, 12-19,
12-20, 12-21, 12-22, 12-23, 12-24, 12-31, 12-32, 13-37
Flashback Drop 11-3, 11-8, 11-12, 11-13
Flashback Logging 12-12, 12-19, 12-20, 12-21, 13-37
Flashback Query 9-9, 11-2, 11-17, 11-18, 11-19, 11-20, 11-38, 11-39,
12-30
Flashback Table 11-8, 11-11, 12-2, 12-3, 12-4, 12-6, 12-7, 12-31
Flashback Transaction Query 9-9, 11-2, 11-17, 11-20, 11-23, 11-24,
11-25, 11-38, 12-3, 12-4, 12-30
Flashback Versions Query 12-3, 12-4

Oracle Database 11g: Administration Workshop II Index - 6


Computer Pride Limited

G
Globalization support 20-2, 20-3, 20-8, 20-21, 20-26, 20-28, 20-30,
20-31, 20-33, 20-34, 20-35, 20-36
Growth trend report 16-3
I
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Image copy 3-3, 4-3, 4-10, 5-4, 5-5, 5-6, 5-9, 5-10, 5-14,
6-27, 7-7, 7-10, 9-17, 10-13
Incarnation 9-9
Index 1-15, 1-21, 1-34, 6-5, 6-7, 6-11, 6-12, 6-13, 11-13, 11-16,
13-28, 13-35, 13-38, 14-9, 15-9, 15-19, 15-26, 15-32, 15-35, 16-5, 16-13,
16-14, 16-20, 16-26, 18-3, 20-24, 20-26
Index-organized tables 16-14, 16-20
a ble
Initialization parameters 1-8, 1-24, 2-15, 2-25, 2-26, 8-6,
fe r
8-7, 8-8, 9-12, 9-17, 10-18, 11-6, 14-15, 14-32, 15-10, 15-11, 20-15, rans
20-16, 20-17, 20-18 o n -t
initorcl.ora 7-24 s an
INSTANCE_TYPE 1-24, 1-25, 1-39 ) ha ideฺ
c o m Gu
iot 16-13, 16-14, 16-20 ail ฺ nt
g m tude
J
u k i@ is S
y 14-21,
Java pool 1-7, 1-8, 14-4, 14-5,s14-12,
a e th 14-25
JAVA_POOL_SIZE 14-12, i ( M14-15,
t o us 14-28
14-26,
k se
job 1-11, 2-9, a syu5-21,
2-10,
c en5-24, 5-25, 5-37, 6-41, 7-5, 7-6,
M l i
n l ey 9-7, 10-5, 10-6, 10-7, 10-8, 10-9, 10-20, 10-33, 11-24, 14-3,
8-19,
Sta 14-21, 15-23, 15-37, 16-15, 16-16, 16-17, 16-18, 16-19, 16-35, 17-20, 18-2,
18-3, 18-4, 18-5, 18-6, 18-7, 18-8, 18-9, 18-10, 18-11, 18-12, 18-13,
18-14, 18-15, 18-16, 18-17, 18-18, 18-19, 18-20, 18-22, 18-23, 18-24, 18-25,
18-26, 18-27, 18-28, 18-29, 18-30, 18-31, 19-2, 19-3, 19-4, 19-5, 19-6,
19-7, 19-10, 19-11, 19-12, 19-13, 19-14, 19-15, 19-16, 19-17, 19-18, 20-32
job classes 19-2, 19-4, 19-5, 19-7, 19-10, 19-16, 19-18
K
Keep buffer cache 14-4, 14-5
L
Language and Character Set File Scanner 20-33
Large pool 1-7, 1-8, 10-16, 10-31, 10-32, 14-4, 14-5, 14-10, 14-11,
14-12, 14-21, 14-25, 14-30, 15-35

Oracle Database 11g: Administration Workshop II Index - 7


Computer Pride Limited

L
LARGE_POOL_SIZE 10-16, 10-31, 10-32, 14-11, 14-15, 14-26, 14-28
LCSSCAN 20-33
Library cache 1-7, 10-16, 14-10, 14-11, 14-12, 14-13, 14-38, 14-39,
15-31
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Linguistic sort 20-20, 20-24, 20-26, 20-28


Listener 8-19
Locale 20-3, 20-15, 20-16, 20-28
Lock 14-36, 15-18
LOCK_SGA 14-36
LOG_ARCHIVE_DEST 2-15, 2-16, 2-17, 2-18, 2-25, 6-31, 6-40, 6-41
LOG_ARCHIVE_DEST_n 2-15, 2-16, 2-17, 2-25
ble
LOG_ARCHIVE_DUPLEX_DEST 2-15, 2-18
fe r a
LOG_ARCHIVE_MIN_SUCCEED_DEST 2-17, 2-18
ans
LOG_BUFFER 14-15, 14-25, 15-14 n - t r
LOG_FILE_NAME_CONVERT 8-7 a no
a s
M ) h i d eฺ
m
o t5-40, G u
ilฺc 5-30,
Media management library 2-19, 4-3, 4-4, 4-6,a5-14,
en
g m u d
10-9
k i @ is St
Memory Advisor 14-34, 14-35 yu th
a s e
Memory Manager 14-12,(M 14-22 o us
u i
k se t
a y
Metric 2-32, 15-9, 15-16
s cen
MMAN 14-22y M li
l e
tan2-19, 4-3, 4-6, 5-14, 5-30, 5-31, 5-32, 10-3
SMML
MMON 15-20, 16-11
MTTR 13-36
N
National Language Support 18-11, 20-15
NLS 7-14, 9-13, 18-11, 20-3, 20-9, 20-10, 20-11, 20-14, 20-15, 20-16,
20-17, 20-18, 20-19, 20-22, 20-23, 20-24, 20-25, 20-26, 20-30, 20-31, 20-32,
20-36
NLS Runtime Library 20-3
NLS_COMP 20-24, 20-25
NLS_DATE_FORMAT 7-14, 9-13, 20-19
NLS_DATE_LANGUAGE 20-19

Oracle Database 11g: Administration Workshop II Index - 8


Computer Pride Limited

N
NLS_LANG 7-14, 9-13, 20-9, 20-10, 20-11, 20-16, 20-22, 20-30, 20-31,
20-32
NLS_LANGUAGE 20-16, 20-17, 20-18, 20-24, 20-26
NLS_SORT 20-22, 20-23, 20-24, 20-25, 20-26, 20-36
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

NLS_TERRITORY 20-16, 20-17, 20-18


NLSRTL 20-3
O
Object Privilege 12-4
OMF 5-12, 16-3, 16-39
Optimizer statistics 15-10, 15-11, 15-22, 17-6, 17-8
OPTIMIZER_DYNAMIC_SAMPLING 15-11
a ble
Oracle Locale Builder 20-28
e r
Oracle Managed Files 4-4, 8-8, 16-3, 16-39 a n sf
Oracle Net 8-5, 9-18, 20-9, 20-10 o n -tr
Oracle Shared Server 1-5, 14-10, 14-11 s an
ORACLE_BASE 6-25, 6-27, 6-31, 12-12, 13-4 ) ha ideฺ
c o m Gu
ORACLE_HOME 6-15, 6-16, 6-26, 9-19, 13-4, a l ฺ
i13-31, n t
15-21
gm Stud e
ORACLE_SID 1-25, 1-43, 3-9, 7-23
i @
k6-25, is 6-27, 6-31,
s y u
orcl 1-24, 1-43, 4-8, 6-6, 6-7, 6-24, t h
6-26,
a 13-6,
(M13-5,
6-32, 7-23, 7-26, 8-7, u se
u ki se t o 13-7, 13-38, 13-42, 13-43, 13-46
P y
as licen
M
Package
n l ey13-3, 13-5, 13-9, 13-10, 13-11, 13-12, 13-16, 13-17, 13-21,
Sta 13-22, 13-23, 13-24, 13-25, 13-26, 13-27, 13-28, 14-39, 15-10, 15-11, 15-17,
15-19, 15-23, 15-44, 16-10, 16-36, 17-7, 17-12, 18-3, 18-7, 18-11, 18-15,
18-22, 19-2, 19-6, 20-19
Parallelization 10-3, 10-4
partition 1-15, 12-30, 16-5, 16-20, 16-26
Password 1-5, 1-12, 1-23, 1-26, 1-27, 1-28, 3-9, 3-11, 3-15,
3-16, 3-17, 5-27, 5-28, 6-7, 6-14, 6-15, 6-16, 8-5, 9-18, 11-29,
16-39

Oracle Database 11g: Administration Workshop II Index - 9


Computer Pride Limited

P
Performance 1-3, 1-10, 1-20, 1-31, 1-45, 1-46, 5-24, 5-36, 9-17,
10-2, 10-3, 10-12, 10-13, 10-14, 10-17, 10-20, 10-23, 10-25, 10-27, 10-29,
10-31, 10-33, 10-34, 10-35, 11-4, 11-28, 12-8, 12-20, 12-30, 13-35, 14-3,
14-6, 14-8, 14-20, 14-21, 14-31, 14-32, 14-33, 15-1, 15-2, 15-3, 15-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

15-5, 15-6, 15-7, 15-8, 15-9, 15-10, 15-12, 15-13, 15-14, 15-15, 15-16,
15-17, 15-18, 15-19, 15-20, 15-22, 15-23, 15-26, 15-27, 15-31, 15-32, 15-37,
15-38, 15-39, 15-42, 15-44, 15-45, 15-46, 15-47, 16-3, 16-4, 16-8, 16-13,
17-3, 18-14, 19-11, 20-12, 20-26, 20-31, 20-33
PGA 1-4, 1-7, 1-8, 1-9, 1-19, 10-14, 10-16, 14-2, 14-4, 14-5,
14-14, 14-15, 14-16, 14-17, 14-18, 14-19, 14-20, 14-30, 14-31, 14-32, 14-33,
14-35, 14-40
ble
PGA_AGGREGATE_TARGET 14-15, 14-16, 14-17, 14-32, 14-33
fe r a
PMON 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22, 17-21
t r a ns
Private SQL area 14-5, 14-30 o n -
Privilege 1-27, 1-35, 3-30, 6-14, 6-15, 11-13, 12-4, 15-28, 16-23, s an
17-12, 18-6, 19-6 ) ha ideฺ
c o m Gu
Proactive Tablespace Monitoring 16-9
a il ฺ n t
Procedure 3-8, 3-35, 5-31, 7-17, 7-19, 7-21, gm7-28, e
ud 11-31,
11-28,
@ S t
11-35, 11-36, 13-30, 14-23, u
y ki 15-10,
14-39, t h is 15-20, 15-39, 15-40, 15-42, 15-43,
s
a 16-38, se17-11, 17-12, 17-21, 18-3, 18-5, 18-6,
15-44, 16-25, 16-30,M
( 16-37,
to u
u
18-7, 18-8, 18-11,
y ki 18-12,
s e 18-13, 18-14, 18-15, 18-16, 18-17, 18-18, 18-19,
18-21,M as 18-23,
18-22, l i c en18-28, 19-6, 19-9, 19-11, 19-12, 19-15, 20-19, 20-29
l y
e15-25,
t a n
Profile 15-26, 15-28
SProgram Global Area 1-8, 1-19, 10-16, 14-4, 14-5, 14-30, 14-31
R
Recovery catalog 2-7, 2-22, 3-1, 3-2, 3-3, 3-4, 3-5, 3-6,
3-7, 3-8, 3-9, 3-10, 3-11, 3-12, 3-13, 3-14, 3-15, 3-16, 3-17,
3-18, 3-20, 3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27, 3-28, 3-29,
3-30, 3-31, 3-32, 3-34, 3-36, 3-37, 4-5, 4-8, 5-19, 5-34, 5-36,
5-38, 7-16, 7-18, 7-19, 7-21, 7-22, 7-23, 7-27, 8-11, 9-9, 9-20,
10-9, 10-10, 13-41
Recovery Manager 2-6, 2-7, 2-8, 5-6, 5-31, 12-12, 13-42
Recycle bin 11-2, 11-3, 11-8, 11-9, 11-10, 11-11, 11-12, 11-13, 11-14,
11-15, 11-16, 11-38, 11-39

Oracle Database 11g: Administration Workshop II Index - 10


Computer Pride Limited

R
Recycle buffer cache 14-4, 14-5
recyclebin 11-8, 11-10, 11-12, 11-13, 11-15
RECYCLEBIN 11-8, 11-10, 11-12, 11-13, 11-15
Redo 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-12, 1-19, 2-5, 2-11,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

2-12, 2-13, 2-15, 2-17, 2-18, 2-24, 2-25, 2-26, 2-30, 3-4, 3-7,
3-16, 3-18, 3-20, 3-21, 4-3, 5-4, 5-5, 5-6, 5-11, 5-15, 5-23,
5-38, 6-2, 6-3, 6-5, 6-7, 6-8, 6-9, 6-10, 6-12, 6-18, 6-19,
6-20, 6-23, 6-26, 6-28, 6-33, 6-36, 6-37, 6-38, 6-39, 6-40, 6-42,
6-43, 6-46, 6-47, 6-48, 6-49, 6-50, 7-3, 7-20, 7-25, 7-27, 8-3,
8-5, 8-7, 8-8, 8-9, 8-10, 8-13, 8-14, 9-5, 9-14, 10-4, 11-28,
12-7, 12-9, 12-12, 12-13, 12-20, 12-22, 12-23, 13-28, 13-36, 13-37, 13-41,
ble
14-4, 14-11, 14-12, 14-13, 15-14, 16-39, 18-13, 18-14
fe r a
Redo log buffer 1-7, 1-8, 14-4, 14-13, 15-14
t r a ns
redo log groups 6-8 o n -
REMOTE_LOGIN_PASSWORDFILE 6-15 s an
Resource Manager 17-2, 17-3, 17-4, 17-5, 17-6, 17-8, 17-10, ) ha 17-14,
i d eฺ
m
co 17-28,G u
a l ฺ
17-17, 17-20, 17-22, 17-24, 17-25, 17-26, i17-27, n t 17-29, 17-30, 19-4,
19-6 gm Stud e
RESOURCE_MANAGER_PLAN u
@
ki 17-24
17-8, is
s y t h
restore point 5-20, 5-21, 5-22,
( M se 7-13, 7-14, 12-13,
a 5-23,u6-20,
12-19, 12-20,y u ki se to
12-21
ResumableM as allocation
space l i c en 16-2, 16-21, 16-22, 16-23, 16-40
n l ey
RESUMABLE_TIMEOUT 16-22
t a
SRetention Policy 2-2, 2-21, 2-22, 2-23, 2-29, 2-30, 2-34, 3-5,
3-27, 4-5, 4-13, 5-18, 5-19, 5-21, 5-22, 5-23, 5-35

Oracle Database 11g: Administration Workshop II Index - 11


Computer Pride Limited

R
RMAN 1-21, 2-2, 2-6, 2-7, 2-8, 2-9, 2-10, 2-19, 2-20, 2-21,
2-22, 2-23, 2-25, 2-28, 2-29, 2-30, 2-34, 2-35, 3-1, 3-2, 3-3,
3-4, 3-5, 3-7, 3-9, 3-11, 3-12, 3-15, 3-17, 3-18, 3-19, 3-20,
3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27, 3-28, 3-29, 3-30, 3-31,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

3-32, 3-33, 3-34, 3-35, 3-36, 3-37, 4-3, 4-5, 4-6, 4-7, 4-8,
4-9, 4-10, 4-12, 4-13, 4-16, 5-1, 5-3, 5-4, 5-6, 5-7, 5-8,
5-9, 5-10, 5-11, 5-13, 5-14, 5-15, 5-16, 5-17, 5-18, 5-19, 5-20,
5-22, 5-23, 5-24, 5-25, 5-26, 5-27, 5-28, 5-29, 5-30, 5-31, 5-32,
5-34, 5-38, 6-20, 6-21, 6-23, 7-1, 7-2, 7-3, 7-4, 7-5, 7-6,
7-7, 7-8, 7-14, 7-16, 7-17, 7-18, 7-19, 7-20, 7-21, 7-22, 7-23,
7-24, 7-25, 7-26, 7-29, 7-30, 8-1, 8-2, 8-3, 8-6, 8-7, 8-9,
ble
8-10, 8-11, 8-12, 8-13, 8-14, 8-21, 8-22, 9-3, 9-5, 9-6, 9-7,
fe r a
9-12, 9-13, 9-15, 9-16, 9-17, 9-18, 9-19, 9-20, 10-1, 10-2, 10-3,
t r a ns
n
10-4, 10-5, 10-6, 10-7, 10-8, 10-9, 10-10, 10-11, 10-12, 10-13, 10-14,
o -
10-16, 10-17, 10-18, 10-20, 10-23, 10-26, 10-27, 10-29, s a n 10-32, 10-33,
10-31,
)
10-34, 10-35, 10-36, 12-12, 12-13, 13-36, 13-37, 13-38, ha 13-39,
i d eฺ13-40, 13-41,
m
co 18-11, G u
l ฺ
13-42, 13-43, 13-44, 13-45, 16-30, 16-37, i16-38, n t 18-18
RMAN Repository 3-2, 3-3, 3-17, 3-27, 3-28,g ma3-36,tu4-5,
de4-7,
5-34, 5-38, 7-22 u k i@ is S
a s y e th
Role 1-26, 1-28, 3-8, 17-12,
i ( M 19-17
t o us
Rule 10-23, 18-16,y k 18-25,
u18-23, se 18-27, 18-29
a s e n
M
Rule set 18-29
y lic
le
S tan
SScheduler 15-10, 15-12, 15-37, 16-18, 17-8, 17-10, 18-1, 18-2, 18-3,
18-4, 18-5, 18-6, 18-7, 18-8, 18-9, 18-10, 18-11, 18-12, 18-13, 18-15,
18-16, 18-17, 18-18, 18-19, 18-20, 18-22, 18-25, 18-26, 18-27, 18-28, 18-29,
18-30, 18-31, 19-1, 19-2, 19-3, 19-4, 19-6, 19-7, 19-8, 19-9, 19-12,
19-13, 19-14, 19-15, 19-16, 19-17, 19-18
Schema 1-14, 1-15, 1-19, 3-5, 3-7, 3-20, 3-29, 3-30, 3-31, 5-36,
6-15, 7-22, 9-7, 11-11, 11-13, 11-17, 11-27, 11-30, 12-5, 12-6, 15-21,
15-32, 15-34, 15-36, 16-15, 16-19, 16-25, 18-6, 18-11, 18-22, 18-26, 19-6
SCN 3-5, 5-20, 6-20, 6-28, 6-33, 6-34, 6-36, 6-37, 6-39, 7-3,
7-7, 7-13, 7-14, 7-15, 7-26, 9-4, 9-9, 11-18, 11-24, 12-6, 12-13,
12-16, 12-18, 12-19, 12-22, 12-24, 12-30, 15-43

Oracle Database 11g: Administration Workshop II Index - 12


Computer Pride Limited

S
Segment 1-14, 1-15, 1-18, 1-19, 1-30, 5-8, 9-4, 11-4, 11-22,
13-28, 14-9, 15-18, 16-2, 16-3, 16-4, 16-5, 16-6, 16-7, 16-8, 16-12,
16-13, 16-14, 16-15, 16-16, 16-17, 16-18, 16-19, 16-20, 16-25, 16-40, 16-41,
17-8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

Segment Advisor 16-2, 16-6, 16-8, 16-15, 16-16, 16-17, 16-18, 16-19,
16-40, 16-41, 17-8
Separation of Duties 3-32
Sequence 3-8, 4-8, 6-39, 6-42, 6-43, 7-14, 12-13, 12-16, 14-38,
14-39, 15-20, 20-20, 20-26
Server sessions 10-3, 10-4, 10-5
Session memory 14-5, 14-11, 14-31
ble
SESSIONS 1-5, 10-3, 10-4, 10-5, 10-6, 13-44, 14-7, 14-10, 14-32,
fe r a
15-2, 15-4, 15-8, 15-12, 15-13, 15-14, 15-15, 15-16, 15-17, 15-39, 15-42,
t r a ns
15-46, 15-47, 16-11, 16-23, 17-3, 17-4, 17-5, 17-6, 17-9, 17-11,o17-13, n -
17-14, 17-15, 17-17, 17-18, 17-21, 17-22, 17-26, 17-27, s a n 18-4, 20-2,
17-28,
20-16, 20-35 ) ha ideฺ
c o m Gu
il
SGA 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-19, 5-11, 10-16,
a ฺ t
10-31,
n
12-9, 14-2, 14-4, 14-6, 14-8, 14-11,g m 14-14,
14-12,
e
ud 14-15, 14-16, 14-17,
@ S t
14-18, 14-19, 14-20, 14-21, u
y ki 14-23,
14-22, t h is 14-24, 14-25, 14-26, 14-27, 14-28,
s
a 14-36, se14-37, 14-40, 15-14, 15-20
14-29, 14-30, 14-33,M
( 14-34, u
o 14-23, 14-27
SGA_MAX_SIZE y14-15, u ki 14-16,
s e t14-17,
SGA_TARGET M as1-8, 14-15,
l i c en 14-16, 14-17, 14-21, 14-23, 14-24, 14-25, 14-26,
n l ey 14-28, 14-29
14-27,
ta
SShared pool 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-45, 10-16, 10-31,
10-32, 14-4, 14-5, 14-10, 14-11, 14-12, 14-13, 14-19, 14-21, 14-24, 14-25,
14-28, 14-29, 14-30, 14-34, 14-38, 15-14
Shared server 1-5, 1-9, 14-4, 14-5, 14-10, 14-11, 14-30, 14-31,
15-43
SHARED_POOL_SIZE 14-10, 14-15, 14-24, 14-26, 14-28, 14-29
Shrink Advisor 16-15
SID 1-22, 1-25, 1-43, 3-9, 3-13, 7-23, 10-5, 10-6, 10-7, 13-4,
15-16, 17-10
SMON 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22
Snapshot 3-20, 5-20, 12-25, 14-7, 15-20, 15-21, 15-42

Oracle Database 11g: Administration Workshop II Index - 13


Computer Pride Limited

S
SORT_AREA_SIZE 14-32
SPFILE 1-24, 4-3, 4-6, 5-6, 7-17, 7-19, 7-24, 8-9, 14-21, 14-22,
14-23, 14-32
SQL Access Advisor 15-2, 15-23, 15-26, 15-27, 15-32, 15-33, 15-34, 15-37,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

15-46, 15-47
SQL Tuning Advisor 15-2, 15-23, 15-26, 15-27, 15-28, 15-29, 15-30, 15-31,
15-46, 15-47
SQL*Loader 6-12, 15-43, 16-22, 20-19, 20-30, 20-31
SQL*Plus 1-5, 1-8, 1-9, 3-35, 6-21, 6-33, 6-39, 8-9, 10-6,
11-15, 11-27, 13-5, 15-8, 16-41, 17-30, 18-31, 20-19
Statistics 1-22, 10-7, 12-7, 12-24, 13-28, 14-22, 14-33, 15-7, 15-8,
ble
15-9, 15-10, 15-11, 15-12, 15-13, 15-14, 15-16, 15-17, 15-18, 15-19, 15-20,
fe r a
15-22, 15-23, 15-26, 15-28, 15-32, 15-37, 16-15, 16-18, 17-6, 17-8, 17-20,
t r a ns
17-26, 17-27, 18-3, 18-6 o n -
STATISTICS_LEVEL 10-7, 15-9, 15-11, 15-14 s an
Statspack 15-21 ) ha ideฺ
m u
Streams pool 1-7, 1-8, 14-4, 14-5, 14-21, 14-25ilฺco nt G
STREAMS_POOL_SIZE 14-15, 14-26, 14-28 g ma tude
k i@ i s S
SYSAUX 1-17, 6-7, 6-24, 6-26, 7-26,u 12-17,
t h
sy1-35,se3-33,
15-20
SYSDBA 1-12, 1-26, 1-27,
( a
M to u
1-28, 3-34, 3-35, 6-14, 6-15,
i
uk 11-29,
6-16, 11-13, y11-27,
a s e n se 12-29
SYSOPER M lic1-28, 3-33, 3-35, 6-14, 6-15, 6-16
y 1-12, 1-27,
l e
n privilege 6-14, 11-13, 12-4, 15-28, 16-23
System
t a
SSystem statistics 15-9, 15-10, 15-11, 15-13, 15-14
SYSTEM tablespace 1-17, 6-29, 7-6, 8-14, 9-4, 13-35, 14-7, 16-36

Oracle Database 11g: Administration Workshop II Index - 14


Computer Pride Limited

T
Tablespace 1-14, 1-15, 1-16, 1-17, 1-18, 1-19, 1-30, 1-43, 3-7,
3-8, 3-9, 3-29, 3-31, 4-3, 4-5, 5-3, 5-14, 5-18, 6-2, 6-5,
6-6, 6-7, 6-13, 6-22, 6-23, 6-26, 6-28, 6-29, 6-30, 6-33, 6-34,
6-45, 6-49, 7-3, 7-5, 7-6, 7-11, 8-14, 9-1, 9-2, 9-3, 9-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

9-5, 9-6, 9-7, 9-9, 9-10, 9-11, 9-13, 9-14, 9-18, 9-19, 9-20,
9-21, 11-5, 11-6, 11-7, 11-10, 11-12, 11-13, 11-14, 11-15, 12-4, 12-17,
12-18, 12-19, 12-27, 12-28, 13-35, 13-42, 13-45, 13-46, 14-7, 15-7, 15-20,
15-36, 16-2, 16-3, 16-4, 16-5, 16-6, 16-9, 16-10, 16-11, 16-15, 16-16,
16-27, 16-28, 16-29, 16-30, 16-33, 16-36, 16-40
Target database 2-7, 2-35, 3-3, 3-4, 3-5, 3-10, 3-11, 3-12,
3-13, 3-15, 3-17, 3-20, 3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27,
ble
3-28, 3-30, 3-31, 3-32, 3-33, 3-34, 3-35, 4-5, 4-9, 5-31, 5-36,
fe r a
7-21, 7-22, 7-27, 7-28, 8-3, 8-4, 8-5, 8-6, 8-7, 8-10, 8-11,
t r a ns
8-12, 8-14, 9-5, 9-6, 9-16, 9-17, 10-5, 13-37, 13-42, 16-28, 16-29,
o n -
16-36, 20-30, 20-32 s an
temporary tablespace 1-14, 1-15, 3-8, 6-5, 6-7, 9-4, 9-19, ) ha ideฺ
c o m Gu
16-11
a il ฺ n t
Temporary tablespace 1-14, 1-15, 3-8, 6-5,gm6-7,S9-4, e
ud9-19,
@ t
16-11
y u ki this
a s 12-13,se15-12
THREAD 1-6, 6-42, 10-5,M
( 10-22,
to u
u
Threshold 11-6, 16-10,
y ki 16-11,
s e 16-18, 16-41, 17-5, 17-13, 17-20, 18-19
M as lic15-14
TIMED_STATISTICS en
Tracen l ey 1-12, 1-13, 13-5, 13-6, 13-7, 13-22, 13-24, 13-38
Files
ta
STRANSACTIONS 1-15, 2-4, 2-13, 6-8, 6-17, 6-18, 6-19, 6-20, 6-34,
7-14, 11-3, 11-4, 11-5, 11-17, 11-20, 11-21, 11-23, 11-26, 11-29, 11-31,
11-32, 11-35, 11-36, 11-37, 12-32, 14-11, 15-4, 15-6, 15-43, 16-5, 16-25
Trigger 1-44, 3-8, 14-15, 16-10, 16-23, 16-24, 16-25, 18-17
U
Undo 1-15, 6-7, 6-18, 6-19, 6-20, 7-5, 7-6, 8-14, 9-4, 9-7,
9-19, 9-20, 11-3, 11-4, 11-5, 11-6, 11-7, 11-8, 11-23, 11-25, 11-33,
11-34, 12-4, 12-7, 12-8, 12-18, 12-27, 12-32, 13-28, 16-5, 16-10, 16-11,
17-5, 17-13, 17-19
Undo data 6-18, 6-20, 7-6, 11-3, 11-5, 11-6, 11-7, 11-25
UNDO_MANAGEMENT 11-6

Oracle Database 11g: Administration Workshop II Index - 15


Computer Pride Limited

U
UNDO_RETENTION 11-6, 11-7, 16-10
UNDO_TABLESPACE 11-6
User Global Area 14-10
USER_DUMP_DEST 10-9, 13-4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

UTC 20-34
V
V$BACKUP 5-13, 5-25, 5-36, 10-20, 10-21, 10-22
V$BACKUP_ASYNC_IO 10-20, 10-21
V$BACKUP_DATAFILE 5-13, 5-25
V$BACKUP_FILES 5-36
V$BACKUP_PIECE 5-36
a ble
V$BACKUP_SET 5-25, 5-36
e r
V$BACKUP_SYNC_IO 10-20, 10-22 a n sf
V$BGPROCESS 1-11, 15-18 o n -tr
V$BLOCK_CHANGE_TRACKING 5-13 s an
V$BUFFER_POOL 15-18 ) ha ideฺ
c o m Gu
V$BUFFER_POOL_STATISTICS 15-18 a il ฺ n t
gm Stud e
V$CONTROLFILE 6-24
@
ki this 13-38, 15-18, 16-31
V$DATABASE 3-15, 7-23, 12-10,
s y u12-22, 13-36,
( M a
V$DATABASE_BLOCK_CORRUPTION u se 13-36, 13-38
u ki 6-30,e to
say
V$DATAFILE 5-36, 6-24,
e s
n 6-32, 7-25, 15-18
yM
V$DATAFILE_COPY lic5-36
l e
tan 15-18
SV$DBFILE
V$EVENT_NAME 15-12, 15-13, 15-16
V$FILESTAT 15-18
V$FLASHBACK_DATABASE_LOG 12-22
V$FLASHBACK_DATABASE_STAT 12-22
V$INSTANCE 15-18
V$LATCH 15-18
V$LIBRARYCACHE 15-18
V$LOCK 15-18
V$LOG 6-10, 6-43, 15-18
V$LOG_HISTORY 6-43, 15-18
V$MYSTAT 15-16

Oracle Database 11g: Administration Workshop II Index - 16


Computer Pride Limited

V
V$PARAMETER 14-26, 15-18
V$PGA_TARGET_ADVICE 14-33
V$PGA_TARGET_ADVICE_HISTOGRAM 14-33
V$PGASTAT 14-33, 15-18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

V$PROCESS 10-5, 10-6, 14-33, 15-18


V$PWFILE_USERS 1-26
V$PX_PROCESS 15-18
V$PX_PROCESS_SYSSTAT 15-18
V$RECOVER_FILE 6-28, 6-30
V$RECOVERY_FILE_DEST 12-23
V$RECOVERY_LOG 6-28, 6-29, 6-30
ble
V$RSRC_CONSUMER_GROUP 17-27, 17-28
fe r a
V$RSRC_PLAN 17-27
t r a ns
V$SEGMENT_STATISTICS 15-18 o n -
V$SERVICE_EVENT 15-17 s an
V$SERVICE_WAIT_CLASS 15-17 ) ha ideฺ
c o m Gu
il
V$SESSION 10-5, 10-6, 10-7, 15-16, 16-25, 17-27,
a ฺ 17-28
n t
V$SESSION_EVENT 15-16 gm Stud e
V$SESSION_LONGOPS 10-7 uk
i @ is
s y t h
V$SESSION_WAIT 15-16,
( M a use
16-25
V$SESSMETRICy15-16 u ki se to
V$SESSTAT M as l15-16,
14-33, i c en 17-27
l y
e14-23,
V$SGA
t a n 14-24
SV$SGA_DYNAMIC_COMPONENTS 14-24
V$SGA_DYNAMIC_FREE_MEMORY 14-23
V$SGAINFO 15-18
V$SGASTAT 10-32, 14-24, 15-13, 15-14
V$SPPARAMETER 15-18
V$SQL 14-33
V$SQL_WORKAREA 14-33
V$SQL_WORKAREA_ACTIVE 14-33
V$STATISTICS_LEVEL 15-11
V$STATNAME 15-13, 15-16
V$SYSSTAT 14-33, 15-13, 15-14, 15-16, 17-27

Oracle Database 11g: Administration Workshop II Index - 17


Computer Pride Limited

V
V$SYSTEM_EVENT 15-13, 15-18
V$SYSTEM_PARAMETER 15-18
V$SYSTEM_WAIT_CLASS 15-13, 15-14
V$TABLESPACE 6-30, 12-17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ

V$TEMPFILE 15-18
V$TEMPSEG_USAGE 15-18
V$TRANSACTION 11-4
V$TRANSPORTABLE_PLATFORM 16-31, 16-36
V$UNDOSTAT 11-7, 15-18
V$WAITSTAT 15-18
W
ble
Wait event 15-12
fe r a
window groups 19-2, 19-17, 19-18 ans
n - t r
Work area 1-15, 1-31, 14-31, 14-33 o
an
Workload repository 15-18, 15-20, 15-21, 16-3, 16-9, 16-15as
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
le y
n
Sta

Oracle Database 11g: Administration Workshop II Index - 18

S-ar putea să vă placă și