You are on page 1of 0

Oracle Database 11g:

Administration Workshop II
Volume III Student Guide
D50079GC10
Edition 1.0
November 2007
D53300

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Copyright 2007, Oracle. All rights reserved.
Disclaimer
This document contains proprietary information and is protected by copyright and
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
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,
license, post, transmit, or distribute this document in whole or in part without the
express authorization of Oracle.
The information contained in this document is subject to change without notice. If you
find any problems in the document, please report them in writing to: Oracle University,
500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Restricted Rights Notice
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
applicable:
U.S. GOVERNMENT RIGHTS
The U.S. Governments rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
license agreement and/or the applicable U.S. Government contract.
Trademark Notice
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
names may be trademarks of their respective owners.
Authors
Tom Best
James Spiller
James Womack
Maria Billings
Technical Contributors
and Reviewers
Sharath Bhujani
Timothy Chien
Al Flournoy
Andy Fortunak
Gerlinde Frenzen
Joel Goodman
Magnus Isaksson
Pete Jones
Donna Keesling
Pierre Labrousse
Gwen Lazenby
Jerry Lee
Hakan Lindfors
Isabelle Marchand
Srinivas Putrevu
Andreas Reinhardt
Ira Singer
Editors
Arijit Ghosh
Amitha Narayan
Atanu Raychaudhuri
Graphic Designer
Rajiv Chandrabhanu
Publishers
Nita Brozowski
Giri Venugopal
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

iii
Contents




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
Process Structures 1-10
Database Storage Architecture 1-12
Logical and Physical Database Structures 1-14
Tablespaces and Data Files 1-16
SYSTEM and SYSAUX Tablespaces 1-17
Segments, Extents, and Blocks 1-18
Database Architecture: Summary of Structural Components 1-19
Automatic Storage Management: Review 1-20
ASM: General Architecture 1-22
Creating an ASM Instance 1-23
ASM Instance Initialization Parameters 1-24
Starting Up an ASM Instance 1-25
SYSASM Role 1-26
Accessing an ASM Instance 1-27
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

iv
Miscellaneous ALTER Commands 1-43
ASMCMD Utility 1-44
ASM Scalability and Performance 1-46
Summary 1-48
Practice 1 Overview: Database Architecture and ASM 1-49

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
Types of RMAN Commands 2-9
Job Commands: Example 2-10
Configuring Your Database for Backup and Recovery Operations 2-11
ARCHIVELOG Mode 2-12
Configuring ARCHIVELOG Mode 2-13
Configuring Archive Log Destinations 2-15
Guaranteeing Archive Log Success 2-17
Specifying a Backup Destination 2-19
Specifying a Retention Policy 2-21
A Recovery Window Retention Policy: Example 2-23
Using a Flash Recovery Area 2-24
Defining a Flash Recovery Area 2-26
Defining a Flash Recovery Area Using Enterprise Manager 2-27
Flash Recovery Area Space Management 2-28
Flash Recovery Area Space Usage 2-30
Monitoring the Flash Recovery Area 2-32
Benefits of Using a Flash Recovery Area 2-33
Summary 2-34
Practice 2 Overview: Configuring for Recoverability 2-35

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
Configuring the Recovery Catalog Database 3-7
Creating the Recovery Catalog Owner 3-8
Creating the Recovery Catalog 3-9
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

v
Managing Target Database Records in the Recovery Catalog 3-10
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
Executing RMAN Stored Scripts 3-24
Displaying RMAN Stored Script Information 3-25
Updating and Deleting RMAN Stored Scripts 3-26
Backing Up the Recovery Catalog 3-27
Re-Creating an Unrecoverable Recovery Catalog 3-28
Exporting and Importing the Recovery Catalog 3-29
Upgrading the Recovery Catalog 3-30
Dropping the Recovery Catalog 3-31
Using a Virtual Private Catalog 3-32
Creating an RMAN Virtual Private Catalog 3-34
Summary 3-36
Practice 3 Overview: Using the RMAN Recovery Catalog 3-37

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

5 Using RMAN to Create Backups
Objectives 5-2
Creating Backup Sets 5-3
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

vi
Creating Image Copies 5-4
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
Backing Up Read-Only Tablespaces 5-18
Archival Backups: Concepts 5-19
Creating Archival Backups with EM 5-21
Creating Archival Backups with RMAN 5-22
Managing Archival Database Backups 5-23
Multisection Backups: Overview 5-24
Creating RMAN Multisection Backups 5-25
Compressing Backups 5-26
Encrypting Backups 5-27
Backing Up Recovery Files 5-29
Using a Media Manager 5-30
Performing Proxy Copies 5-32
Creating an Oracle-Suggested Backup 5-33
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
Log Group Status: Review 6-8
Recovering from the Loss of a Redo Log Group 6-9
Clearing a Log File 6-10
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

vii
Re-Creating Indexes 6-11
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
Manually Backing Up a NOARCHIVELOG Database 6-25
Manually Backing Up an ARCHIVELOG Database 6-26
Backing Up the Control File 6-27
Performing User-Managed Complete Database Recovery: Overview 6-28
Performing Complete Closed Database Recovery: Overview 6-29
Identifying Recovery-Related Files 6-30
Restoring Recovery-Related Files 6-31
Applying Redo Data 6-33
Performing Complete Open Database Recovery 6-34
Performing User-Managed Incomplete Recovery: Overview 6-36
Choosing an Incomplete Recovery Method 6-37
Performing User-Managed Incomplete Recovery 6-38
Performing User-Managed Incomplete Recovery: Steps 6-40
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
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

viii
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
Restoring the Control File from Autobackup 7-18
Using Incremental Backups to Recover a Database in NOARCHIVELOG Mode 7-20
Restoring and Recovering the Database on a New Host 7-21
Preparing to Restore the Database to a New Host 7-22
Restoring the Database to a New Host 7-23
Performing Disaster Recovery 7-27
Summary 7-29
Practice 7 Overview: Using RMAN to Perform Recovery 7-30

8 Using RMAN to Duplicate a Database
Objectives 8-2
Using RMAN to Create a Duplicate Database 8-3
Using a Duplicate Database 8-4
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
Summary 8-21
Practice 8 Overview: Using RMAN to Duplicate a Database 8-22

9 Performing Tablespace Point-in-Time Recovery
Objectives 9-2
Tablespace Point-in-Time Recovery (TSPITR): Concepts 9-3
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

ix
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
Performing Fully Automated TSPITR 9-13
Using Enterprise Manager to Perform TSPITR 9-14
RMAN TSPITR Processing 9-15
Performing RMAN TSPITR with an RMAN-Managed Auxiliary Instance 9-17
Performing RMAN TSPITR Using Your Own Auxiliary Instance 9-18
Troubleshooting RMAN TSPITR 9-19
Summary 9-21
Practice 9 Overview: Performing TSPITR 9-22

10 Monitoring and Tuning RMAN
Objectives 10-2
Parallelization of Backup Sets 10-3
Monitoring RMAN Sessions 10-5
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-25
Controlling Tape Buffer Size with BLKSIZE 10-26
Channel Tuning 10-27
Tuning the BACKUP Command 10-29
Tuning RMAN Backup Performance 10-31
Setting LARGE_POOL_SIZE 10-32
Tuning RMAN Tape Streaming Performance Bottlenecks 10-33
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

x
Summary 10-35
Practice 10 Overview: Monitoring and Tuning RMAN 10-36

11 Using Flashback Technology
Objectives 11-2
Flashback Technology 11-3
Transactions and Undo 11-4
Guaranteeing Undo Retention 11-5
Preparing Your Database for Flashback 11-6
Flashback Drop and the Recycle Bin 11-8
Recycle Bin 11-9
Restoring Tables from the Recycle Bin 11-11
Recycle Bin: Automatic Space Reclamation 11-12
Recycle Bin: Manual Space Reclamation 11-13
Bypassing the Recycle Bin 11-14
Querying the Recycle Bin 11-15
Querying Data from Dropped Tables 11-16
Using Flashback Technology to Query Data 11-17
Flashback Query 11-18
Flashback Query: Example 11-19
Flashback Version Query 11-20
Using Enterprise Manager to Perform Flashback Version Query 11-21
Flashback Version Query: Considerations 11-22
Flashback Transaction Query 11-23
Using Enterprise Manager to Perform Flashback Transaction Query 11-24
Flashback Transaction Query: Considerations 11-25
Flashback Transaction 11-26
Prerequisites 11-27
Flashing Back a Transaction 11-28
Possible Workflow 11-29
Viewing Data 11-30
Flashback Transaction Wizard 11-31
Choosing Other Back-out Options 11-35
Final Steps Without EM 11-37
Summary 11-38
Practice 11 Overview: Performing Flashback Database 11-39

12 Additional Flashback Operations
Objectives 12-2
Flashback Table: Overview 12-3
Flashback Table 12-4
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xi
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
Flashback Database: Examples 12-13
Performing Flashback Database Using EM 12-14
Excluding Tablespaces from Flashback Database 12-17
Flashback Database Considerations 12-18
Guaranteed Restore Points 12-19
Flashback Database and Guaranteed Restore Points 12-20
Monitoring Flashback Database 12-22
Monitoring Flashback Database with EM 12-24
Flashback Data Archive 12-25
Flashback Data Archive Process 12-26
Flashback Data Archive Scenario 12-27
Viewing Flashback Data Archives 12-29
Flashback Data Archive DDL Restrictions 12-30
Summary 12-31
Practice 12 Overview: Working with Flashback Database 12-32

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
Viewing Critical Error Alerts in Enterprise Manager 13-12
Viewing Problem Details 13-13
Viewing Incident Details 13-14
Creating a Service Request 13-16
Packaging and Uploading Diagnostic Data to Oracle Support 13-17
Tracking the SR 13-18
Implementing Repairs 13-19
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xii
Closing Incidents and Problems 13-20
Incident Packaging Configuration 13-21
Custom Packaging: Creating a New Package 13-22
Custom Packaging: Manipulating an Incident Package 13-23
Custom Packaging: Finalizing an Incident Package 13-24
Custom Packaging: Generating a Package 13-25
Custom Packaging: Uploading a Package 13-26
Viewing and Modifying Incident Packages 13-27
Health Monitor: Overview 13-28
Running Health Checks Manually: EM Example 13-29
Running Health Checks Manually: PL/SQL Example 13-30
Viewing HM Reports Using the ADRCI Utility 13-31
What Is Block Corruption? 13-32
Block Corruption Symptoms: ORA-01578 13-33
How to Handle Corruption 13-34
Verifying Block Integrity in Real Time: DB_BLOCK_CHECKING 13-35
Block Media Recovery 13-36
Prerequisites for Block Media Recovery 13-37
The RECOVER...BLOCK Command 13-38
Data Recovery Advisor 13-39
Data Recovery Advisor: RMAN Command-Line Interface 13-40
Listing of Data Failures 13-41
Advising on Repair 13-43
Executing Repairs 13-44
Classifying (and Closing) Failures 13-45
Data Recovery Advisor Views 13-46
Summary 13-47
Practice 13 Overview: Diagnosing the Database 13-48

14 Managing Memory
Objectives 14-2
Memory Management: Overview 14-3
Oracle Memory Structures 14-4
Buffer Cache 14-6
Using Multiple Buffer Pools 14-8
Shared Pool 14-10
Large Pool 14-11
Java Pool 14-12
Redo Log Buffer 14-13
Automatic Memory Management: Overview 14-14
Oracle Database Memory Parameters 14-15
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xiii
Automatic Memory Parameter Dependency 14-16
Enabling Automatic Memory Management with EM 14-18
Monitor Automatic Memory Management 14-19
Monitoring Automatic Memory Management 14-20
Automatic Shared Memory Management: Overview 14-21
How ASMM Works 14-22
Enabling Automatic Shared Memory Management 14-23
Behavior of Autotuned SGA Parameters 14-24
Behavior of Manually Tuned SGA Parameters 14-25
Using the V$PARAMETER View 14-26
Modifying the SGA_TARGET Parameter 14-27
Disabling ASMM 14-28
Manually Resizing Dynamic SGA Parameters 14-29
Program Global Area (PGA) 14-30
Automatic PGA Memory Management 14-32
PGA Management Resources 14-33
Using the Memory Advisor to Size the SGA 14-34
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
Oracle Wait Events 15-12
System Statistics 15-13
Monitoring Session Performance 15-15
Displaying Session-Related Statistics 15-16
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xiv
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
SQL Tuning Advisor Options 15-28
SQL Tuning Advisor Recommendations 15-29
Using the SQL Tuning Advisor: Example 15-30
SQL Tuning Advisor: Identifying Duplicate SQL 15-31
SQL Access Advisor: Overview 15-32
Typical SQL Access Advisor Session 15-33
Workload Source 15-34
Recommendation Options 15-35
Reviewing Recommendations 15-37
Database Replay 15-38
System Architecture: Capture 15-39
System Architecture: Processing the Workload 15-40
System Architecture: Replay 15-41
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
Row Chaining and Migration 16-8
Proactive Tablespace Monitoring 16-9
Thresholds and Resolving Space Problems 16-10
Monitoring Tablespace Space Usage 16-11
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xv
Automatic Segment Advisor 16-18
Manual Segment Shrink Using EM 16-19
Shrinking Segments Using SQL 16-20
Managing Resumable Space Allocation 16-21
Using Resumable Space Allocation 16-22
Resuming Suspended Statements 16-24
What Operations are Resumable? 16-26
Transporting Tablespaces 16-27
Concept: Minimum Compatibility Level 16-28
Minimum Compatibility Level 16-29
Transportable Tablespace Procedure 16-30
Determining the Endian Format of a Platform 16-31
Transportable Tablespaces with Enterprise Manager 16-33
Transporting Databases 16-36
Database Transportation Procedure: Source System Conversion 16-37
Database Transportation Procedure: Target System Conversion 16-38
Database Transportation: Considerations 16-39
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
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
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xvi
Monitoring the Resource Manager 17-26
Summary 17-29
Practice 17 Overview: Using the Resource Manager 17-30

18 Automating Tasks with the Scheduler
Objectives 18-2
Simplifying Management Tasks 18-3
A Simple Job 18-4
Key Components and Steps 18-5
1. Creating a Program 18-6
2. Creating and Using Schedules 18-7
3. Creating and Running a Job 18-8
4. Monitoring a Job 18-9
Using a Time-Based or Event-Based Schedule 18-10
Creating a Time-Based Job 18-11
Persistent Lightweight Jobs 18-13
Choosing the Right Job 18-14
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
Summary 18-31
Practice 18 Overview: Automating Tasks with the Scheduler 18-32

19 Administering the Scheduler
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

xvii
Creating an Array of Lightweight Jobs 19-11
Creating Lightweight Jobs 19-12
Viewing Lightweight Jobs in Dictionary 19-14
PL/SQL APIs 19-15
Generic Scheduler Data Dictionary Views 19-16
Summary 19-18

20 Globalization
Objectives 20-2
Globalization Support Features 20-3
What Every DBA Needs to Know 20-4
What Is a Character Set? 20-5
Understanding Unicode 20-7
How Are Character Sets Used? 20-9
Problems to Avoid 20-10
Another Sample Problem 20-11
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- 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- 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
NLS Data Conversion with Oracle Utilities 20-30
NLS Data Conversion with Data Pump 20-32
The Language and Character Set File Scanner (LCSSCAN) 20-33
Setting the Database Time Zone 20-34
Summary 20-35
Practice 20 Overview: Using Globalization Support 20-36

A Practices and Solutions

Index
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y


Appendix A
Practices and Solutions



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-2
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 ........................................................................ 18
Practice 1-3: ASMCMD ............................................................................................... 23
Practices for Lesson 2....................................................................................................... 25
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................................................................... 34
Practice 3-2: Creating the Recovery Catalog Owner.................................................... 47
Practice 3-3: Creating the Recovery Catalog................................................................ 48
Practice 3-4: Registering a Database in the Recovery Catalog..................................... 49
Practice 3-5: Cataloging Additional Backup Files........................................................ 51
Practice 3-6: Backing Up the Recovery Catalog .......................................................... 53
Practices for Lesson 4....................................................................................................... 56
Practice 4-1: Setting the Date and Time Format for RMAN........................................ 57
Practice 4-2: Enabling Control File Autobackup.......................................................... 58
Practice 4-3: Configuring Devices for Backup............................................................. 60
Practices for Lesson 5....................................................................................................... 62
Practice 5-1: Creating Fast Incremental Backups......................................................... 63
Practice 5-2: Cross-Checking Backups......................................................................... 66
Practice 5-3: Listing Backup Files................................................................................ 70
Practices for Lesson 6....................................................................................................... 82
Practice 6-1: Backing Up a NOARCHIVELOG Database.............................................. 83
Practice 6-2: Recovering from the Loss of All Control File Copies............................. 87
Practice 6-3: Recovering from Loss of a Redo Log Group .......................................... 93
Practices for Lesson 7....................................................................................................... 96
Practice 7-1: Recovering Image Copies........................................................................ 97
Practice 7-2: Performing Fast Recovery..................................................................... 104
Practices for Lesson 8..................................................................................................... 111
Practice 8-1: Cloning a Database................................................................................ 112
Practices for Lesson 9..................................................................................................... 123
Practice 9-1: Performing Tablespace Point-in-Time Recovery.................................. 124
Practices for Lesson 10................................................................................................... 135
Practice 10-1: Monitoring RMAN Jobs...................................................................... 136
Practices for Lesson 11................................................................................................... 138
In these practices you use the recycle bin to flash back dropped objects. You also
explore the workings of Flashback Transaction. ........................................................ 138
Practice 11-1: Using the Recycle Bin......................................................................... 139
Practice 11-2: Flashback Transaction Backout........................................................... 142
Practices for Lesson 12................................................................................................... 151
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-3
The following practices cover the usage of Flashback Database and Flashback Data
Archive........................................................................................................................ 151
Practice 12-1: Flashback Database ............................................................................. 152
Practice 12-2: Using Flashback Data Archive............................................................ 158
Practices for Lesson 13................................................................................................... 173
Practice 13-1: Diagnostic Scenario............................................................................. 174
Practice 13-2: Repairing Block Corruption ................................................................ 185
Practice 13-3: SQL Repair Advisor Scenario............................................................. 194
Practices for Lesson 14................................................................................................... 211
Practice 14-1: Using Automatic Memory Management ............................................. 212
Practices for Lesson 15................................................................................................... 229
Practice 15-1: Monitoring Services ............................................................................ 230
Practice 15-2: Using SQL Tuning Advisor................................................................. 239
Practices for Lesson 16................................................................................................... 244
Solution for Practice 16-1: Managing Storage............................................................ 245
Practices for Lesson 17................................................................................................... 255
Practice 17-1: Managing Resources............................................................................ 256
Practices for Lesson 18................................................................................................... 268
Practice 18-1: Creating Scheduler Components ......................................................... 269
Practice 18-2: Creating Lightweight Scheduler Jobs.................................................. 277
Practice 18-3: Monitoring the Scheduler .................................................................... 283
Practices for Lesson 19................................................................................................... 288
Practices for Lesson 20................................................................................................... 289
Practice 20-1: Using Globalization Support ............................................................... 290


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-4
Practices for Lesson 1
In this practice, you upgrade the database storage from file system files to ASM. You
also explore the functionality of the ASM command-line utility, ASMCMD.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-5
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 6 GB slices employing external redundancy. Then you use
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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-6

3) On the next page, select Configure Automatic Storage Management from the list of
possible operations, and then click Next to continue.


4) You are asked to run the localconfig script to set up local Cluster
Synchronization Service (CSS) for high availability purposes.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-7

5) Open a terminal window and run the localconfig add script as root.

When the script has completed, click OK to dismiss the localconfig dialog box.

6) After returning to the Operations page, click Next to continue.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-8

7) The new ASM instance must have a password for the SYS account. Use oracle for
the password and click Next.


8) Click OK to start the ASM instance.

Wait a few moments while the instance starts.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-9

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


10) Enter DATA for the Disk Group Name and select Normal redundancy. Select the first
four raw slices that are 3 GB in size, and click OK.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-10

11) Click Create New to create the next diskgroup for the flash recovery area.


12) Enter FRA for the Disk Group Name and select External Redundancy. There will be
four raw slices of 3 GB left. Select them and click OK to continue.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-11


13) Both diskgroups should be mounted at this stage. Click Finish to continue.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-12

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


15) Connect to Enterprise Manager using the URL: https://your_host_name:1158/em.
Enter sys as your username and oracle as your password, and connect as
sysdba.



16) On the Database home page, click the Server folder tab, and then click Migrate to
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-13


17) In the Files to Be Migrated section, select all three check boxes: Database Files,
Recovery-related Files, and Parallelism. The working directory should be the same as
the database home, /u01/app/oracle/product/11.1.0/db_1/dbs. Click
Next to continue.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-14

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.


19) On the Schedule page, select Immediately in the Start section and click Next to
continue.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-15

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.


21) After the job has been submitted, click the View Status button to monitor the jobs
progress. It takes several minutes to complete.

That takes you to the Job Activity page. When the job finishes, you will be disconnected
from Enterprise Manager.


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-16
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?

On the +ASM home page, you see that the DATA diskgroup is associated with the orcl
instance storage.
23) Now that the database has been migrated to ASM, you can remove all the files that
were stored in the traditional file system.
$ cd $ORACLE_BASE/oradata/orcl
$ pwd
/u01/app/oracle/oradata/orcl
$ ls -l
total 1906132
-rw-r----- 1 oracle oinstall 9748480 Sep 24 20:44
control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Sep 24 20:44
control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Sep 24 20:44
control03.ctl
-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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-1: Upgrade the Database Storage to ASM (continued)
Oracle Database 11g: Administration Workshop II A-17
-rw-r----- 1 oracle oinstall 5251072 Sep 24 20:44
users01.dbf
$ rm *


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-18
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
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

SQL> select name,compatibility,database_compatibility from
v$asm_diskgroup;

NAME COMPATIBILITY DATABASE_COMPATIBILITY
-------------------- ------------------ ----------------------
DATA 10.1.0.0.0 10.1.0.0.0
FRA 10.1.0.0.0 10.1.0.0.0


2) Using Enterprise Manager, navigate to the DATA disk group page.
a) Connect to Enterprise Manager Database Control as user SYS using the URL that
was given during the previous lab. For example:
https://edrsr14p1.us.oracle.com:1158/em/
b) Click the +ASM link on the main Database page.
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-2: ASM Fast Mirror Resync (continued)
Oracle Database 11g: Administration Workshop II A-19
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
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
$ sqlplus / as sysasm
SQL> select name,compatibility,database_compatibility from
v$asm_diskgroup;

NAME COMPATIBILITY DATABASE_COMPATIBILITY
------ ------------- ----------------------
DATA 11.1.0.0.0 11.1.0.0.0
FRA 10.1.0.0.0 10.1.0.0.0


5) Execute the asm_setup.sh script from the labs directory to set up the
environment for this practice. The script creates a new tablespace called TBSJMW in
the DATA disk group using a 50 MB file. It then creates a new table called
SYSTEM.JMW residing in this new tablespace. The script then inserts some rows in
the newly created table.
$ 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

set echo on

create tablespace tbsjmw datafile '+DATA' size 50M;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-2: ASM Fast Mirror Resync (continued)
Oracle Database 11g: Administration Workshop II A-20

drop table jmw purge;

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

insert into jmw
values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

commit;

begin
for i in 1..10 loop
insert into jmw select * from jmw;
end loop;
commit;
end;
/

EOF
6) Offline the second disk that is part of the DATA disk group making sure that the Disk
Repair Time attribute is set to 0:
a) Back to the Disk Group: DATA General page, select the second disk
(DATA_0001), and click Offline.
b) On the Confirmation page, change the Disk Repair Time from its default (3.6
hours) to 0 and click Show SQL.
ALTER DISKGROUP DATA OFFLINE DISK DATA_0001 DROP AFTER 0 h
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_001 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

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

SQL> commit;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-2: ASM Fast Mirror Resync (continued)
Oracle Database 11g: Administration Workshop II A-21
9) Add the dropped ASM disk back to the DATA disk group:
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.
ALTER DISKGROUP DATA ADD FAILGROUP DATA_0001 DISK
'/dev/raw/raw2' NAME DATA_0001 SIZE 3000 M REBALANCE POWER 11
e) Click Return.
f) On the Add Disks page, click OK.
10) What do you observe?
a) Back to the Disk Group: DATA General page, refresh your browser until you see
no more rebalance activity.
b) You can see that a rebalance operation is going on for a while.
11) Offline the second disk that is part of the DATA disk group making sure that the Disk
Repair Time attribute is set to its default value. Modify the SYSTEM.JMW table again
(delete another batch of 499 rows). What are your observations?
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

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.
a) Back to the Disk Group: DATA General page, select the offline disk and click
Online.
b) On the Confirmation page, click Yes.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-2: ASM Fast Mirror Resync (continued)
Oracle Database 11g: Administration Workshop II A-22
c) Back to the Disk Group: DATA General page, you should see the disk back to its
level (around 30% full), without the need of any rebalance operation. The disk is
added back immediately.



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-23
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.
$ export ORACLE_SID=+ASM
$ asmcmd
ASMCMD> ls +DATA/*

+DATA/ASMTESTING/:
DATAFILE/

+DATA/ORCL/:
CHANGETRACKING/
DATAFILE/
ONLINELOG/
TEMPFILE/

ASMCMD> ls +DATA/ORCL/DATAFILE
EXAMPLE.260.630800437
SYSAUX.257.628766309
SYSTEM.256.628766309
TBSJMW.269.628767357
UNDOTBS1.258.628766309
USERS.259.628766309


2) Using ASMCMD, create a new directory called jmw in the DATA disk group. Then,
create an alias called +DATA/jmw/mytbs.f that points to the file used to store
your TBSJMW tablespace.
$ 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>

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 1-3: ASMCMD (continued)
Oracle Database 11g: Administration Workshop II A-24
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

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 datafile in the JMW directory.
ASMCMD> ls +DATA/ORCL/DATAFILE/EXAMPLE*
EXAMPLE.260.630800437

ASMCMD> cp +DATA/ORCL/DATAFILE/EXAMPLE.260.630800437
+DATA/jmw/exampl01_copy.dbf (Your numerical extension may vary)

source +DATA/ORCL/DATAFILE/EXAMPLE.260.630800437
target +DATA/jmw/exampl01_copy.dbf
copying file(s)...
ASMCMD>
ASMCMD> ls +DATA/jmw
exampl01_copy.dbf
mytbs.f
ASMCMD> exit
$


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-25
Practices for Lesson 2
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-26

Practice 2-1: Configuring ARCHIVELOG Mode
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
2) Run the size_memory_down.sh script to size the database appropriately for the
following practices.
$ cd ~/labs
$ ./size_memory_down.sh
3) Determine the archive mode your database is running in now.
$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Jul 14
02:17:17 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> 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.
Database dismounted.
ORACLE instance shut down.
5) Mount the database.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 2-1: Configuring ARCHIVELOG Mode (continued)
Oracle Database 11g: Administration Workshop II A-27
SQL> startup mount
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;

Database altered.

SQL>
7) Open the database.
SQL> alter database open;

Database altered.

SQL>


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-28
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;

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;

NAME TYPE VALUE
------------------------------------ ----------- -------------
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer 4G
SQL>
Note that the Flash Recovery Area is in the FRA disk group.
b) Using EM, navigate to Database > Home > +ASM_<hostname> > Disk Groups.
If prompted for login credentials for the ASM instance, provide sys and
oracle as the username and password, respectively. When the disk group list
appears, note the Usable Free column for the FRA disk group.

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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 2-2: Resizing the Flash Recovery Area (continued)
Oracle Database 11g: Administration Workshop II A-29

b) Click Return, and then click Apply.
4) Verify the size of the Flash Recovery Area by using SQL*Plus.
SQL> show parameter recovery_file_dest_size;

NAME TYPE VALUE
------------------------------------ ----------- -------------
db_recovery_file_dest_size big integer 6G
SQL>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-30
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.
$ . 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)

RMAN>
3) See if the control files are automatically backed up.
RMAN> show CONTROLFILE AUTOBACKUP;

RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
Note that automatic backup is not enabled.
4) Configure RMAN to automatically back up the control file when any backups are
done.
RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
5) Take a backup of datafile 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 2-3: Verifying the Backup Destination (continued)
Oracle Database 11g: Administration Workshop II A-31
channel ORA_DISK_1: finished piece 1 at 2007-08-01:21:24:35
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

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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-32
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.
$ . 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>
Note that there is currently no retention policy configured.
3) Change the retention policy to ensure that at least one copy of each file is backed up.
RMAN> configure retention policy to redundancy 1;

old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO NONE;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

RMAN>
4) Check the retention policy setting again.
RMAN> show retention policy;

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

RMAN>

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-33
Practices for Lesson 3


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-34
Practice 3-1: Creating a Recovery Catalog
In this practice, you create a recovery catalog.
1) Use the oraenv script to ensure that you are still using the ORCL instance in your
terminal session.
$ . oraenv
2) Shut down the ORCL instance to free resources that make the database creation go
faster.
$ sqlplus / as sysdba

SQL> shutdown immediate
3) Run the restart_listener.sh script to stop and start the listener.
$ ./restart_listener.sh

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 18-AUG-
2007 18:40:57

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
LSNRCTL> 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/edcdr11p1/listener/alert/log.xml
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edcdr11p1.us.oracle.
com)(PORT=1521)))

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version
11.1.0.6.0 - Production
Start Date 18-AUG-2007 18:40:58
Uptime 0 days 0 hr. 0 min. 0 sec
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-35
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/edcdr11p1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edcdr11p1.us.oracle.
com)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> $
$
4) Use DBCA to start the process of creating a recovery catalog database.
$ dbca
5) On the Welcome page, click Next.
6) On the Operations page, choose the Create a Database option, and then click Next.

7) On the Database Templates page, leave the default of General Purpose or Transaction
Processing, and then click Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-36

8) On the Database Identification page, enter the name of the recovery catalog database.
Use rcat as the Global Database Name. Then click Next.

9) On the Management Options page, leave the defaults as they are, and then click Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-37

10) On the Database Credentials page, select the option to use the same administrative
password for all accounts. Then enter oracle in both of the password fields and
click Next.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-38
11) On the Storage Options page, select ASM as the storage mechanism, and then click
Next.

12) When prompted for the password for the ASM instance, enter oracle and click OK.

13) On the ASM Disk Groups page, select the DATA disk group to be used for the catalog
database storage. Then click Next.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-39

14) On the Database File Locations page, select Use Oracle-Managed Files, and specify
the +DATA disk group as the Database Area. Then click Next.

15) On the Recovery Configuration page, specify the +FRA disk group to be the location
for the Flash Recovery Area. Specify a size of 2048 MB. Then click Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-40

16) On the Database Content page, leave the sample Schema option disabled, and then
click Next.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-41
17) On the Initialization Parameters page, set the memory size to 300 MB, enable
Automatic Memory Management, and then click Next.

18) On the Security Settings page, keep the defaults, and click Next.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-42
19) On the Automatic Maintenance Tasks page, disable the automatic tasks, and click
Next.

20) On the Database Storage page, review the configuration, and then click Next.

21) On the Creation Options page, make sure that Create Database is the only option
selected, and then click Finish
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-43

22) Review the Confirmation page, and then click OK to start the database creation
process.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-44

The Database Creation Assistant now creates the database.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-45

23) When the Database Configuration Assistant finishes running, view the final page, and
then click Exit.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-1: Creating a Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-46

24) Restart the ORCL database.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus / as sysdba
SQL> startup
SQL> exit
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-47
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,
using SQL*Plus.
$ sqlplus sys@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.

Enter password:oracle

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options

SQL>
2) Create a tablespace named RCAT to hold the repository data. Make it 15 MB in size.
SQL> create tablespace rcat datafile size 15M;

Tablespace created.

SQL>
3) Create a user who will own the recovery catalog data. Name the user RCATOWNER.
The default tablespace should be the RCAT tablespace, and the user should have
unlimited quota on that tablespace.
SQL> create user rcatowner identified by oracle
2 default tablespace rcat
3 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-48
Practice 3-3: Creating the Recovery Catalog
In this practice, you create the recovery catalog inside the recovery catalog database you
have prepared.
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
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;

recovery catalog created

RMAN> exit

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-49
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.
$ . 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.

connected to target database: ORCL (DBID=1155655108)
recovery catalog database Password:oracle
connected to recovery catalog database

RMAN>
3) Register the database in the catalog.
RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit
4) Now register the recovery catalog to be used by Enterprise Manager.
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-4: Registering a Database in the Recovery Catalog
(continued)
Oracle Database 11g: Administration Workshop II A-50

d) On the Review page, click Finish.
e) Back on the Recovery Catalog Settings page, select Use Recovery Catalog.
f) Make sure that the recovery catalog you just registered is selected in the drop-
down list, and then click OK.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-51
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 datafile.
$ . 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 datafile for the USERS tablespace. Run this script as the oracle user.
The copy is /tmp/users_copy.dat.
$ cd ~/labs
$ ./copy_users_df.sh
source +data/orcl/datafile/USERS.259.627874231
target /tmp/users_copy.dat
copying file(s)...
file, /tmp/users_copy.dat, copy committed.
$
3) Back in the SQL*Plus session, bring the USERS tablespace back online.
SQL> alter tablespace users online;

Tablespace altered.

SQL>
4) 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

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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-5: Cataloging Additional Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-52
5) List the image copy backups available.
RMAN> list datafilecopy all;

RMAN-00571:
===========================================================
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 datafile.
RMAN> catalog datafilecopy '/tmp/users_copy.dat';

cataloged datafile copy
datafile copy file name=/tmp/users_copy.dat RECID=3
STAMP=628295424

RMAN>
7) Again, list the datafile copies available. Then exit RMAN.
RMAN> list datafilecopy all;

starting full resync of recovery catalog
full resync complete
List of Datafile Copies
=======================

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 datafile copy you made manually is now listed as a backup in the
recovery catalog.


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-53
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.
$ 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
it to at least 2.
RMAN> show retention policy;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name
RCAT are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN> configure retention policy to redundancy 2;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored

RMAN>
3) Back up the database.
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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-6: Backing Up the Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-54
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
===============
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
availability.
4) Exit RMAN.
RMAN> exit
5) Run the rcat_to_archivelog.sh script to change the recovery catalog
database to run in ARCHIVELOG mode.
$ cd ~/labs
$ ./rcat_to_archivelog.sh
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area 263639040 bytes
Fixed Size 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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 3-6: Backing Up the Recovery Catalog (continued)
Oracle Database 11g: Administration Workshop II A-55
Recovery Manager: Release 11.1.0.6.0 - Production on Sun Aug
19 08:33:45 2007

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

connected to target database: RCAT (DBID=403110344)

RMAN>
7) Reattempt backing up the recovery catalog database.
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
input datafile file number=00003
name=+DATA/rcat/datafile/undotbs1.270.629081373input datafile
file number=00005 name=+DATA/rcat/datafile/rcat.294.629356557
input datafile file number=00004
name=+DATA/rcat/datafile/users.271.629081373
channel ORA_DISK_1: starting piece 1 at 2007-07-31:22:49:00
channel ORA_DISK_1: finished piece 1 at 2007-07-31:22:52:37
piece
handle=+FRA/rcat/backupset/2007_07_31/nnndf0_tag20070731t22485
3_0.298.629419741 tag=TAG20070731T224853 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:03:37
Finished backup at 2007-07-31:22:52:37

RMAN>
8) Run the disable_asynch_io.sh script to disable asynchronous input/output
(I/O). This improves performance on the following labs:
$ ~/labs/disable_asynch_io.sh


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-56
Practices for Lesson 4




O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-57
Practice 4-1: Setting the Date and Time Format for RMAN
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.
a) Start RMAN.
$ rman target sys/oracle@rcat
b) List the backups, and note the timestamp format.


RMAN> list backup;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- ------------ ----------
---------
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>

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-58
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.
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;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
3) Verify that it is enabled by backing up the archive logs for the recovery catalog. Then
exit RMAN.
RMAN> backup archivelog all;

Starting backup at 2007-08-20:00:54:40
current log archived
using channel ORA_DISK_1
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=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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 4-2: Enabling Control File Autobackup (continued)
Oracle Database 11g: Administration Workshop II A-59
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

RMAN> exit

Note that the control file and spfile are automatically backed up now.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-60
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
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.

connected to target database: ORCL (DBID=1157684688)
connected to recovery catalog database

RMAN>
3) Show all configuration settings to see whether there are any tape devices defined.
RMAN> show all;

starting full resync of recovery catalog
full resync complete
RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 4-3: Configuring Devices for Backup (continued)
Oracle Database 11g: Administration Workshop II A-61
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)';

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.
RMAN> backup device type sbt tablespace users;

Starting backup at 2007-08-20:02:13:50
released channel: ORA_DISK_1
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00004
name=+DATA/orcl/datafile/users.263.630812119
channel ORA_SBT_TAPE_1: starting piece 1 at 2007-08-
20:02:13:57
channel ORA_SBT_TAPE_1: finished piece 1 at 2007-08-
20:02:13:58
piece handle=0gipqqqu_1_1 tag=TAG20070820T021350 comment=API
Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time:
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.


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-62
Practices for Lesson 5


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-63
Practice 5-1: Creating Fast Incremental Backups
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.

b) Click OK.
c) If you see the following error, then 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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-1: Creating Fast Incremental Backups (continued)
Oracle Database 11g: Administration Workshop II A-64
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
RMAN> backup incremental level 0 database plus archivelog;

starting full resync of recovery catalog
full resync complete
.
.
.
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:03
Finished backup at 19-JUL-07

RMAN>
4) Now that you have a level 0 incremental backup, you can take advantage of block
change tracking to make fast incremental backups. Take a level 1 incremental backup.
RMAN> backup incremental level 1 database plus archivelog;


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.
$ 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
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 19
02:04:41 2007

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-1: Creating Fast Incremental Backups (continued)
Oracle Database 11g: Administration Workshop II A-65
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
FILE# AVG(DATAFILE_BLOCKS) AVG(BLOCKS_READ)
PCT_READ_FOR_BACKUP AVG(BLOCKS)
---------- -------------------- ---------------- -------------
------ -----------
1 89600 193
.215401786 33
2 78968 1565
1.98181542 699
5 12800 1
.0078125 1
4 640 1
.15625 1
3 11520 383
3.32465278 196

SQL> Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-66
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.
$ 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

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

connected to target database: ORCL (DBID=1155655108)
connected to recovery catalog database

RMAN>
3) List backups of datafile 5, noting the entry corresponding to the example datafile.
RMAN> list backup of datafile 5;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
58 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-2: Cross-Checking Backups (continued)
Oracle Database 11g: Administration Workshop II A-67
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
------- ---- -- ---------- ----------- ------------ ---------------
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>
Take note of the only backup that is a full backup of datafile 5. Also note that the
Piece Name is the name of the ASM file where the backup file resides.
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
script to do this. Supply the full Piece Name as an argument to the script.
$ ./rm_asm_file.sh \
> +FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
$
5) List the backups again, and look for the backup that corresponds to the example
datafile.
RMAN> list backup of datafile 5;


List of Backup Sets
===================


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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-2: Cross-Checking Backups (continued)
Oracle Database 11g: Administration Workshop II A-68
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.
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>
Note that the backup in question has expired.
7) Delete all the expired backup sets.
RMAN> delete expired backupset;

using channel ORA_DISK_1

List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
485 484 1 1 EXPIRED DISK
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.63132
4655

Do you really want to delete the above objects (enter YES or
NO)? YES
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-2: Cross-Checking Backups (continued)
Oracle Database 11g: Administration Workshop II A-69
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
---- -- ---- ---------- --------- ----
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
---- -- ---- ---------- --------- ----
5 1 Incr 1195391 24-AUG-07
+DATA/orcl/datafile/example.261.631245463


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-70
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.
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
Archive Log 45 2007-07-16:23:24:47
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_4.269.628125799
Archive Log 46 2007-07-16:23:34:35
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_5.270.628126293
Archive Log 47 2007-07-16:23:39:24
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_6.271.628126685
Archive Log 48 2007-07-16:23:41:16
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_7.272.628126865
Archive Log 49 2007-07-17:00:04:59
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_8.273.628128279
Archive Log 50 2007-07-17:03:44:28
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_9.274.628141457
Archive Log 53 2007-07-17:22:03:18
+FRA/orcl/archivelog/2007_07_17/thread_1_seq_12.262.628207215
Archive Log 54 2007-07-18:00:23:14
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_13.264.628215781
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-71
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

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
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ ---------------
-----
Backup Set 84 2007-08-17:01:35:25
Backup Piece 87 2007-08-17:01:35:25
+DATA/orcl/backupset/2007_08_17/nnsnf0_tag20070817t012756_0.26
4.630812125
Control File Copy 94 2007-08-17:01:35:07
+DATA/orcl/controlfile/backup.262.630811889
Backup Set 86 2007-08-17:02:59:08
Backup Piece 89 2007-08-17:02:59:08
+FRA/orcl/autobackup/2007_08_17/s_630817140.261.630817147
Backup Set 110 2007-08-19:08:23:23
Backup Piece 114 2007-08-19:08:23:23
+FRA/orcl/autobackup/2007_08_19/s_631009384.278.631009401
Datafile Copy 124 2007-08-19:08:27:40
/tmp/users_copy.dat
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-72
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
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
-------------------- ------ ------------------ ---------------
-----
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
Archive Log 45 2007-07-16:23:24:47
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_4.269.628125799
Archive Log 46 2007-07-16:23:34:35
+DATA/orcl/archivelog/2007_07_16/thread_1_seq_5.270.628126293
.
.
.
archived log file
name=+FRA/orcl/archivelog/2007_07_19/thread_1_seq_18.268.62830
4879 RECID=17 STAMP=628304892
deleted backup piece
backup piece
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-73
RMAN> list backup of archivelog until time 'sysdate-1/24';


List of Backup Sets
===================


BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ------------------
-
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
Thrd Seq Low SCN Low Time Next SCN Next
Time
---- ------- ---------- ------------------- ---------- -----
----
1 2 694583 2007-07-14:01:38:11 706664 2007-
07-14:01:41:18
1 3 706664 2007-07-14:01:41:18 718914 2007-
07-14:02:24:49
1 4 718914 2007-07-14:02:24:49 729694 2007-
07-16:23:23:17
1 5 729694 2007-07-16:23:23:17 744259 2007-
07-16:23:31:31
1 6 744259 2007-07-16:23:31:31 756123 2007-
07-16:23:38:05
1 7 756123 2007-07-16:23:38:05 764907 2007-
07-16:23:41:05
1 8 764907 2007-07-16:23:41:05 771262 2007-
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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-74
RMAN>
5) List the image copies of the single datafile in the USERS tablespace.
a) Report on the schema to find out which datafile number belongs to the USERS
tablespace.
RMAN> report schema;

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
3 90 UNDOTBS1 YES
+DATA/orcl/datafile/undotbs1.258.627874231
4 5 USERS NO
+DATA/orcl/datafile/users.259.627874231
5 100 EXAMPLE NO
+DATA/orcl/datafile/example.265.627874511

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- ---------------
-----
1 20 TEMP 32767
+DATA/orcl/tempfile/temp.264.627874505

RMAN>
Note that the file in question is datafile number 4.
b) List any image copies of datafile 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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-75
Note that, in this case, there is only one image copy of this file. You may not have
any at this point.
6) Delete any datafile 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
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:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
8) Make an image file backup of datafile 4.
RMAN> backup as copy datafile 4;

Starting backup at 2007-07-19:06:06:38
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.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 datafile, 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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-76
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 datafile copy
input datafile file number=00004
name=+DATA/orcl/datafile/users.259.627874231
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
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.
10) Reattempt the archival backup, this time providing a FORMAT specifier that causes
the backup to be written to the /tmp directory.
RMAN> backup keep forever as copy datafile 4 format
'/tmp/bu_%d_%s_%p.dbf';

Starting backup at 2007-07-19:06:11:04
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 datafile copy
input datafile file number=00004
name=+DATA/orcl/datafile/users.259.627874231
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-77
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
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
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

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 full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 2007-07-19:06:11:41
channel ORA_DISK_1: finished piece 1 at 2007-07-19:06:11:42
piece handle=/tmp/bu_ORCL_35_1.dbf tag=TAG20070719T061104
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 2007-07-19:06:11:42

RMAN>
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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-78

Starting backup at 2007-07-19:06:14:12
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.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

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
-------------------- ------ ------------------ ---------------
-----
Datafile Copy 1791 2007-07-19:06:06:45
+FRA/orcl/datafile/users.267.628322805

RMAN>
Note that the first backup taken is now obsolete.
14) For an alternate view of the backups, in EM, navigate to Availability > Manage
Current Backups > Image Copies. Then click the File Type heading twice, to sort the
listing in such a manner that the DATAFILE entries are listed first.

15) Fill in the username and password of oracle/oracle, 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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-79

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.

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).

20) Click the File Type heading twice, so that the DATAFILE types are listed at the top.
Note that there are now only two backups of datafile 4. The obsolete one has been
deleted because it was the third of three, and the retention policy is set to 1, meaning
there need only be two backups of any given file.

21) Return to the RMAN session, and take another backup of the datafile in the same
way. This should not be an archival backup.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-80
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
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
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.
24) After the job completes, navigate to the Manage Current Backups page again.
25) Note that there are now only two image copy backups. But the oldest one was
preserved this time because it is an archival backup.

26) Click the Backup Sets tab on this page. What archival backup sets appear there? Why
are they there?
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 5-3: Listing Backup Files (continued)
Oracle Database 11g: Administration Workshop II A-81

Answer: These archival backup sets are here because they were taken as a byproduct
of taking the datafile image copy as an archival backup. When the datafile 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 backup.
27) Exit RMAN.
RMAN> exit


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-82
Practices for Lesson 6



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-83
Practice 6-1: Backing Up a NOARCHIVELOG Database
In this practice, you perform a user-managed backup of a NOARCHIVELOG database.
1) Run the script to put the database into NOARCHIVELOG mode.
$ cd ~/labs
$ ./orcl_to_noarchivelog.sh
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area 523108352 bytes
Fixed Size 1300904 bytes
Variable Size 406849112 bytes
Database Buffers 109051904 bytes
Redo Buffers 5906432 bytes
Database mounted.

Database altered.


Database altered.

$
2) Use oraenv to make sure you are working with the ORCL database, and start
SQL*Plus as SYSDBA. Determine what files have to be copied to perform a user-
managed backup of the entire database.
a) Query the V$DATAFILE view to see what datafiles need to be copied.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus / as sysdba
SQL> select name from v$datafile;

NAME
----------------------------------------------------------
+DATA/orcl/datafile/system.256.627874229
+DATA/orcl/datafile/sysaux.257.627874229
+DATA/orcl/datafile/undotbs1.258.627874231
+DATA/orcl/datafile/users.259.627874231
+DATA/orcl/datafile/example.265.627874511
+DATA/orcl/datafile/tbsjmw.269.630814117

SQL>
b) Query the V$CONTROLFILE view to see what control files need to be copied.
SQL> select name from v$controlfile;

NAME
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-1: Backing Up a NOARCHIVELOG Database
(continued)
Oracle Database 11g: Administration Workshop II A-84
--------------------------------------------------------------
+DATA/orcl/controlfile/current.260.627874373
+FRA/orcl/controlfile/current.256.627874375

SQL>
3) Put the database into backup mode, in preparation for doing the file copies.
SQL> alter database begin backup;
alter database begin backup
*
ERROR at line 1:
ORA-01123: cannot start online backup; media recovery not
enabled


SQL>
Note that you cannot put the database in backup mode. The error says that media
recovery is not enabled. What does that mean?
Answer: The database is running in NOARCHIVELOG mode, so you are not able to
do an online backup.
4) To back up this database manually, you must shut down the database first.
SQL> shutdown immediate
5) Because the files to be copied are ASM files, you must use the ASMCMD utility to
copy them. ASMCMD relies on ORACLE_SID being set to the SID for the ASM
instance. Set it using the oraenv script. Open a Terminal window to do this.
$ . oraenv
ORACLE_SID = [orcl] ? +ASM
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$
6) Use ASMCMD to copy the datafiles and the control files to the /backup directory.
Note: Copying large ASM files can take a few minutes.
$ asmcmd
ASMCMD> cd data/orcl/datafile
ASMCMD> cp EXAMPLE.265.627874511 /backup/EXAMPLE
ASMCMD> cp SYSAUX.257.627874229 /backup/SYSAUX
ASMCMD> cp SYSTEM.256.627874229 /backup/SYSTEM
ASMCMD> cp UNDOTBS1.258.627874231 /backup/UNDOTBS1
ASMCMD> cp USERS.259.627874231 /backup/USERS
ASMCMD> cp TBSJMW.269.630814117 /backup/TBSJMW
ASMCMD> cd +data/orcl/controlfile
ASMCMD> ls -l
Type Redund Striped Time Sys Name
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-1: Backing Up a NOARCHIVELOG Database
(continued)
Oracle Database 11g: Administration Workshop II A-85
CONTROLFILE HIGH FINE JUL 19 10:00:00 Y
Current.260.627874373
ASMCMD> cp Current.260.627874373 /backup/Current.260.627874373
source +data/orcl/controlfile/Current.260.627874373
target /backup/Current.260.627874373
copying file(s)...
file, /backup/Current.260.627874373, copy committed.
ASMCMD>
7) In another terminal window, make sure you are at the ~/labs directory.
$ cd ~/labs
8) Run the script to create a scenario needing recovery. Run this from the ~/labs
directory.
$ ./rm_system.sh
9) Start a SQL*Plus session, and start up the ORCL database.
$ . oraenv
$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.

Total System Global Area 523108352 bytes
Fixed Size 1300904 bytes
Variable Size 343934552 bytes
Database Buffers 171966464 bytes
Redo Buffers 5906432 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '+DATA/orcl/datafile/system.256.627874229'

SQL>
Note that the database does not open because the SYSTEM tablespace cannot be
accessed.
10) Use ASMCMD to copy the SYSTEM datafile backup copy into the datafile directory.
Note that, for the destination file name, you do not supply the file serial numbers.
They are generated automatically by ASM.
ASMCMD> cp /backup/SYSTEM +data(DATAFILE)
.
.
.
copying file(s)...
file, +DATA/asmtesting/datafile/testing.256.628389063, copy
committed.
ASMCMD>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-1: Backing Up a NOARCHIVELOG Database
(continued)
Oracle Database 11g: Administration Workshop II A-86
Note that ASM copied the file to an asmtesting directory. Rename the file in the
database so that the database can be opened.
11) Return to the SQL*Plus session to record the new file name in the control file, and
then verify that the database starts up correctly. Then exit SQL*Plus.
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------
+DATA/orcl/datafile/system.256.627874229
+DATA/orcl/datafile/sysaux.257.627874229
+DATA/orcl/datafile/undotbs1.258.627874231
+DATA/orcl/datafile/users.259.627874231
+DATA/orcl/datafile/example.265.627874511
+DATA/orcl/datafile/tbsjmw.269.630814117

SQL> alter database rename file
2 '+DATA/orcl/datafile/system.256.627874229'
3 to '+DATA/asmtesting/datafile/testing.256.628389063';

Database altered.

SQL> alter database open;

Database altered.

SQL> exit
12) Run the noarchivelog_backup_cleanup.sh script to clean up the backup
files in the /backup directory.
$ ./noarchivelog_backup_cleanup.sh
$


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-87
Practice 6-2: Recovering from the Loss of All Control File Copies
In this practice/task, you discover that all the copies of the control file have been lost.
1) Make sure you are at the ~/labs directory.
$ cd ~/labs
2) Put the database into ARCHIVELOG mode by running the
orcl_to_archivelog.sh script from the labs directory.
$ ./orcl_to_archivelog.sh
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area 523108352 bytes
Fixed Size 1300904 bytes
Variable Size 398460504 bytes
Database Buffers 117440512 bytes
Redo Buffers 5906432 bytes
Database mounted.

Database altered.


Database altered.

$
3) Run the controlfile_autobackup_on.sh script to turn on autobackup for
control files.
$ ./controlfile_autobackup_on.sh

Recovery Manager: Release 11.1.0.6.0 - Production on Fri Jul
20 01:21:50 2007

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

connected to target database: ORCL (DBID=1155655108)
connected to recovery catalog database

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-2: Recovering from the Loss of All Control File Copies
(continued)
Oracle Database 11g: Administration Workshop II A-88

Recovery Manager complete.
$
4) Log in to the ORCL database and make a copy of the control file.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus / as sysdba

SQL> alter database backup controlfile to '/tmp/ctl.bak';

Database altered.

SQL>
5) Delete all copies of the control file that are currently being used by the database.
a) In a SQL*Plus session, list the control files:
SQL> show parameter control_files

NAME TYPE VALUE
------------------------------------ ----------- -------------
control_files string
+DATA/orcl/controlfile/current

.256.628901483, +FRA/orcl/cont

rolfile/current.256.628901483
SQL>
b) Shut down the ORCL instance, so that you are able to delete the control files.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
c) Run the rm_asm_file.sh script to delete each control file.
SQL> host ./rm_asm_file.sh
+DATA/orcl/controlfile/current.256.628901483
ASMCMD> ASMCMD>
SQL> host ./rm_asm_file.sh
+FRA/orcl/controlfile/current.256.628901483
ASMCMD> ASMCMD>
d) Start the database. What state will the database end up in?
SQL> startup
ORACLE instance started.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-2: Recovering from the Loss of All Control File Copies
(continued)
Oracle Database 11g: Administration Workshop II A-89
Total System Global Area 389189632 bytes
Fixed Size 1300128 bytes
Variable Size 356518240 bytes
Database Buffers 25165824 bytes
Redo Buffers 6205440 bytes
ORA-00205: error in identifying control file, check alert log
for more info


SQL> select status from v$instance;

STATUS
------------
STARTED

SQL>
Note that the instance only starts, and the database is not even mounted. This is
because of the missing control files.
6) Create an initialization parameter file (pfile) from the spfile.
SQL> create pfile from spfile;

File created.
7) Find the file and view it.
$ gedit /u01/app/oracle/product/11.1.0/db_1/dbs/initorcl.ora &
8) Edit the initorcl.ora file, pointing the control file setting to the image copy you
created earlier. Make sure to save the file.
*.control_files='/tmp/ctl.bak'#Restore Controlfile
9) Shut down the instance.
SQL> shutdown abort
10) Use the edited parameter file to start the instance, which points at the control file
copy.
SQL> startup pfile=?/dbs/initorcl.ora
ORACLE instance started.

Total System Global Area 627732480 bytes
Fixed Size 1301728 bytes
Variable Size 570426144 bytes
Database Buffers 50331648 bytes
Redo Buffers 5672960 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for
database open
SQL>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-2: Recovering from the Loss of All Control File Copies
(continued)
Oracle Database 11g: Administration Workshop II A-90
Note that you cannot open the database without specifying RESETLOGS because you
are using a backup control file.
11) Open the database by using the RESETLOGS option.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old
backup
ORA-01110: data file 1:
'+DATA/orcl/datafile/system.258.630811685'

Note that you need to recover the database.
12) Recover the database by using the backup control file option.
SQL> recover database using backup controlfile;
ORA-00279: change 1377484 generated at 08/20/2007 08:07:30
needed for thread 1
ORA-00289: suggestion : +FRA
ORA-00280: change 1377484 for thread 1 is in sequence #46

13) You need to first enter CANCEL to perform the necessary queries for determining the
names of the log files that are to be applied.
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
14) Determine which redo logs are associated with the sequence number given, by first
querying the archive redo log file information. Use the sequence number reported in
the output of step 12.
Note: Your sequence number is probably different from the example shown.
SQL> select * from v$archived_log where sequence# = 46;

no rows selected

SQL>
If the sequence number is not found in the V$ARCHIVED_LOG view, then this
sequence is not archived.
15) Check the online redo log files for this sequence number.
SQL> select * from v$log where sequence# = 46;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC
STATUS
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-2: Recovering from the Loss of All Control File Copies
(continued)
Oracle Database 11g: Administration Workshop II A-91
---------- ---------- ---------- ---------- ---------- --- ---
-------------
FIRST_CHANGE# FIRST_TIME
------------- -------------------
2 1 46 52428800 2 NO
CURRENT
1376170 2007-08-20:08:07:30


16) Note the group# of the associated online redo file. Query the V$LOG view to
determine the file name for this sequence number.
Note: Your group number may be different from the one shown here.
SQL> select * from v$logfile where group#=2;

GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------
------------------
IS_
---
2 ONLINE
+DATA/orcl/onlinelog/group_2.268.630812389
NO

2 ONLINE
+FRA/orcl/onlinelog/group_2.259.630812413
YES

17) Note the file name for this group. Reattempt the recovery command, and supply one
of these file names when prompted.
Note: The file name you provide is most likely different from the example shown
here.
SQL> recover database using backup controlfile;
ORA-00279: change 1377484 generated at 08/20/2007 08:07:30
needed for thread 1
ORA-00289: suggestion : +FRA
ORA-00280: change 1377484 for thread 1 is in sequence #46


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
+DATA/orcl/onlinelog/group_2.268.630812389
Log applied.
Media recovery complete.
SQL>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-2: Recovering from the Loss of All Control File Copies
(continued)
Oracle Database 11g: Administration Workshop II A-92
18) Reattempt to open the database by using the RESETLOGS option.
SQL> alter database open resetlogs;

Database altered.

SQL>
19) Your database has been opened successfully, but by using a pfile. Switch back to
using an spfile.
a) Create the spfile.
SQL> create spfile from pfile;

File created.

SQL>
b) Shut down the database.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
c) Start the database, and then exit SQL*Plus.
SQL> startup
ORACLE instance started.

Total System Global Area 627732480 bytes
Fixed Size 1301728 bytes
Variable Size 570426144 bytes
Database Buffers 50331648 bytes
Redo Buffers 5672960 bytes
Database mounted.
Database opened.
SQL> exit



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-93
Practice 6-3: Recovering from Loss of a Redo Log Group
In this practice, you recover from the loss of all redo log members of a redo log group.
The redo log group that is lost is the current one.
1) Make sure you are at the ~/labs directory.
$ cd ~/labs
2) Delete the redo log files of the current redo log group.
a) Run the query_logs.sh script to list the names of the online redo log groups.
$ ./query_logs.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Sep 26
03:44:00 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

SQL> SQL> SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORACLE instance started.

Total System Global Area 627732480 bytes
Fixed Size 1301728 bytes
Variable Size 562037536 bytes
Database Buffers 58720256 bytes
Redo Buffers 5672960 bytes
Database mounted.
SQL> 2 3 4
MEMBER GROUP#
STATUS ARC
--------------------------------------------- ---------- -----
--- ---
+FRA/orcl/onlinelog/group_1.259.629772131 1
INACTIVE YES
+DATA/orcl/onlinelog/group_1.267.629772097 1
INACTIVE YES
+FRA/orcl/onlinelog/group_2.257.629772191 2
INACTIVE YES
+DATA/orcl/onlinelog/group_2.266.629772147 2
INACTIVE YES
+FRA/orcl/onlinelog/group_4.258.629772261 4
CURRENT NO
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-3: Recovering from Loss of a Redo Log Group
(continued)
Oracle Database 11g: Administration Workshop II A-94
+DATA/orcl/onlinelog/group_4.265.629772243 4
CURRENT NO

Note the names of the files for the CURRENT redo log group.
b) Shut down the database, so that the files can be deleted, and then exit SQL*Plus.
$ sqplus / as sysdba
SQL> shutdown immediate
SQL> exit
c) Use the rm_asm_file.sh script to delete the two redo log files in the current
group.
$ ./rm_asm_file.sh +FRA/orcl/onlinelog/group_4.258.629772261
$ ./rm_asm_file.sh +DATA/orcl/onlinelog/group_4.265.629772243
3) Start the database.
SQL> startup
ORACLE instance started.

Total System Global Area 422670336 bytes
Fixed Size 1300352 bytes
Variable Size 348129408 bytes
Database Buffers 67108864 bytes
Redo Buffers 6131712 bytes
Database mounted.
ORA-00313: open failed for members of log group 4 of thread 1
ORA-00312: online log 4 thread 1:
'+DATA/orcl/onlinelog/group_4.265.629772243'
ORA-00312: online log 4 thread 1:
'+FRA/orcl/onlinelog/group_4.258.629772261'
Note that the database does not open. See the errors regarding the missing online redo
log files. Note also that the database is not in the MOUNT state. In this case, the group
number of concern is 4.
4) You know that, with the current log group missing, you cannot recover completely.
Recover to the most recent time possible.
Note: The group number for your database may indeed be different from that shown
here.
a) Clear the log file.
SQL> alter database clear logfile group 4;
alter database clear logfile group 4
*
ERROR at line 1:
ORA-00350: log 4 of instance orcl (thread 1) needs to be
archived
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 6-3: Recovering from Loss of a Redo Log Group
(continued)
Oracle Database 11g: Administration Workshop II A-95
ORA-00312: online log 4 thread 1:
'+DATA/orcl/onlinelog/group_4.265.629772243'
ORA-00312: online log 4 thread 1:
'+FRA/orcl/onlinelog/group_4.258.629772261'

SQL>
Note that the current redo log group cannot be cleared because it has not been
archived. A log file in the current state is never archived. It must become active or
inactive first.
b) Attempt to clear the logfile group again, this time indicating that you know that it
is unarchived.
SQL> alter database clear unarchived logfile group 4;

Database altered.

SQL>
c) Open the database. Then exit SQL*Plus.
SQL> alter database open;

Database altered.

SQL> exit


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-96
Practices for Lesson 7


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-97
Practice 7-1: Recovering Image Copies
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. In preparation for needing
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.
1) Make sure you are at the ~/labs directory.
$ cd ~/labs
2) Run the create_appraisal_ts.sh script to create a new tablespace called
APPRAISAL.
$ ./create_appraisal_ts.sh
Tablespace created.
Table created.
$
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
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
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-98
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
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:04:18
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003
name=+DATA/orcl/datafile/undotbs1.258.635127417output file
name=+FRA/orcl/datafile/undotbs1.292.635210025 tag=APP_INCR
RECID=20 STAMP=635210104
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:01:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005
name=+DATA/orcl/datafile/example.260.635127419
output file name=+FRA/orcl/datafile/example.293.635210123
tag=APP_INCR RECID=21 STAMP=635210156
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:45
channel ORA_DISK_1: starting datafile copy
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
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
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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-99
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

107 rows created.
.
.
.
5) List the copy of the APPRAISAL tablespace to see its SCN.
RMAN> list copy of tablespace appraisal;

List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- -------- ------------------
630 7 A 2007-10-05:23:16:51 822339 2007-10-
05:23:16:45
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.
$
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;

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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-100
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
file number=00005
name=+DATA/orcl/datafile/example.260.635127419
input datafile file number=00006
name=+DATA/orcl/datafile/tbsjmw.263.635148067
input datafile file number=00007
name=+DATA/orcl/datafile/appraisal.256.635209311
input datafile file number=00004
name=+DATA/orcl/datafile/users.262.635127891
channel ORA_DISK_1: starting piece 1 at 2007-10-05:23:37:11
channel ORA_DISK_1: finished piece 1 at 2007-10-05:23:37:36
piece
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t23370
2_0.298.635211431 tag=TAG20071005T233702 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:25
Finished backup at 2007-10-05:23:37:36

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
===================

BS Key Type LV Size Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- ------------ ----------
---------
676 Incr 1 12.72M DISK 00:00:24 2007-10-
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-101
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
7 1 Incr 824887 2007-10-05:23:37:11
+DATA/orcl/datafile/appraisal.256.635209311

RMAN>
9) Use the incremental backup to recover the APPRAISAL tablespace image copy.
RMAN> recover copy of tablespace appraisal with tag
'app_incr';

Starting recover at 2007-10-05:23:52:00
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=170 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set
restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00007
name=+FRA/orcl/datafile/appraisal.295 .635210207
channel ORA_DISK_1: reading from backup piece
+FRA/orcl/backupset/2007_10_05/nnn
dn1_tag20071005t233702_0.298.635211431
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
=======================

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


RMAN>
Note that it is now equal to the SCN of the last incremental backup.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-102
11) Recover all the datafile 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
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=112 device type=DISK
no copy of datafile 7 found to recover
channel ORA_DISK_1: starting incremental datafile backup set
restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001
name=+FRA/orcl/datafile/system.290.635209395
recovering datafile copy file number=00002
name=+FRA/orcl/datafile/sysaux.291.635209755
recovering datafile copy file number=00003
name=+FRA/orcl/datafile/undotbs1.292.635210025
recovering datafile copy file number=00004
name=+FRA/orcl/datafile/users.296.635210221
recovering datafile copy file number=00005
name=+FRA/orcl/datafile/example.293.635210123
recovering datafile copy file number=00006
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.
RMAN> list copy;

List of Datafile Copies
=======================

Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- ----------------
---
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-1: Recovering Image Copies (continued)
Oracle Database 11g: Administration Workshop II A-103

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

801 3 A 2007-10-06:00:00:40 824887 2007-10-
05:23:37:11
Name: +FRA/orcl/datafile/undotbs1.292.635210025
Tag: APP_INCR

799 4 A 2007-10-06:00:00:34 824887 2007-10-
05:23:37:11
Name: +FRA/orcl/datafile/users.296.635210221
Tag: APP_INCR

506 4 A 2007-10-05:05:18:05 799678 2007-10-
05:05:18:03
Name: +FRA/orcl/datafile/users.279.635145483
Tag: TAG20071005T051803

414 4 A 2007-10-05:04:53:32 797391 2007-10-
05:04:53:31
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
Tag: APP_INCR
.
.
.
RMAN>

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-104
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 datafile.
Note: The datafile numbers in your database may differ from what is shown here.
1) Use the RMAN session from the previous practice and take the APPRAISAL datafile
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 restore the datafile from the flash recovery area.
a) Determine the name of the datafile that is currently associated with the
APPRAISAL tablespace.
RMAN> report schema;

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
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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-105
Note that there is only one datafile for the tablespace. In this case, it is datafile
number 7. You can use that datafile number, instead of the tablespace name, in the
upcoming set of commands.
b) Confirm that you have an image copy for datafile 7 that you can switch to.
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

RMAN>
c) Switch to that copy of the image file.
RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy
"+FRA/orcl/datafile/appraisal.295.634277277"
starting full resync of recovery catalog
full resync complete

RMAN>
d) Recover datafile 7.
RMAN> recover datafile 7;

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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-106
RMAN>
4) Report the schema to note the file name for the APPRAISAL tablespace.
RMAN> report schema;

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
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
+FRA/orcl/datafile/appraisal.295.634277277
.
.
.
Note that you are now using the Flash Recovery Area datafile as the open datafile for
the online tablespace.
5) Determine what happened to the original datafile.
List the image copies for datafile 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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-107
Note that it is still there and is listed now as an image copy. But, the reason for
switching was because this datafile was considered to be on a damaged disk, or the
datafile itself was corrupted.
6) In a separate terminal window, make sure you are at the ~/labs directory.
$ cd ~/labs
7) Remember that the reason for switching was because this datafile was considered to
be on a damaged disk, or the datafile 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 datafiles. By now, the hardware or corruption problem has been remedied, so
switch the datafile back to the original location.
a) Back up the datafile, specifying the DATA ASM disk group, using the DATAFILE
template.
RMAN> backup as copy to destination '+DATA(datafile)' datafile
7;

Starting backup at 2007-09-26:05:11:02
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007
name=+FRA/orcl/datafile/appraisal.295.634277277
output file name=+DATA/orcl/datafile/appraisal.256.634281073
tag=TAG20070926T051102 RECID=33 STAMP=634281075
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:03
Finished backup at 2007-09-26:05:11:15

Starting Control File and SPFILE Autobackup at 2007-09-
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 datafile offline.
RMAN> sql "alter database datafile 7 offline";

sql statement: alter database datafile 7 offline

RMAN>
c) Switch the datafile to the newly made copy.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-108
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

RMAN>
d) Report the schema to confirm that the datafile location has changed.
RMAN> report schema;

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
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.634281073
.
.
.
9) Recover the datafile.
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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-109
10) Bring the datafile online.
RMAN> sql "alter database datafile 7 online";

sql statement: alter database datafile 7 online

RMAN>
11) Cross-check the image copy backups and remove the obsolete datafile 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
name=+FRA/orcl/datafile/system.290.634276557 RECID=30
STAMP=634278061
validation succeeded for datafile copy
.
.
.
datafile copy file
name=+FRA/orcl/datafile/appraisal.295.634277277 RECID=34
STAMP=634281188
validation failed for datafile copy
datafile copy file
name=+DATA/orcl/datafile/appraisal.256.634276429 RECID=32
STAMP=634279041
validation succeeded for archived log
archived log file
name=/u01/app/oracle/product/11.1.0/db_1/dbs/arch1_36_63124294
3.dbf RECID=7 STAMP=634245437
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 7-2: Performing Fast Recovery (continued)
Oracle Database 11g: Administration Workshop II A-110
------- ---- - ------------------- ---------- ----------------
---
982 7 X 2007-09-26:04:37:21 1288660 2007-09-
26:04:25:52
Name: +DATA/orcl/datafile/appraisal.256.634276429

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
------- ---- - ------------------- ---------- ----------------
---
982 7 X 2007-09-26:04:37:21 1288660 2007-09-
26:04:25:52
Name: +DATA/orcl/datafile/appraisal.256.634276429


Do you really want to delete the above objects (enter YES or
NO)? yes
deleted datafile copy
datafile copy file
name=+DATA/orcl/datafile/appraisal.256.634276429 RECID=32
STAMP=634279041
Deleted 1 EXPIRED objects

RMAN> exit
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-111
Practices for Lesson 8


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-112
Practice 8-1: Cloning a Database
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
2) Make sure RMAN is configured to automatically back up the control file.
RMAN> configure controlfile autobackup on;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
3) Configure RMAN to write the control file auto backup to the desired location, so all
of the backup files are there together.
RMAN> 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 datafiles.
RMAN> backup database format '/backup/bu_%d_%s_%p' plus
archivelog format '/backup/bu_%d_%s_%p';
5) Return the autobackup file location to the default setting.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-113
RMAN> configure controlfile autobackup format for device type
disk clear;

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) From the ~oracle/labs directory, run the prep_for_cloning.sh script to
prepare the environment to perform the clone operation.
$ ./prep_for_cloning.sh
Setting up ORCL environment.
ORACLE_SID = [orcl] ? The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
Setting to NOARHIVELOG mode
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area 627732480 bytes
Fixed Size 1301728 bytes
Variable Size 570426144 bytes
Database Buffers 50331648 bytes
Redo Buffers 5672960 bytes
Database mounted.

Database altered.


Database altered.

Creating pfile

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Sep 26
05:49:15 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, Oracle Label Security, OLAP, Data
Mining
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-114
and Real Application Testing options

SQL>
File created.

SQL> 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
Removing quotes
restarting with pfile

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Sep 26
05:49:15 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORA-00837: Specified value of MEMORY_TARGET greater than
MEMORY_MAX_TARGET
ORA-01078: failure in processing system parameters
SQL> 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
Shutting down RCAT instance

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Sep 26
05:49:28 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-115
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 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
$
7) In EM, navigate to Data Movement > Clone Database.

8) Select the option to use an existing backup for the source. Then click Continue.

9) On the Source Options page, enter the backup directory in the RMAN Backup
Location field. Leave the Staging Area Location as the default setting. Then click
Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-116

10) Specify ODUP for the Global Database Name and the Instance Name. Leave the
default values in all the other fields. Then click Next.

11) On the Destination Options page, leave the default values in all the fields. Then click
Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-117

12) You see a warning page regarding a sales history datafile and the control file
directory. Click Yes to continue.

13) On the Database Configuration page, leave the default values in all the fields, and
click Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-118

14) On the Schedule page, leave the default values in all the fields, and click Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-119

15) Review the Review page, and then click Submit Job.

16) Click View Status, and view the status of the job until it shows that it is Succeeded.
The entire job takes five to eight minutes to complete.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-120

17) Configure a terminal window environment to work with a terminal session with the
ORACLE_SID set to ODUP.
$ . oraenv
ORACLE_SID = [orcl] ? odup
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$
18) Log in to the ODUP database, using SQL*Plus. Query a table to make sure you have a
copy of the source database.
$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Aug 20
12:50:13 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

SQL> select count(*) from hr.job_history;

COUNT(*)
----------
10

19) 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-121
20) Run the cleanup_from_cloning.sh script to return the environment to its
original state before the cloning operation.
$ ./cleanup_from_cloning.sh
21) Query the truncated table to prove it is still populated in the ORCL instance.
$ . oraenv
ORACLE_SID = [odup] ? orcl
$ sqlplus / as sysdba
SQL> select count(*) from hr.job_history;

COUNT(*)
----------
10

22) Run the dbca to delete the ODUP database, since it is no longer needed.
a) Start the dbca.
$ dbca
b) Click Next on the Welcome page.
c) Choose Delete a Database on the Operations page.
d) Select odup from the list of databases to delete. Then click Finish.

e) Confirm the delete operation by clicking Yes.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 8-1: Cloning a Database (continued)
Oracle Database 11g: Administration Workshop II A-122
f) After the delete operation is finished, click No when asked if you want to perform
another operation.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-123
Practices for Lesson 9


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-124
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

Export: Release 11.1.0.6.0 - Production on Monday, 20 August,
2007 13:14:53

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
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/********
dumpfile=hrexp.dmp schemas=hr
. . exported "HR"."REGIONS" 5.476
KB 4 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully
loaded/unloaded
.
.
.
**************************************************************
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
$ 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
2 /
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-125
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
4 EXTENT MANAGEMENT LOCAL
5 SEGMENT SPACE MANAGEMENT AUTO
6 /

Tablespace created.

SQL> REM ***** User/schema for the HR import *****
SQL> DROP USER hrtest cascade
2 /
DROP USER hrtest cascade
*
ERROR at line 1:
ORA-01918: user 'HRTEST' does not exist


SQL> CREATE USER hrtest
2 PROFILE DEFAULT
3 IDENTIFIED BY hrtest
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>
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-126
$ ./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
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully
loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********
dumpfile=hrexp.dmp parfile=impdphr.par
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"HRTEST" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "HRTEST"."DEPARTMENTS" 7.007
KB 27 rows
. . imported "HRTEST"."EMPLOYEES" 16.80
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
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ORA-39083: Object type REF_CONSTRAINT failed to create with
error:
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-127
ORA-00942: table or view does not exist
Failing sql is:
ALTER TABLE "HRTEST"."DEPARTMENTS" ADD CONSTRAINT
"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

$

4) Create a backup of your database using RMAN.
RMAN> backup database;

Starting backup at 2007-08-20:13:40:42
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=118 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=00001
name=+DATA/orcl/datafile/system.258.630811685
channel ORA_DISK_1: starting piece 1 at 2007-08-20:13:40:55
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
channel ORA_DISK_1: specifying datafile(s) in backup set
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-128
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
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

Starting Control File and SPFILE Autobackup at 2007-08-
20:13:46:17
piece
handle=+FRA/orcl/autobackup/2007_08_20/s_631115181.311.6311151
89 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-08-
20:13:46:36

RMAN>

5) Record the current SCN for the database: ____________
SQL> select current_scn from V$database;

CURRENT_SCN
-----------
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-129
3 where department_id = 60
4 /

EMPLOYEE_ID LAST_NAME SALARY
----------- ------------------------- ----------
103 Hunold 9000
104 Ernst 6000
105 Austin 4800
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 /

5 rows updated.
SQL> select employee_id, last_name, salary
2 from hrtest.employees
3 where department_id = 60
4 /

EMPLOYEE_ID LAST_NAME SALARY
----------- ------------------------- ----------
103 Hunold 11250
104 Ernst 7500
105 Austin 6000
106 Pataballa 6000
107 Lorentz 5250

9) You now want to perform TSPITR for the HRTEST tablespace to return it to the state
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 /

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-130
no rows selected
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.
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.

12) On the Point-in-time page, select the Recover to a prior point-in-time option button.
Choose SCN and enter the SCN that you recorded earlier in this practice. Then click
Next.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-131

13) Specify the auxiliary instance location of
/u01/app/oracle/oradata/tspitr. Click Add to add the HRTEST
tablespace to the recovery job. Then click Next.

14) Create the auxiliary location directory now.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-132
$ mkdir -p /u01/app/oracle/oradata/tspitr
15) On the Rename page, specify that the files are to be restored to the default location.
Then click Next.

16) Review the Review page, and then click Submit. Watch for the job to complete. It
runs for six to eight minutes.
17) When the job completes, note the status. You should see a page titled Operation
Succeeded. When you do, review it, and then click OK.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-133
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, then 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.
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
----------- ------------------------- ----------
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.
SQL> @add_constraint
SQL> connect / as sysdba
Connected.
SQL> GRANT references (location_id) on hr.locations to hrtest
2 /

Grant succeeded.

SQL> connect hrtest/hrtest
Connected.
SQL> ALTER TABLE hrtest.departments
2 ADD CONSTRAINT dept_loc_id_fk FOREIGN KEY (location_id)
3 REFERENCES hr.locations (location_id)
4 /

Table altered.
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 9-1: Performing Tablespace Point-in-Time Recovery
(continued)
Oracle Database 11g: Administration Workshop II A-134
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
---------------------------------------------------------
OBJ2_OWNER OBJ2_NAME OBJ2_TYPE TS2_NAME
------------------------------ --------------------------
CONSTRAINT_NAME REASON
------------------------------
HR LOCATIONS TABLE EXAMPLE
HRTEST DEPARTMENTS TABLE HRTEST
DEPT_LOC_ID_FK
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

HR LOCATIONS TABLE EXAMPLE
HRTEST DEPARTMENTS TABLE HRTEST
DEPT_NAME_NN
constraint between tables not contained in recovery set

22) If you wanted to complete the tablespace point-in-time recovery for the HRTEST
tablespace now, what would you need to do?

Note: You will not perform another tablespace point-in-recovery in this practice.
Answer: You would need to disable the DEPT_LOC_ID_FK constraint that was
added to your HRTEST.DEPARTMENTS table or you would need to add the
tablespace that contains the HR.LOCATIONS table to your recovery set.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-135
Practices for Lesson 10


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-136
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;
2) Open a second terminal window. Change to the labs directory. Invoke SQL*Plus
and connect as SYSDBA. You use this second session to monitor a database backup.
$ sqlplus / as sysdba
3) Return to your first terminal window. In your RMAN session, begin a database
backup to the tape device.
RMAN> backup device type sbt database;

Starting backup at 2007-08-20:14:46:36
released channel: ORA_DISK_1
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=120 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
channel ORA_SBT_TAPE_1: starting full datafile backup set
...
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

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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 10-1: Monitoring RMAN Jobs (continued)
Oracle Database 11g: Administration Workshop II A-137
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
120 27-SEP-07 54
SQL>
5) Run the cleanup_archivelogs.sh script to back up and remove archivelog
files. This takes several minutes to run.
$ cd ~/labs
$ ./cleanup_archivelogs.sh
6) Run the cleanup_tape_dir.sh script to remove files from the /tape
directory.
$ ./cleanup_tape_dir.sh
7) Shut down the recovery catalog instance. You are finished with it.
$ sqlplus sys/oracle@rcat as sysdba

SQL> shutdown immediate
8) Run the size_memory_up.sh script to size the database appropriately for the
following practices.
$ cd ~/labs
$ ./size_memory_up.sh


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-138
Practices for Lesson 11
In these practices you use the recycle bin to flash back dropped objects. You also explore
the workings of Flashback Transaction.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-139
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 5 through 8.
1) This workshop scenario simulates loss of data. To introduce the problem, change
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';

OWNER ORIGINAL_NAME DROPTIME
------ ------------------ -------------------
HR DEPT_LOCATION_IX 2007-07-24:10:51:11
HR DEPT_ID_PK 2007-07-24:10:51:11
HR DEPARTMENTS 2007-07-24:10:51:11
...
3) Use Flashback Table to restore the dropped objects. You can use Flashback Table
through Enterprise Manager or through SQL*Plus. To flash back the table using
Enterprise Manager, skip to step 5.
SQL> FLASHBACK TABLE hr.departments TO BEFORE DROP;

Flashback complete.
SQL>
4) Perform a select operation against the HR.DEPARTMENTS table to confirm the
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-1: Using the Recycle Bin (continued)
Oracle Database 11g: Administration Workshop II A-140


6) The Perform Object Level Recovery: Rename page allows you to rename the restored
object. Accept the default or original name and click Next.
7) On the Review page, inspect the Impact Analysis. Note that the table and dependent
objects are to be restored and note the names they will be restored to. Click Submit.

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
------------- -------------------- ---------- -----------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-1: Using the Recycle Bin (continued)
Oracle Database 11g: Administration Workshop II A-141
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
...

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-142
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
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.

$ cd $HOME/labs
$ echo $ORACLE_SID
orcl
$ ./flatxn_archivelog.sh
*******************************************
* Unlock HR account
* Enable ARCHIVELOG mode for database

The script may appear to hang at the SQL prompt
when the database is shutting down and being
opened. Wait a few minutes and it should progress.
*******************************************

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12
12:35:19 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> SQL>
User altered.

SQL>
System altered.

SQL> SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-143
SQL> ORACLE instance started.

Total System Global Area 422670336 bytes
Fixed Size 1300232 bytes
Variable Size 260049144 bytes
Database Buffers 155189248 bytes
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
Oldest online log sequence 12
Next log sequence to archive 14
Current log sequence 14
SQL> Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
$
2) Using SQL*Plus, connect to the database as the SYS user and run the
flatxn_setup1.sql script. This setup script sets up the database and the HR user
for backing out transactions with flashback. It also performs four groups of
transactions. Take a few moments to inspect the script before executing it. Note the
ALTER DATABASE and GRANT commands.
$ sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12
12:42:43 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> @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 for this OBE ==*/
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-144
SQL>
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY)
COLUMNS;

Database altered.

SQL> GRANT EXECUTE ON dbms_flashback TO hr;

Grant succeeded.

SQL> GRANT select any transaction TO hr;

Grant succeeded.

SQL> pause Press [Enter] to continue...
3) Press [Enter] to continue to the next step in the script. The script connects to the
database as HR user and creates the first test transaction, which consists of inserting
five rows.
Press [Enter] to continue...
SQL>
SQL> /*== Create test data for flashback transaction ==*/
SQL> connect hr/hr
Connected.
SQL>
SQL> /*== Test transaction 1 ==*/
SQL> INSERT INTO hr.regions VALUES (10,'Pole');

1 row created.

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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-145

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 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
region_id = 10;

1 row updated.

SQL> UPDATE hr.regions SET region_name='Many Moons' WHERE
region_id = 20;

1 row updated.

SQL> COMMIT;

Commit complete.

SQL> pause Press [Enter] to continue...
5) Press [Enter] to continue to the next step in the script. The script continues to create
the third transaction, which consists of updating three rows, one of which was also
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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-146

1 row updated.

SQL> UPDATE hr.regions SET region_name='Big star' WHERE
region_id = 50;

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.
Press [Enter] to continue...

SQL>
SQL> /*== Test transaction 4 ==*/
SQL> /*== Region 30 has a WAW dependency on transaction 1 ==*/
SQL> UPDATE hr.regions SET region_name='Still called Venus'
WHERE region_id = 30;

1 row updated.

SQL> COMMIT;

Commit complete.

SQL>
SQL> pause Press [Enter] to continue...
7) Press [Enter] to continue to the next step in the script. Lastly, 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...
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-147
8) Press [Enter] to exit the script.
Press [Enter] to continue...

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
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.
b) You suspect that the HR.REGIONS table contains changes from the bad
transaction, and want to view the complete table data. Click the Schema tabbed
page, and then click Tables located under Database Objects.
c) To view all tables that belong to the HR schema user, enter HR in the Schema field
and click the Go button.
d) On the Tables page, select the REGIONS table, and then select View Data from
the Actions drop-down list. Click Go to view the data in the HR.REGIONS table.
e) While viewing the content of the table, you realize that it should not contain the
Many moons and Still called Venus rows. Click OK.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-148

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.
k) On the Show Dependencies: Details page, review the compensating transactions.
Note that one of the compensating transactions has been executed. It is marked
[exec=yes]. The other one is not executed; it is marked [exec=no]. Click
OK.
l) On the Flashback Transaction: Show Dependencies page, click the Change
Recovery Option button.
m) On the Show Dependencies: Change Recovery Option page, select Cascade,
which will also back out the erroneous dependent transaction changes, and click
OK.
n) On the Flashback Transaction: Show Dependencies page, click Next.
o) Click the Show Undo SQL Script button.
p) On the Review: Show Undo SQL page, review all compensating UPDATE
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, then select
View Data from the Actions drop-down list and click Go.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-149
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.
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.


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> @flatxn_cleanup.sql
SQL> set serveroutput on
SQL> set term on
SQL> set lines 200
SQL> set pause on
SQL>
SQL> connect / as sysdba
Connected.
SQL>
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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 11-2: Flashback Transaction Backout (continued)
Oracle Database 11g: Administration Workshop II A-150

1 row deleted.

SQL> COMMIT;

Commit complete.

SQL>
SQL> ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY)
COLUMNS;

Database altered.

SQL> ALTER DATABASE DROP SUPPLEMENTAL LOG DATA;

Database altered.

SQL> REVOKE EXECUTE ON dbms_flashback FROM hr;

Revoke succeeded.

SQL> REVOKE select any transaction FROM hr;

Revoke succeeded.

SQL>
SQL> exit

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-151

Practices for Lesson 12
The following practices cover the usage of Flashback Database and Flashback Data
Archive.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-152
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
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.

c. Enter the host credentials using oracle/oracle and click OK.
d. Click Yes on the Restart Database: Confirmation page.
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-1: Flashback Database (continued)
Oracle Database 11g: Administration Workshop II A-153
SQL> SELECT current_scn FROM v$database;

CURRENT_SCN
-----------
712863

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;

COUNT(*)
----------
10

4. Run the flb_db_txn.sql script to perform the same HR reorganization updates
as was run in the practice for the lesson titled Database Recovery.
a. Enter the following at the SQL prompt:
SQL> @flb_db_txn.sql
Following is the output of that command:
SQL> @flb_db_txn.sql
SQL>
SQL> update employees set department_id = 90 where job_id =
'IT_PROG';

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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-1: Flashback Database (continued)
Oracle Database 11g: Administration Workshop II A-154
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.
SQL> SELECT current_scn FROM v$database;

CURRENT_SCN
-----------
716681

SQL> SELECT SUM(salary) FROM hr.employees;

SUM(SALARY)
-----------
679050

SQL> SELECT COUNT(*) FROM hr.job_history;

COUNT(*)
----------
15

SQL>
6. Using RMAN, flash back the database to the first SCN value noted in step 2.
a. Shut down and then mount the database by entering the following:
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
b. Go to the RMAN session in another XTerm window, and exit the current RMAN
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


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-1: Flashback Database (continued)
Oracle Database 11g: Administration Workshop II A-155
starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished flashback at 25-JUL-07

RMAN>
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 row count for the
JOB_HISTORY table.
SQL> SELECT SUM(salary) FROM hr.employees;

SUM(SALARY)
-----------
691400
8. Open the database for read/write use. You have to use the RESETLOGS keyword.
a. Shut down the database by entering the following at the SQL prompt:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-1: Flashback Database (continued)
Oracle Database 11g: Administration Workshop II A-156
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;
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
FLASHBACK_SIZE
-------------------- ------------------- ---------------- ----
----------
712309 2007-07-25 11:07:20 1440
8192000

11. View the overhead associated with flashback logging and related operations by
querying V$FLASHBACK_DATABASE_STAT. What is the average number of bytes
of flashback data written per minute during this time interval?
SQL> select * from V$FLASHBACK_DATABASE_STAT;
truncating (as requested) before column
ESTIMATED_FLASHBACK_SIZE

BEGIN_TIME END_TIME FLASHBACK_DATA
DB_DATA REDO_DATA
------------------- ------------------- -------------- -------
--- ----------
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
--------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-1: Flashback Database (continued)
Oracle Database 11g: Administration Workshop II A-157
16384000
Note: Your results will probably vary slightly from those shown here.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-158
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
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.


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> @flada_setup.sql
Connected.
SQL> set serveroutput on
SQL> -- set verify on
SQL> set term on
SQL> set lines 200
SQL> set pages 44
SQL> set pause on
SQL>
SQL> /*== Create a tablespace for your flashback data archive
==*/
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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-159
SQL> pause Press [Enter] to continue...
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
*
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.

SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL> /*== Set up the HR database account for this lesson ==*/
SQL> /*== Note: The HR user has the UNLIMITED TABLESPACE
system privilege. ==*/SQL>
SQL> ALTER USER hr IDENTIFIED BY "HR" ACCOUNT UNLOCK
2 /

User altered.

SQL> /*== Create an ARCHIVE_ADMIN user like the HR user ==*/
SQL> /*== with FLA_TBS1 default tablespace ==*/
SQL> CREATE USER ARCHIVE_ADMIN PROFILE DEFAULT IDENTIFIED BY
ARCHIVE_ADMIN
2 DEFAULT TABLESPACE FLA_TBS1 TEMPORARY TABLESPACE TEMP
3 ACCOUNT UNLOCK;

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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-160
Grant succeeded.

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;
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:
ARCHIVE_ADMIN ==*/
SQL> /*== The HR user has the password: HR ==*/
SQL>
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL>
2) To give the ARCHIVE_ADMIN user administrative privileges for creating,
maintaining, and dropping flashback data archives, execute the following command
as the SYS user:
GRANT FLASHBACK ARCHIVE ADMINISTER TO archive_admin;
$ sqlplus / as sysdba
SQL> GRANT FLASHBACK ARCHIVE ADMINISTER TO archive_admin;

Grant succeeded.

SQL>
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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-161
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
TABLESPACE fla_tbs1
QUOTA 10M
RETENTION 1 YEAR
/ 2 3 4 5

Flashback archive created.

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.

SQL>
6) Now, you switch to the role of a flashback archive user. Connect as the HR user with
the HR password. To enable this flashback data archive for the EMPLOYEES table,
execute the following command:
ALTER TABLE hr.employees FLASHBACK ARCHIVE fla1;
SQL> connect HR/HR
Connected.
SQL> ALTER TABLE hr.employees FLASHBACK ARCHIVE fla1;

Table altered.

SQL>
7) To view and increase the salary of Mr. Fox three times by 1000, execute the
flada_dml.sql script. This produces activity in the flashback data archive.
$ 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-162
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 ==*/
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 9600

1 row selected.

SQL>
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL>
SQL> /*== Increase the salary three times by 1000 ==*/
SQL>
SQL> UPDATE hr.employees
2 SET salary = salary + 1000
3 WHERE last_name = 'Fox'
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 /

Commit complete.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-163
SQL> UPDATE hr.employees
2 SET salary = salary + 1000
3 WHERE last_name = 'Fox'
4 /

1 row updated.

SQL> COMMIT
2 /

Commit complete.

SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL>
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

1 row selected.

SQL>
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...

SQL>
SQL> set pause off
SQL> set feedback on
SQL>
8) To query the internal name of the archive table, execute the following command:
SELECT * FROM USER_FLASHBACK_ARCHIVE_TABLES;
SQL> SELECT * FROM USER_FLASHBACK_ARCHIVE_TABLES;

TABLE_NAME OWNER_NAME
------------------------------ ------------------------------
FLASHBACK_ARCHIVE_NAME
--------------------------------------------------------------
ARCHIVE_TABLE_NAME
-----------------------------------------------------
EMPLOYEES HR
FLA1
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-164

SYS_FBA_HIST_70271

1 row selected.

SQL>
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
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.
Note: If you execute the DROP command too quickly, while internal processing still
occurs, you might receive an ORA-30013 error. Wait and try again.
10) As the HR user, choose a time after the creation of the flashback data archive and
before you executed the erroneous DML. To view Mr. Fox's employee record as of
that time, execute the following query (replace '10' MINUTE with your chosen
historic date, format examples: '50' SECOND, '10' DAY, '5' MONTH):
Note: You receive an ORA-1466 error, if the time you specify a time before the
flashback data archive was started. Reduce the time to a smaller interval and try
again. If you still see the salary of 12600, increase your time interval.

SELECT employee_id, last_name, salary
FROM hr.employees AS OF TIMESTAMP
(SYSTIMESTAMP - INTERVAL '10' MINUTE)
WHERE last_name = 'Fox';
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
----------- ------------------------- ----------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-165
170 Fox 9600
1 row selected.
SQL>
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)
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>
12) From your SQL*Plus session, connect to the database as the SYS user and list the
data dictionary views available to you, execute the flada_list1.sql file:
SQL> connect / as sysdba
Connected.
SQL> @flada_list1
SQL> REM "******************************************* "
SQL> REM "For demo purposes ONLY:"
SQL>
SQL> connect / as sysdba
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> /*== 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
------------------------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-166
DBA_FLASHBACK_ARCHIVE
DBA_FLASHBACK_ARCHIVE_TABLES
DBA_FLASHBACK_ARCHIVE_TS
USER_FLASHBACK_ARCHIVE
USER_FLASHBACK_ARCHIVE_TABLES

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL>
SQL> col FLASHBACK_ARCHIVE_NAME format A25
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
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)
FLASHBACK_ARCHIVE#
NOT NULL NUMBER
RETENTION_IN_DAYS
NOT NULL NUMBER
CREATE_TIME
TIMESTAMP(9)
LAST_PURGE_TIME
TIMESTAMP(9)
STATUS
VARCHAR2(7)

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL>
SQL> /*== To query the time when the flashback data archive(s)
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-167

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL>
SQL> DESC dba_flashback_archive_ts
Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
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 ...

SQL>
SQL> /*== To list the tablespace(s), which are used for
flashback data archives ==*/
SQL>
SQL> SELECT *
2 FROM dba_flashback_archive_ts
3 /
Press [Enter] to continue ...

FLASHBACK_ARCHIVE_NAME FLASHBACK_ARCHIVE# TABLESPACE_NAME
QUOTA_IN_MB
------------------------- ------------------ -----------------
------------- ----------------------------------------
FLA1 1 FLA_TBS1
10

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL>
SQL> DESC dba_flashback_archive_tables
Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-168
TABLE_NAME
NOT NULL VARCHAR2(30)
OWNER_NAME
NOT NULL VARCHAR2(30)
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)
ARCHIVE_TABLE_NAME
VARCHAR2(53)

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL>
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

SQL>
SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL> clear columns
SQL>
SQL> connect hr/HR
Connected.
SQL>
SQL> SELECT table_name
2 FROM dict
3 WHERE table_name LIKE '%FLASHBACK_ARCHIVE%'
4 /
Press [Enter] to continue ...

TABLE_NAME
------------------------------
USER_FLASHBACK_ARCHIVE
USER_FLASHBACK_ARCHIVE_TABLES

SQL> pause Press [Enter] to continue ...
Press [Enter] to continue ...

SQL> exit

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-169
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

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>

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);
SQL> ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE
TIMESTAMP(SYSTIMESTAMP - INTERVAL '2' MINUTE);

Flashback archive altered.

SQL>
15) Execute the flada_tbs2.sql script to create an additional 10 MB tablespace as
the SYS user.
SQL> @flada_tbs2
Connected.
SQL> set serveroutput on
SQL> -- set verify on
SQL> set term on
SQL> set lines 200
SQL> set pages 44
SQL> set pause on
SQL>
SQL> /*== Create another tablespace ==*/
SQL>
SQL> DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
2 /
DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
*
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-170
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
4 NOLOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE
MANAGEMENT AUTO
5 /

Tablespace created.

SQL> pause Press [Enter] to continue...
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;

Flashback archive altered.

SQL>
17) All tables in one specific flashback data archive have the same retention time. Change
the retention time of the FLA1 flashback data archive to two years.
SQL> ALTER FLASHBACK ARCHIVE fla1 MODIFY RETENTION 2 YEAR;

Flashback archive altered.

SQL>
18) As the ARCHIVE_ADMIN user, drop the FLA1 flashback data archive. Note:
Dropping a flashback data archive includes dropping the internal tamper-proofed
history table. You cannot drop this table directly due to auditing and security
requirements. Dropping a flashback data archive does not drop the tablespaces in
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-171
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
SQL> set lines 200
SQL> set pause on
SQL>
SQL> connect / as sysdba
Connected.

SQL> CREATE SMALLFILE UNDO TABLESPACE undotbs1
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 /
Tablespace dropped.

SQL> DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
2 /
Tablespace dropped.

SQL> ALTER USER hr PASSWORD EXPIRE ACCOUNT LOCK
2 /
User altered.

SQL> DROP USER archive_admin CASCADE
2 /
User dropped.

SQL> DROP TABLESPACE undotbs2 INCLUDING CONTENTS
2 /
Tablespace dropped.

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...
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 12-2: Using Flashback Data Archive (continued)
Oracle Database 11g: Administration Workshop II A-172

SQL> exit

Note: If you execute the DROP command too quickly, while internal processing still
occurs, you might receive an ORA-30013 error. Wait and try again.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-173
Practices for Lesson 13
In this practice, you employ various diagnostic capabilities to solve errors.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-174
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.
$ 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.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
With the Partitioning, OLAP and Data Mining options

SQL> select object_id from dba_objects where owner='SCOTT' and
object_name='TABJMW';

no rows selected

SQL> create table scott.tabjmw(c number) tablespace users;

Table created.


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.

SQL> print obj;

OBJ
----------
70975

SQL> update tab$ set cols=1001 where obj#=:obj;

1 row updated.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-175
commit;



SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition
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.
d) On the Run Dictionary Integrity Check page, specify a Run Name: DictCheck
and click OK.

e) Back to the Advisor Central Checkers page, you should see a Confirmation
message indicating that your check ran successfully.
f) Select your DictCheck run and click Details.
g) This takes you to the Run Details Findings tabbed page from 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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-176

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

SQL*Plus: Release 11.1.0.5.0 - Beta on Thu May 24 05:57:02
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> set long 100000

SQL> select dbms_hm.get_run_report('DictCheck') from dual;

DBMS_HM.GET_RUN_REPORT('DICTCHECK')
--------------------------------------------------------------------
------------
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-177

Run Findings And Recommendations
Finding
Finding Name : Dictionary Inconsistency
Finding ID : 22
Type : FAILURE
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



SQL>
4) Go back to your EM Home page. What do you observe?
a) You should see a new critical alert (Data Failure) for the previously detected
corruption in the Alerts section of the Home page.

5) Flush your shared pool and buffer cache first, then exit and reconnect as the SYS
user. From a SQL*Plus session connected as the SYS user, execute the following
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-178
Process ID: 1487
Session ID: 152 Serial number: 2276


SQL>
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.

b) On the Support Workbench Problems tabbed page, you should see a new Active
Incident whose description is similar to ORA 7445 [qcstda()+515].

c) Click the + icon in the Details column for this problem.
d) This shows you the corresponding first-time incident.
e) Click that incident number.
f) This takes you to the corresponding Incident Details page. Make a note of the
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".
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-179

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
Credentials page from where you can enter oracle/oracle and click Continue.
k) This brings you to the Contents page from where you can see the structured trace
information.
l) For example, click the current sql statement link below the incident dump
link. This prints the culprit SQL statement in the window below the Trace Map.
m) Click OK.
n) Back to the Incident Details page, click the Problem Key link.
o) On the Problems Details page, click Edit in front of the SR field.
p) Enter 1234 in the SR Number pop-up window that appears and click OK. It is
assumed that you already opened an SR (1234) with Metalink.

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 could enter a comment here.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-180
7) Back to your terminal window, locate your incident and your health check report in
ADR.
$ cd $ORACLE_BASE/diag/rdbms/orcl/orcl

$ ls
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

orcl_ora_1487_i26649.trc
orcl_ora_1487_i26649.trm
$ cd ../..
$ ls
alert cdump hm incident incpkg ir lck metadata stage
sweep trace
$ cd hm
$ ls
HMREPORT_DictCheck.hm
$ cd ..
$
8) Use ADRCI to locate your incident and problem information.
$ adrci

ADRCI: Release 11.1.0.6.0 - Beta on Wed Jul 25 16:03:42 2007

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:
**************************************************************
***********
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-181
INCIDENT_ID PROBLEM_KEY
CREATE_TIME
-------------------- -----------------------------------------
------------------ ----------------------------------------
26649 ORA 7445 [qcstda()+515]
2007-07-25 15:35:35.107020 -04:0021124 ORA 600
[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:
**************************************************************
***********
PROBLEM_ID PROBLEM_KEY
LAST_INCIDENT LASTINC_TIME
-------------------- -----------------------------------------
------------------ -------------------- ----------------------
------------------
1 ORA 7445 [qcstda()+515]
26649 2007-07-25 1
5:35:35.107020 -04:00
1 rows fetched

adrci>
adrci>
9) Use Enterprise Manager to package your problem quickly.
a) From the Problem Details page, click Quick Package in the Investigate and
Resolve section.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-182
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.
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/
ORA7445qc_20070725160927_COM_1.zip. Please send it manually
to Oracle."
j) Click OK.
k) Back to the Problem Details Activity Log tabbed page, you should now see two
new entries in the log reporting about the package creation for this problem.
l) In the Summary section, click Yes in front of the Packaged entry.
m) This takes you to the Packages page from where you can see your package.
n) Select your package, and click View.
o) This takes you to the Package Details page from where you can see the package
details.
p) Click the Files tab.
q) On the Files tabbed page, you can now see the Full Package Content view.
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-183
LAST_COMPLETE_SEQUEN PROBLEM_ID NAME
DESCRIPTION
CORRELATION_LEVEL DRIVING_INCIDENT BEGIN_TIME
END_TIME UPDATE_TIME
-------------------- -------------------- --------------------
---------------------------------------- --------------------
-------------------- -------------------- --------------------
--------------------------------------------------------------
------------------- ------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
----------- -------------------- -------------------- --------
-------------------------------- -----------------------------
----------- ----------------------------------------
1 0 4
2007-07-25 16:10:53.351235 -04:00 1
1 1
ORA7445qc_20070725160927
2 26649
2007-07-25 16:10:53.689763 -04:00

adrci>
11) After analyzing the problem, you know that the number of columns for TABJMW is
wrong in TAB$. Fix the issue by updating TAB$ and close your problem. You can
execute hm_fix.sh from the labs subdirectory for that purpose.
$ $HOME/labs/hm_fix.sh

sqlplus / as sysdba

SQL*Plus: Release 11.1.0.5.0 - Beta on Thu May 24 08:16:40
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-1: Diagnostic Scenario (continued)
Oracle Database 11g: Administration Workshop II A-184

SQL> print obj;

OBJ
----------
70975

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
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP and Data Mining options
$
12) Use Enterprise Manager to close your incident.
a) Back to the Package Details page, click the problem link in front of the
Problems in Package field in the Summary section.
b) On the Problem Details Incidents tabbed page, select your incident and click
Close.
c) On the Confirmation page, click Yes.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-185
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
populated with data from the HR schema. A backup of the new tablespace is
performed, and then a corruption is introduced into the datafile. 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

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>
Tablespace created.

SQL> SQL>
User dropped.

SQL> SQL>
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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-186
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;

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
handle=+FRA/orcl/backupset/2007_08_27/nnndf0_tag20070827t10383
6_0.260.631708727 tag=TAG20070827T103836 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 27-AUG-07

SQL> SQL> Disconnected from Oracle Database 11g Enterprise
Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP and Data Mining options
0+1 records in
0+1 records out
0+1 records in
0+1 records out
0+1 records in
0+1 records out

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 26
14:42:10 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> 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'


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-187
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'


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
Release 11.1.0.6.0 - Production
With the Partitioning, OLAP and Data Mining options

$

2) Use RMAN to back up the TBSBC tablespace. What happens?
$ rman target / nocatalog
RMAN> backup tablespace tbsbc;

Starting backup at 27-AUG-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=118 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
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.

3) Use the RMAN list failure command to provide details about the errors.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-188
$ rman target / nocatalog

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Aug
27 09:49:50 2007

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:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' contains one or
more corrupt blocks
Impact: Some objects in tablespace TBSBC might be
unavailable
List of child failures for parent failure ID 1942
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
1957 HIGH OPEN 2007-10-07:18:47:21 Block 28
in datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is
media corrupt
Impact: Object REGIONS owned by BC might be unavailable
1951 HIGH OPEN 2007-10-07:18:47:21 Block 20
in datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is
media corrupt
Impact: Object DEPARTMENTS owned by BC might be
unavailable
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 could 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
---------- -------------------
DESCRIPTION
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-189
--------------------------------------------------------------
------------------
IMPACTS
--------------------------------------------------------------
------------------
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

FAILURE_ID TIME_DETECTED
---------- -------------------
DESCRIPTION
--------------------------------------------------------------
------------------
IMPACTS
--------------------------------------------------------------
------------------
upt
Object EMPLOYEES owned by BC might be unavailable

1951 2007-10-07:18:47:21
Block 20 in datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corr
upt
Object DEPARTMENTS owned by BC might be unavailable

FAILURE_ID TIME_DETECTED
---------- -------------------
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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-190
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

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
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
1137 CRITICAL OPEN 2007-06-11:15:29:10 SQL
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

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=149 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=111 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-191
========================
Option Repair Description
------ ------------------
1 Recover multiple corrupt blocks in datafile 3
Strategy: The repair includes complete media recovery with
no data loss Repair script:
/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
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
REPAIR_SCRIPT
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
ESTIMATED_REPAIR_TIME ACTUAL_REPAIR_TIME STATUS
--------------------- ------------------ -------
391 390 NO DATA LOSS
1 27-AUG-07 UNKNOWN
The repair includes complete media recovery with no data loss
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2681015512.hm
0 0 NOT RUN
SQL> exit

6) Rerun the RMAN advise failure all command. After inspecting the results
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;

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-192
List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
1137 CRITICAL OPEN 2007-06-11:15:29:10 SQL
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
------ ------------------
1 Recover multiple corrupt blocks in datafile 3
Strategy: The repair includes complete media recovery with
no data loss Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no
data loss Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm

contents of repair script:
# block media recovery for multiple blocks
recover datafile 3 block 12, 20, 28;

Do you really want to execute the above repair (enter YES or
NO)? yes
executing repair script

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-2: Repairing Block Corruption (continued)
Oracle Database 11g: Administration Workshop II A-193
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

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;

REGION_ID REGION_NAME
---------- -------------------------
1 Europe
2 Americas
3 Asia
4 Middle East and Africa

SQL> exit

8) To clean up the practice environment, run the bc_cleanup.sh script from the
$HOME/labs directory.
$ ./bc_cleanup.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 26
14:56:16 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> SQL>
Tablespace dropped.

SQL> SQL>
User dropped.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-194
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.
$ 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
With the Partitioning, OLAP, Data Mining and Real Application
Testing options

SQL> @sql_repair1
SQL>
SQL> -- This example generates a workaround for a crash. This
bug has already
SQL> -- been fixed but we toggle the bug fix using an
underscore parameter
SQL> -- which uses the (internal) feature called bug fix
control.
SQL> -- This script will pause periodically to allow you to
read the comments
SQL> -- and see the output of the previous command on the
screen. Just press
SQL> -- return to make the demo resume.
SQL>
SQL> pause
2) Press [Enter] twice 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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-195
SQL> alter user scott account unlock;

User altered.

SQL>
SQL>
SQL> -- Next we need to create and populate the table used by
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
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL>
SQL> create table t(a varchar(40), b number, c varchar(240), d
varchar(240));

Table created.

SQL>
SQL> -- create index tc on t(b, d, a);
SQL>
SQL> insert into t values('a', 1, 'b', 'c');

1 row created.

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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-196
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";

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.
SQL>
SQL> --- explain the plan
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>
SQL> --- display the plan
SQL> select plan_table_output from
table(dbms_xplan.display('plan_table',null));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
------------------
Plan hash value: 2017343943

--------------------------------------------------------------
----------------
| 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 |
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-197
|* 4 | HASH JOIN | | 1 | 507 | 7
(15)| 00:00:01 |
|* 5 | TABLE ACCESS FULL| T | 2 | 652 | 3
(0)| 00:00:01 |

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
------------------
|* 6 | TABLE ACCESS FULL| T | 2 | 362 | 3
(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')
6 - filter("T1"."A"='a')

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
------------------

Note
-----
- dynamic sampling used for this statement

26 rows selected.

SQL>
SQL> -- The plan shows that we we will do a full table scan
oun r.
SQL> -- If we execut this simple system it will crash the
system.
SQL>
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],
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-198
[16777631], [17], [], []


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
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;

System altered.

SQL>
SQL> set echo on;
SQL>
SQL> -- At this point your previous session has crashed due to
a problem
SQL> -- with our delete statement. We now want to use the SQL
Repair Advisor
SQL> -- to fit that problem. Before we begin to fix this
problem lets ensure
SQL> -- that the actual code that prevents this issue in real
life is switched off.
SQL>
SQL> pause
8) Press [Enter] to continue. Make sure that the code for the previous issue is still
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-199
SQL> -- to specify the problem type. There are three possible
problem types
SQL>
SQL> -- PROBLEM_TYPE_COMPILATION_ERROR
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
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');
END;

*
ERROR at line 1:
ORA-13605: The specified task or object sqldiag_bug_5869490
does not exist for the current user.
ORA-06512: at "SYS.PRVT_ADVISOR", line 1967
ORA-06512: at "SYS.DBMS_ADVISOR", line 172
ORA-06512: at "SYS.DBMS_SQLTUNE", line 759
ORA-06512: at "SYS.DBMS_SQLDIAG", line 838
ORA-06512: at line 1


SQL>
SQL> declare
2 rep_out clob;
3 t_id varchar2(50);
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',
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-200
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);
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);
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
Workload Type : Single SQL Statement
Execution Count : 1
Current Execution : EXEC_47
Execution Type : SQL DIAGNOSIS
Scope : COMPREHENSIVE
Time Limit(seconds) : 1800
Completion Status : COMPLETED
Started at : 05/29/2007 01:19:49
Completed at : 05/29/2007 01:20:07

--------------------------------------------------------------
-----------------
Schema Name: SCOTT
SQL ID : f5z1dvyudh0hj
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)

--------------------------------------------------------------
-----------------
FINDINGS SECTION (1 finding)
--------------------------------------------------------------
-----------------

1- SQL Patch Finding (see explain plans section below)
------------------------------------------------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-201
A potentially better execution plan was found for this
statement.

Recommendation
--------------
- Consider accepting the recommended SQL patch.
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
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
- Recommended plan with hash value 4122352137 has number of
rows 0, check sum
0, execution time 22 and 16 buffer gets
- Alternative plan with hash value 3804998351 has number of
rows 0, check sum
0, execution time 1 and 16 buffer gets
- Alternative plan with hash value 4122352137 has number of
rows 0, check sum
0, execution time 22 and 16 buffer gets
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_USE_HASH_AGGREGATION(@"SEL$80F8B8C6") has cost 7 with
plan hash value
4117267572
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_USE_HASH(@"SEL$80F8B8C6" "T1"@"DEL$1") has cost 7 with
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-202
- 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
- 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
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
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.5') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.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.0') has cost 1 with
plan hash value
4122352137
- 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-203
- 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
(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
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
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.4') 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.5') has cost 7 with
plan hash
value 4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.1') 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.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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-204
(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
- 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],
[16777631], [0], [16777631], [17], [], []

--------------------------------------------------------------
-----------------
EXPLAIN PLANS SECTION
--------------------------------------------------------------
-----------------

1- Original
-----------
Plan hash value: 2017343943

--------------------------------------------------------------
----------------
| 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 |
|* 5 | 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):
-------------------------------------------------------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-205

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))
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):
-----------------------------------------------------------

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],
"T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22], "T2"."D"[VARCHAR2,240],
ROWID[ROWID,10]
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240]
6 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22],
"T1"."D"[VARCHAR2,240]

Note
-----
- dynamic sampling used for this statement

2- Original With Adjusted Cost
------------------------------
Plan hash value: 4122352137

--------------------------------------------------------------
---------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------
---------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-206
| 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 |
| |
|* 5 | TABLE ACCESS FULL| T | 1 | 169 | 3
(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

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')
5 - filter("T2"."A"=:B1 AND "T2"."B"=:B2 AND "T2"."D"=:B3)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

2 - (cmp=2,3,4) ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22], "T1"."D"[VARCHAR2,240]
3 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22],
"T1"."D"[VARCHAR2,240]
4 - (#keys=0) MAX(ROWID)[10]
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240]

Note
-----
- dynamic sampling used for this statement

--------------------------------------------------------------
-----------------
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-207


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
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.
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],
[16777631], [0], [16777631], [17], [], []


SQL>
SQL> -- connect scott/tiger
SQL>
SQL> -- We need to accept the SQL Patch that the SQL Repair
Advisor recommended before
SQL> -- our SQL statement will be able to run without
crashing. To accept the SQL Patch
SQL> -- we must execute dbms_sqldiag.accept_sql_patch and pass
it task name
SQL>
SQL> pause
11) Press [Enter] to continue. This time you accept the SQL Patch.
SQL> execute dbms_sqldiag.accept_sql_patch(task_name =>
'sqldiag_bug_5869490', task_owner => 'SCOTT', replace =>
TRUE);

PL/SQL procedure successfully completed.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-208
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>
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
SQL> select plan_table_output from
table(dbms_xplan.display('plan_table',null,'advanced'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
----------------------------------------------------
Plan hash value: 4122352137

--------------------------------------------------------------
---------------
| 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 |
| |
|* 5 | TABLE ACCESS FULL| T | 1 | 169 | 3
(0)| 00:00:01 |
--------------------------------------------------------------
---------------

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-209
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")
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
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')
5 - filter("T2"."A"=:B1 AND "T2"."B"=:B2 AND "T2"."D"=:B3)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

2 - (cmp=2,3,4) ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22], "T1"."D"[VARCHAR2,240]
3 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22],
"T1"."D"[VARCHAR2,240]
4 - (#keys=0) MAX(ROWID)[10]
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240]

Note
-----
- dynamic sampling used for this statement
- SQL patch "SYS_SQLPTCH_0144b5bb2a078000" used for this
statement
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 13-3: SQL Repair Advisor Scenario (continued)
Oracle Database 11g: Administration Workshop II A-210

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);

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
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>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
$

14) Finally, drop the patch using the DBMS_SQLDIAG.DROP_SQL_PATCH procedure.
Get the patch name under the Note section from step 12.
SQL> execute DBMS_SQLDIAG.DROP_SQL_PATCH (name =>
SYS_SQLPTCH_0144b5bb2a078000);
SQL> exit

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-211
Practices for Lesson 14
In this practice, you use various new memory management capabilities.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-212
Practice 14-1: Using Automatic Memory Management
In this practice, you use Automatic Memory Management to show that you do not need to
manually modify SGA_TARGET and PGA_AGGREGATE_TARGET anymore. 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 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 ...
... Stopped.
$
2) Shut down your database instance and make a copy of your spfile. Then restart your
database instance.

$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.5.0 - Beta on Fri May 25 01:41:28
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> 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

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-213
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

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.
_PX_use_large_pool = TRUE
_memory_broker_stat_interval = 5
_memory_management_tracing = 31
parallel_execution_message_size = 36864
parallel_max_servers = 200
parallel_adaptive_multi_user = FALSE
processes = 200
sga_target = 0
pga_aggregate_target = 0
memory_target = 280M
SQL> @change_parameters.sql
SQL> set pages 20000
SQL>
SQL> ALTER SYSTEM SET "_PX_use_large_pool" = TRUE
SCOPE=SPFILE;

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>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-214
SQL> ALTER SYSTEM SET "parallel_execution_message_size" =
36864 SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET "parallel_max_servers" = 200
SCOPE=SPFILE;

System altered.

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.

SQL> ALTER SYSTEM SET "sga_target" = 0 SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET "memory_target" = 280M SCOPE=SPFILE;

System altered.

SQL>
4) Remain connected in your SQL*Plus session as the SYS user and execute the
amm_setup.sql script.
SQL> @amm_setup.sql
SQL> drop tablespace tbssga including contents and datafiles;
drop tablespace tbssga including contents and datafiles
*
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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-215
drop tablespace mytemp including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'MYTEMP' does not exist


SQL>
SQL> create temporary tablespace mytemp tempfile 'temp12.f'
size 40m reuse;

Tablespace created.

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
3 temporary tablespace mytemp;

User created.

SQL>
SQL> grant connect,resource,dba to amm;

Grant succeeded.

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 58720256 0
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-216
Connected.
SQL>
SQL> drop table tabsga purge;
drop table tabsga purge
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL>
SQL> create table tabsga(a number, b number) tablespace
tbssga;

Table created.

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.

SQL> commit;

Commit complete.

SQL>
SQL> alter table tabsga parallel 64;

Table altered.

SQL>
SQL> create or replace procedure testpga( psize number ) as
2 begin
3 declare
4 TYPE nAllotment_tabtyp IS TABLE OF char(2048) INDEX BY
BINARY_INTEGER;
5 myarray nAllotment_tabtyp;
6 begin
7 for i in 1..psize loop
8 myarray(i) := to_char(i);
9 end loop;
10 end;
11 end;
12 /

Procedure created.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-217
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
---------- ---------- ----------
shared poo 58720256 0
large pool 4194304 0
java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 117440512 0
PGA Target 100663296 0

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:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup quiet;
ORACLE instance started.
Database mounted.
Database opened.
SQL>
SQL> connect amm/amm
Connected.
SQL>
6) Still connected as the AMM user in your SQL*Plus session, determine the current
settings for the various memory buffers as well as the list of resized operations that
were done since you started your instance. You can use the components.sql
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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-218

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

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
---------- ---------- ------------- --------- ---------
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
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
PGA Target 100663296 STATIC COMPLETE
ASM Buffer 0 STATIC COMPLETE
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
DEFAULT bu 109051904 SHRINK IMMEDIATE COMPLETE
shared poo 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 104857600 SHRINK IMMEDIATE COMPLETE
large pool 4194304 GROW IMMEDIATE COMPLETE

22 rows selected.

SQL>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-219
7) Remain connected as the AMM user in your SQL*Plus session and execute the
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

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 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,
OPER_MODE, status from v$memory_resize_ops order by
START_TIME;

SUBSTR(COM FINAL_SIZE OPER_TYPE 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-220
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
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
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
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
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
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-221
large pool 79691776 GROW IMMEDIATE COMPLETE
DEFAULT bu 29360128 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE

64 rows selected.

SQL>
8) Redo the same thing as in the previous step but this time using the following query.
You can use query2.sql script for that purpose. What do you observe?
a) The same trend continues.
SQL> @query2.sql
SQL> select /*+ PARALLEL(s 26) */ count(*)
2 from (select /*+ parallel(s 26) */ * from tabsga s group
by a);

COUNT(*)
----------
100000

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 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
START_TIME;

SUBSTR(COM FINAL_SIZE OPER_TYPE 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-222
DEFAULT bu 109051904 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
ASM Buffer 0 STATIC COMPLETE
PGA Target 100663296 STATIC COMPLETE
DEFAULT 32 0 STATIC COMPLETE
DEFAULT 16 0 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
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
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
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
large pool 54525952 GROW IMMEDIATE COMPLETE
DEFAULT bu 50331648 SHRINK IMMEDIATE COMPLETE
large pool 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 46137344 SHRINK IMMEDIATE COMPLETE
large pool 62914560 GROW IMMEDIATE COMPLETE
DEFAULT bu 41943040 SHRINK IMMEDIATE COMPLETE
large pool 67108864 GROW IMMEDIATE COMPLETE
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-223
DEFAULT bu 37748736 SHRINK IMMEDIATE COMPLETE
large pool 71303168 GROW IMMEDIATE COMPLETE
large pool 75497472 GROW IMMEDIATE COMPLETE
DEFAULT bu 33554432 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 29360128 SHRINK IMMEDIATE COMPLETE
large pool 79691776 GROW IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
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>
9) Still connected as the AMM user from your SQL*Plus session, execute the following
command, and immediately after, 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 the query number three needs a lot of untunable PGA
memory.
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;

COMP CS US
---------- ---------- ----------
shared poo 79691776 0
large pool 4194304 0
java pool 4194304 0
SGA Target 113246208 0
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-224
DEFAULT bu 8388608 0
Shared IO 8388608 8388608
PGA Target 180355072 0

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
---------- ---------- ------------- --------- ---------
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
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
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
DEFAULT bu 41943040 SHRINK IMMEDIATE COMPLETE
large pool 62914560 GROW IMMEDIATE COMPLETE
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-225
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
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
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
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
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
DEFAULT bu 96468992 GROW DEFERRED ERROR
large pool 8388608 SHRINK DEFERRED COMPLETE
DEFAULT bu 100663296 GROW DEFERRED COMPLETE
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-226
SGA Target 176160768 SHRINK DEFERRED COMPLETE
DEFAULT bu 79691776 SHRINK DEFERRED COMPLETE
PGA Target 117440512 GROW DEFERRED COMPLETE
SGA Target 167772160 SHRINK DEFERRED COMPLETE
DEFAULT bu 71303168 SHRINK DEFERRED COMPLETE
PGA Target 125829120 GROW DEFERRED COMPLETE
SGA Target 159383552 SHRINK DEFERRED COMPLETE
DEFAULT bu 62914560 SHRINK DEFERRED COMPLETE
PGA Target 134217728 GROW DEFERRED COMPLETE
large pool 4194304 SHRINK DEFERRED COMPLETE
DEFAULT bu 67108864 GROW DEFERRED COMPLETE
SGA Target 146800640 SHRINK DEFERRED COMPLETE
DEFAULT bu 54525952 SHRINK DEFERRED COMPLETE
PGA Target 146800640 GROW DEFERRED COMPLETE
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
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
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-227
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP and Data Mining options
$
10) From a terminal window, restart Enterprise Manager Database Control and look at the
memory variations that happened during this lab. What do you observe?
$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release
11.1.0.4.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights
reserved.
https://stbbv07.us.oracle.com:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control
....... started.
--------------------------------------------------------------
----
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 large pool was raised, and then the total SGA was raised too,
and then SGA was shrunk for the benefit of the PGA.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 14-1: Using Automatic Memory Management
(continued)
Oracle Database 11g: Administration Workshop II A-228

11) To clean up your environment, shut down your database instance, restore the original
SPFILE, and restart your database instance. Running the amm_cleanup.sh script
accomplishes the same task.
$ sqlplus sys/oracle as sysdba
SQL> shutdown immediate;
SQL> exit
$ cp /tmp/spfileorcl_bu.ora $ORACLE_HOME/dbs/spfileorcl.ora
$ sqlplus sys/oracle as sysdba
SQL> startup;
SQL> drop user amm cascade;
SQL> drop tablespace tbssga including contents and datafiles;
SQL> drop tablespace mytemp including contents and datafiles;
SQL> exit



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-229
Practices for Lesson 15

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-230
Practice 15-1: Monitoring Services
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

1) Use the DBMS_SERVICE package to create a service called SERV1. Then make sure
that you add your service name to your tnsnames.ora file.
a) The recommended method for adding a service name to the tnsnames.ora file
is to use Net Manager. For this exercise, execute the add_service.sh script.
Review the tnsnames.ora file at $ORACLE_HOME/network/admin to
confirm that the following lines are included. Substitute the output of the
hostname command for <hostname> below.
SERV1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = <hostname>.us.oracle.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SERV1.us.oracle.com)
)
)

$ . 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

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


Connected to:
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-231
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
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
With the Partitioning, OLAP and Data Mining options
2) After you have created your services, try connecting to your database by using your
service name. What happens and why?
Answer: You cannot connect using your service because although it is defined, it is
not started on your instance. You can verify this by looking at the SERVICE_NAME
initialization parameter and by looking at the services known to the listener.
[oracle@edrsr3p1 labss]$ lsnrctl services

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 08-DEC-
2005 00:54:16

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
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):
"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))
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-232
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 "prod", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:21 refused:0 state:ready
LOCAL SERVER
Service "prodXDB.oracle.com" has 1 instance(s).
Instance "prod", status READY, has 1 handler(s) for this
service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022
state:ready
DISPATCHER <machine: edrsr3p1, pid: 5119>

(ADDRESS=(PROTOCOL=tcp)(HOST=edrsr3p1.us.oracle.com)(PORT=5940
6))
Service "prod_XPT.oracle.com" has 1 instance(s).
Instance "prod", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:21 refused:0 state:ready
LOCAL SERVER
The command completed successfully

[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
----------------------------- ----------- ----------------
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-233
descriptor


Warning: You are no longer connected to ORACLE.
SQL> exit
$
3) How would you make sure that you could connect using your service? Do it and
connect to your instance using your service.
Answer: You must start your service on your instance.
$ sqlplus / as sysdba


SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 8
13:01:54 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options


SQL> show parameter service

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

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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-234
Connecting to
(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...
Handler(s):
"DEDICATED" established:50 refused:0 state:ready
LOCAL SERVER
Service "SERV1.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
Service "orcl.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
Service "orclXDB.us.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
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
Connected.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-235
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
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

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 8
13:16:24 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, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

SQL> SQL> SQL> SQL> SQL> drop user jfv cascade
*
ERROR at line 1:
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-236
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.
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.
SQL> SQL> select count(*) from
dba_objects,dba_objects,dba_objects
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation



SQL> SQL> 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
6) Set alert thresholds for your SERV1 service by using Database Control. Specify the
values defined at the beginning of this practice.
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-hand 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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-237
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
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.
Look at the corresponding threshold history by using Database Control. Return to
the Service Response Time (per user call) (microseconds): Service Name SERV1
page, from the previous step.
$ ./serv1_load2.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 8
14:45:27 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, Oracle Label Security, OLAP, Data
Mining
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 muliple-edit icon button in the right-hand column of the row.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-1: Monitoring Services (continued)
Oracle Database 11g: Administration Workshop II A-238
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.
f) On the Confirmation page, click OK.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-239
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
1) Open a command-line window. Change to the $HOME/labs directory under
workshop directory and run the following OS script:
$ cd $HOME/labs
$ ./setup_perflab.sh
Note: This script takes a few minutes to run. The script starts a number of user
sessions to use up resources. If you run this script but for any reason do not complete
the workshop immediately, run the cleanup script cleanup_perflab.sh as
instructed at the end of this workshop ($./cleanup_perflab.sh) to stop the
sessions. When you complete the entire workshop as instructed, your machine returns
to optimum performance but it is still recommended that you run the cleanup script at
the end so that the other labs and workshops are not affected.
2) Run the start_perflab.sh script to start the workload. Do not wait for this
script to finish before moving on to the following steps.
$ ./start_perflab.sh
3) Open a browser and enter the following URL:
https://<hostname>:1158/em
Specify sys as the username and oracle as the password. Select SYSDBA from
the Connect As drop-down list, and then click Login.
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 2 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.
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.
______________________
______________________
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-2: Using SQL Tuning Advisor (continued)
Oracle Database 11g: Administration Workshop II A-240
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
As determined in the previous section, the targeted SQL statement needs tuning. The
SQL Tuning Advisor tunes the execution plan for you. Perform the following steps:

11) Click Schedule SQL Tuning Advisor.
12) In the Schedule Advisor window, make sure that the Scope Comprehensive is
selected and that the job is scheduled immediately. Click Submit.
13) The SQL Tuning Advisor creates a task to analyze the SQL statement and on
completion of this task, displays a set of tuning recommendations.
14) When the Tuning Recommendations page appears, click the New Explain Plan
eyeglasses icon to view the suggested changes for each recommendation.
Note: One or more recommendations may be given. The recommendation to add
indexes removes all full table scans from the explain plan and may have the highest
benefit. It removes full-table scans by creating new indexes. When you have reviewed
the New Explain Plan, click the Back button on the browser to return to the
Recommendations page.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-2: Using SQL Tuning Advisor (continued)
Oracle Database 11g: Administration Workshop II A-241
15) On the Recommendations page, select the Index recommendation that creates
indexes, and then click the Implement button to implement the tuning
recommendation.
16) On the Implement Recommendation page, click OK.
17) A confirmation message appears indicating that the Create indexes job was
successfully submitted. Click the Database tab and then the Performance tab.
Reviewing SQL Execution Details for a SQL Statement
Now that you have implemented the tuning suggestion, review the SQL statement and its
execution details. Perform the following steps:
18) Scroll down to the Average Active sessions chart. Wait for about a minute and then
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, and 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.
______________
______________
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
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
heading to sort the listing by table name.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-2: Using SQL Tuning Advisor (continued)
Oracle Database 11g: Administration Workshop II A-242
a) Find the index on SH.CUSTOMERS("CUST_FIRST_NAME"). Note that it has
a system-generated name starting with IDX$$.
b) Find the index on SH.SALES("CUST_ID"). Note that this index is a
partitioned index named SALES_CUST_BIX. The existence of this index
prevented the recommended index from being created. Only one index can be
created over a unique set of columns.
30) Navigate to the SQL Detail page and Statistics tab for the most active statement. Wait
until a few minutes have elapsed since the last tuning task was executed. This is the
time you recorded in step 25. Select the most active SQL statement (this should be the
same SQL_ID as in previous steps), and then click Schedule SQL Tuning Advisor.
31) On the Schedule SQL Tuning Advisor page, confirm the job is scheduled to execute
immediately, and then click Submit. If the Tuning Advisor does not return a
recommendation, schedule it again.
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, and 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.

35) Navigate to the SQL ID Detail page, click the Plan tab, and set each plan hash value
in turn until you find the one that does not have a Table Access Full operation and
does use both indexes, SALES_CUST_BIX and IDX$$%. If the plan does not
appear in the list, wait for a few moments, refresh the page, and then check for a new
plan.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 15-2: Using SQL Tuning Advisor (continued)
Oracle Database 11g: Administration Workshop II A-243

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.
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


38) Close your browser.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-244
Practices for Lesson 16
In this practice, you use the segment advisor capabilities.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-245
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 have finished with your test case,
drop the tablespace 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:
$ sqlplus / as sysdba
SQL> exec DBMS_SERVER_ALERT.SET_THRESHOLD(-
dbms_server_alert.tablespace_pct_full,-
NULL,NULL,NULL,NULL,1,1,NULL,-
dbms_server_alert.object_type_tablespace,NULL);
2. From a SQL*Plus session, check the databasewide threshold values for the
Tablespace Space Usage metric using the following command:
a. Log in to SQL*Plus and run the following query:
$ sqlplus / as sysdba
SQL> SELECT warning_value,critical_value
FROM dba_thresholds
WHERE metrics_name='Tablespace Space Usage'
AND object_name IS NULL;

WARNING_VALUE
--------------------------------------------------------------------
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-246
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.

e. Click Continue and then click OK to create the tablespace.

4. In Enterprise Manager, change the Tablespace Space Usage thresholds of the
TBSALERT tablespace. Set its warning level to 55 percent and its critical level to 70
percent.
a. On the Tablespaces page, select TBSALERT, click Edit, and then click
Thresholds.
b. Select Specify Thresholds, and enter 55 as Warning (%) and 70 as Critical (%)
under the Space Used section.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-247

c. Click Apply to modify the threshold values.
5. Using SQL*Plus, check the new threshold values for the TBSALERT tablespace.
a. In your SQL*Plus session, enter:
SQL> select warning_value,critical_value
from dba_thresholds
where metrics_name='Tablespace Space Usage' and
object_name='TBSALERT';
The result should be:
WARNING_VALUE CRITICAL_VALUE
--------------- ---------------
55 70
6. Query the reason and resolution columns from DBA_ALERT_HISTORY for
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-248
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
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;
alter table employees4 enable row movement;
alter table employees5 enable row movement;

BEGIN
FOR i in 1..10 LOOP
insert into employees1 select * from employees1;
insert into employees2 select * from employees2;
insert into employees3 select * from employees3;
insert into employees4 select * from employees4;
insert into employees5 select * from employees5;
commit;
END LOOP;
END;
/
insert into employees1 select * from employees1;
insert into employees2 select * from employees2;
insert into employees3 select * from employees3;
commit;
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-249

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:
SQL> select reason
from dba_outstanding_alerts
where object_name='TBSALERT';

REASON
--------------------------------------------------------------
Tablespace [TBSALERT] is [60 percent] full
9. Execute the inserts below to add more data to TBSALERT. Wait a few moments and
view the critical level in both the database and Database Control. Verify that
TBSALERT fullness is around 75%.
$ sqlplus / as sysdba
SQL> insert into employees4 select * from employees4;
SQL> commit;
SQL> insert into employees5 select * from employees5;
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:
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-250
SQL> select reason, message_level
from dba_outstanding_alerts
where object_name='TBSALERT';

REASON MESSAGE_LEVEL
-------------------------------------------- -------------

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.

10. Execute the following delete statements to delete rows from tables in TBSALERT.
These statements will take several minutes to complete.
SQL> delete employees1;
SQL> commit;
SQL> delete employees2;
SQL> commit;
SQL> delete employees3;
SQL> commit;
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-251

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.

d. On the Schedule page, make sure Immediately is selected and click Next.
e. On the Segment Advisor: Review page, click the Submit button.
f. This takes you back to the Advisor Central page, where you can see the evolution
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.

i. Click the Select All link and then click the Implement button.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-252

j. On the Shrink Segment: Options page, make sure that you click the Compact
Segments and Release Space option button. Click Implement.

k. On the Shrink Segment: Schedule page, click the Submit button.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-253
m. Navigate to the Tablespaces page and verify that the TBSALERT tablespace usage
is now below 55%.

12. Wait a few minutes and check that there are no longer any outstanding alerts for the
TBSALERT tablespace.
a. Navigate to the Database home page. You should see Problem Tablespaces: 0.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Solution for Practice 16-1: Managing Storage (continued)
Oracle Database 11g: Administration Workshop II A-254
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.
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
drop your TBSALERT tablespace.
$ ./seg_advsr_cleanup.sh

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 9
08:44:31 2007

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

SQL> Connected.
SQL>
System altered.

SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORACLE instance started.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-255
Practices for Lesson 17
You received complaints that certain batch jobs are using too many system resources and
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. Then, you 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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-256
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.

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 are opening 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
Manager section).
b) On the Consumer Groups page, click the Create button.
c) Enter APPUSER as Consumer Group and click Show SQL.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-257


2) Add the APPUSER and LOW_GROUP consumer groups to the DEFAULT_PLAN
resource plan. Change the level 3 CPU resource allocation percentages: 60% for the
APPUSER consumer group and 40% for the LOW_GROUP consumer group.
a) In Enterprise Manager, select Server > Plans.
b) On the Resource Plans page, select DEFAULT_PLAN and click the Edit button.
c) Click Modify.
d) On the Select Groups/Subplans page, move APPUSER and LOW_GROUP to the
Resource Allocations.

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 click Return. O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-258

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
priority than the CLIENT_OS_USER attribute.
a) In Enterprise Manager, select Server > Consumer Group Mappings.
b) Select Oracle User and click the Add Rule for Selected Type button.
c) On the Consumer Group Mappings page, ensure that APPUSER is selected as
Selected Consumer Group.
d) Move the HR user into the Selected Oracle User region, and then click OK.
e) On the Consumer Group Mappings General Page, click Show SQL.

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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-259
j) On the Consumer Group Mappings page, click the Priorities tab.

k) Confirm that Oracle User has a higher priority than Client OS User.
l) Click Apply to assign the SCOTT user to the LOW_GROUP consumer group.

4) Configure Consumer Group Mappings so that the oracle OS user belongs to the
SYS_GROUP consumer group.
a) In Enterprise Manager, select Server > Consumer Group Mappings.
b) Select Client OS User and click the Add Rule for Selected Type button.
c) Select SYS_GROUP from the Selected Consumer Group drop-down list, move
oracle into the Selected Client OS User area, and click OK.
d) Optionally, click Show SQL, review the statements, and click Return.
e) Click Apply to assign the oracle OS user to the SYS_GROUP consumer group.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-260

5) Assign the PM Oracle user to the following consumer groups: APPUSER,
LOW_GROUP, and SYS_GROUP.
a) In Enterprise Manager, select Server > Users (in the Security section).
b) Select the PM user and click the Edit button.
c) Click the Consumer Groups Privileges tab. If you see an error regarding the
password for the PM user, enter pm in both the password fields.
d) Click the Edit List button.
e) Move the APPUSER, LOW_GROUP, and SYS_GROUP consumer groups to
Selected Consumer Groups and click OK.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-261

f) Click Show SQL.

g) Review the statements and click Return.
h) Click Apply to assign the PM user to these consumer groups.

6) Execute the unlock_accts.sh script to unlock the HR, SCOTT, OE, and PM
Oracle user accounts in the orcl database. The script sets the passwords in
lowercase to match the username.
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-262
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

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>
User altered.

SQL>
User altered.

SQL>
User altered.

SQL> SQL> Disconnected from Oracle Database 11g Enterprise
Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
[oracle@edt3r10p1 labs]$
c) You should see that the four users have been altered. If not, resolve any problems
that might have occurred.
7) Activate the DEFAULT_PLAN resource group.
a) In Enterprise Manager, select Server > Plans.
b) On the Resource Plans page, select DEFAULT_PLAN, select Activate from the
Actions drop-down list, and click Go.
c) Click Yes to confirm your activation.
You should see a success message.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-263
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.
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

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>
c) 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.
d) To start a SQL*Plus session with the scott/scott@orcl connect string and
to set your SQL prompt to SECOND, enter:
$ sqlplus scott/scott@orcl

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-264
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:
FIRST>@query_rsc_groups.sql

SCHEMANAME RESOURCE_CONSUMER_GROUP
------------------------------ ------------------------------
SCOTT LOW_GROUP
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS

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 those following 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:
SECOND>connect pm/pm@orcl
Connected.
SECOND>
h) In your FIRST SQL*Plus session, enter / to execute the previous SQL
statement again.
FIRST>/

SCHEMANAME RESOURCE_CONSUMER_GROUP
------------------------------ -------------------------------
PM SYS_GROUP
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS

FIRST>
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-265
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
------------------------------ -------------------------------
OE OTHER_GROUPS
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS

FIRST>
l) 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
deleting the APPUSER resource group.
a) To deactivate the DEFAULT_PLAN resource group in Enterprise Manager, select
Server > Plans.
b) On the Resource Plans page, select the DEFAULT_PLAN, select Deactivate from
the Actions drop-down list, and click Go.
c) Click Yes to confirm your deactivation.
d) To lock accounts and reconfigure or undo all consumer group mappings, enter
from your working directory:
$ ./rsc_cleanup.sh
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 3
16:55:46 2007

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


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-266
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.

SQL>
User altered.

SQL> undo lab step 5
SQL> 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> 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
SQL> SQL> 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20 21 22 23 24
25 26
PL/SQL procedure successfully completed.

SQL> undo lab step 2
SQL> SQL> 2 3 4 5 6 7 8 9
PL/SQL procedure successfully completed.

SQL> 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
$
e) To delete the APPUSER resource group in Enterprise Manager, select Server >
Consumer Groups.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 17-1: Managing Resources (continued)
Oracle Database 11g: Administration Workshop II A-267
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 the terminal windows.


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-268
Practices for Lesson 18
In this practice, you explore Oracle Scheduler capabilities.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-269
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
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
session_history(snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)'); END;

Schedule:
Repeating: Do not Repeat
Start: Immediately
Options:
No special options
a. As the SYS user, grant CONNECT, RESOURCE, and DBA roles to the HR user.
SQL> connect sys/oracle as sysdba
Connected.
SQL> grant connect, resource, dba to hr;
b. Log in to Enterprise Manager Database Control as the HR user. Then click the
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
Owner: HR
Enabled: Yes
Description: Create the SESSION_HISTORY table
Logging Level: RUNS
Command Type: PL/SQL
PL/SQL Block:
BEGIN
execute immediate
('create table session_history(
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-270
snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)');
END;


e. On the Schedule folder tab, enter and confirm the following values:
Repeating: Do not Repeat
Start: Immediately
f. Click Show SQL if you wish to view the SQL statement defining your job.
g. Review the statements and click Return.
h. Click OK 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;
a. In Enterprise Manager, click the Server folder tab, and then select Programs.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-271
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
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,
sess_count);
COMMIT;
END;
d. Click Show SQL.

e. Review the statements, and then click Return.
f. Click OK to create the program.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-272

3. Create a schedule named SESS_UPDATE_SCHED owned by HR that executes every
three seconds. Use SQL*Plus and the DBMS_SCHEDULER.CREATE_SCHEDULE
procedure to create the schedule.
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
schedule_name => 'SESS_UPDATE_SCHED',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=SECONDLY;INTERVAL=3',
comments => 'Every three seconds');
END;
/
Return to Enterprise Manager Database Control and verify that the
SESS_UPDATE_SCHED schedule was created.
Hint: You may have to refresh the page for the Schedule to appear.
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-273
d. Verify that the SESS_UPDATE_SCHED schedule has been created. (You may
have to refresh the page for the Schedule to appear.)

4. Using Enterprise Manager Database Control, create a job named
LOG_SESSIONS_JOB that uses the LOG_SESS_COUNT_PRGM program and the
SESS_UPDATE_SCHED schedule. Make sure that the job uses FULL logging.
a. In Enterprise Manager, select Server > Jobs, and then click Create.
b. On the Create Job page, enter and confirm the following values:
Name: LOG_SESSIONS_JOB
Owner: HR
Description: Count sessions with HR.LOG_SESS_COUNT_PRGM
Logging level: FULL
c. Click Change Command Type, and on the Select Command Option page, select
Program Name, and enter HR.LOG_SESS_COUNT_PRGM in the field next to it,
or use the Lookup (flashlight) icon to select the program. Click OK.

d. Click the Schedule tab.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-274
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.

g. Review the statements and then click Return.
h. Click OK to create the job.
5. In your SQL*Plus session, check the HR.SESSION_HISTORY table for rows.
a. Enter:
SQL> SELECT * FROM SESSION_HISTORY ORDER BY snap_time;
Your result looks different but the second values should be three seconds apart:
SNAP_TIME
--------------------------------------------------------------
-----
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, and 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-275
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.
c. On the View Schedule page, click Edit.
e. Change the description to Every three minutes.
f. Change Available to Start to Immediately.
e. Change the value in the Repeat drop-down list from By Seconds to By
Minutes.
f. Ensure that the interval is 3 and click Show SQL.

g. Review the statements, click Return, and then click Apply.
h. In your SQL*Plus session, query the HR.SESSION_HISTORY table, ordered by the
SNAP_TIME column. (Wait for three minutes after you update the schedule.) Enter:
SQL> SELECT * FROM HR.SESSION_HISTORY ORDER BY snap_time;
Your result looks different (but the minute values should be 3 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-1: Creating Scheduler Components (continued)
Oracle Database 11g: Administration Workshop II A-276
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.
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.
d. Select If there are dependent objects, it will not be dropped and then click Yes
on the Confirmation page.
e. Click the Database Instance breadcrumb at the upper-left corner of the page to
return to the Server page. Then, click Programs.
f. With the LOG_SESS_COUNT_PRGM program selected, click the Delete button.
Click Yes to confirm.
g. Click the Database Instance breadcrumb at the upper-left corner of the page to
return to the Server page. Click Schedules.
h. With the SESS_UPDATE_SCHED schedule selected, click the Delete button.
Make sure that you do not delete the wrong schedule.
i. Select If there are dependent objects, it will not be dropped, and then click Yes
to confirm.
j. In your SQL*Plus session as the HR user, delete the SESSION_HISTORY table,
and then exit the session. Enter:
SQL> DROP TABLE session_history PURGE;
SQL> EXIT
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-277
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
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


-- This will produce an error the first

-- time it is run since PROG_1 does not exist

DBMS_SCHEDULER.DROP_PROGRAM (
program_name => '"SYSTEM"."PROG_1"');

END;

/


BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name=>'"SYSTEM"."PROG_1"'
,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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-2: Creating Lightweight Scheduler Jobs (continued)
Oracle Database 11g: Administration Workshop II A-278
$ cd $HOME/labs
$ sqlplus system/oracle

SQL*Plus: Release 11.1.0.5.0 - Beta on Tue May 29 11:10:55
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, Data Mining and Real Application
Testing options
SQL> @cr_test_log.sql
SQL> create table system.test_log
(job_type VARCHAR2(10)
,
timemark VARCHAR2(10)
,
act_time TIMESTAMP with TIME ZONE)

/
2 3 4 5 6 7 SQL>
Table created.
PL/SQL procedure successfully completed.

SQL> @prog_1.sql
SQL> BEGIN
2 DBMS_SCHEDULER.CREATE_PROGRAM(
3 program_name=>'"SYSTEM"."PROG_1"'
4 ,program_action=>'DECLARE
5 time_now DATE;
6 BEGIN
7
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.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-2: Creating Lightweight Scheduler Jobs (continued)
Oracle Database 11g: Administration Workshop II A-279
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.
$ 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);

BEGIN
-- Create the Job
jobname := 'my_lwt_job';

sys.dbms_scheduler.create_job(
job_name => '"SYSTEM"."MY_LWT_JOB"',
program_name => '"SYSTEM"."PROG_1"',
job_class => '"DEFAULT_JOB_CLASS"',
job_style => 'LIGHTWEIGHT',
repeat_interval => 'FREQ=DAILY;INTERVAL=2',
comments => 'Lightweight job',
enabled => TRUE);

END;
/
$
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-2: Creating Lightweight Scheduler Jobs (continued)
Oracle Database 11g: Administration Workshop II A-280
ORA-06512: at "SYS.DBMS_SCHEDULER", line 615
ORA-06512: at line 5


SQL>
SQL> DECLARE
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',
13 repeat_interval => 'FREQ=DAILY;INTERVAL=2',
14 comments => 'Lightweight job',
15 enabled => TRUE);
16
17 END;
18 /

PL/SQL procedure successfully completed.

SQL>

3) Check the Scheduler metadata views USER_SCHEDULER_JOBS, _PROGRAMS,
DBA_JOBS.
a) Select JOB_NAME, JOB_STYLE, and PROGRAM_NAME from
USER_SCHEDULER_JOBS.
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.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-2: Creating Lightweight Scheduler Jobs (continued)
Oracle Database 11g: Administration Workshop II A-281
View the history of MY_LWT_JOB.


b) Click the Job Name to view the job attributes.


5) Drop the job from the EM Scheduler Jobs page.
a) Navigate to the Scheduler jobs page, select MY_LWT_JOB, and click Delete.



O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-2: Creating Lightweight Scheduler Jobs (continued)
Oracle Database 11g: Administration Workshop II A-282
b) On the Confirmation page, select Drop the job and any running instance. Click
Yes.

O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-283
Practice 18-3: Monitoring the Scheduler
Background: Because your job tasks are regularly increasing, you decide to automate
routine tasks. First, you monitor existing scheduler elements, and then you create
scheduler components and test them.
In this practice, you use Enterprise Manager Database Control to define and monitor the
Scheduler and automate tasks. Regularly, click Show SQL 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:
CONNECT role
RESOURCE role
DBA role
Because you are going to use the HR user to administer jobs through Database Control,
you need to make sure that HR is registered as a possible administrator.
a. In Enterprise Manager, select Server > Users.
b. On the Users page, select the HR user and click Edit.
c. On the Edit User page, click the Roles tab. Then, click the Edit List button on the
right side of the page.
d. On the Modify Roles page, make sure that the DBA role, CONNECT role, and
RESOURCE role are selected. Click Apply.

e. Click the Setup link on the upper-right region of the page.
f. Click the Administrators link. On the Administrators page, click the Create
button.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-3: Monitoring the Scheduler (continued)
Oracle Database 11g: Administration Workshop II A-284
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.

j. Click the Logout link at the upper-right corner of the page.
2. Log in to Enterprise Manager Database Control as the HR user. On the Server tabbed
page, click the Jobs link in the Database Scheduler region. Are there any jobs?
a. Click the Login button to log in as the HR user.
b. For the username and password, enter HR, accept Connect As Normal, and click
Login.
c. In Enterprise Manager, select Server > Jobs in the Database Scheduler region.
Question: Are there any jobs?
Answer: There are some jobs.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-3: Monitoring the Scheduler (continued)
Oracle Database 11g: Administration Workshop II A-285

3. Review the Programs page in Enterprise Manager. Are there any existing programs?
(Hint: Use the browsers Back button).
a. In Enterprise Manager, select Server > Programs in the Database Scheduler
region.
Question: Are there any existing programs?
Answer: There are some existing programs.

4. Review the Scheduler Schedules page in Enterprise Manager. Are there any existing
schedules?
a. In Enterprise Manager, select Server > Schedules.
Question: Are there any existing schedules?
Answer: There are two schedules, DAILY_PURGE_SCHEDULE and
BSLN_MAINTAIN_STATS_SCHED.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-3: Monitoring the Scheduler (continued)
Oracle Database 11g: Administration Workshop II A-286

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?
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.
6. Review the Scheduler Job Classes page in Enterprise Manager. Are there any existing
job classes? If so, which resource consumer group is associated with each job class?
a. In Enterprise Manager, select Server > Job Classes.
Question 1: Are there any existing job classes?
Answer: There are many job classes.
b. Click the DEFAULT_JOB_CLASS link.
Question 2: Which resource consumer group is associated with the job class?
Answer: None.
c. Click OK, and then click the ORA$AT_JCURG_OS link.
Question 3: Which resource consumer group is associated with the job class?
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 18-3: Monitoring the Scheduler (continued)
Oracle Database 11g: Administration Workshop II A-287
Answer: ORA$AT_JCURG_OS is associated with
ORA$AUTOTASK_URGENT_GROUP.

d. Click OK, and then exit Enterprise Manager.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-288
Practices for Lesson 19
There are no practices for lesson 19.
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-289
Practices for Lesson 20


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

Oracle Database 11g: Administration Workshop II A-290
Practice 20-1: Using Globalization Support
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, date and time formats, and
for 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
b) Start the sqldeveloper executable.
$ ./sqldeveloper
c) If asked whether you would like to migrate settings from a previous release, click
No.
d) Right-click Connections, and select New Connection. Enter the following
information for the connection:
Connection Name: SYSTEM
Username: system
Password: oracle
Save Password: Check it
Role: default
SID: orcl
e) Click Save, and then click Connect. Enter any subsequent queries in the area at
the top of the window where it says 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.
SELECT SYSDATE FROM dual;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 20-1: Using Globalization Support (continued)
Oracle Database 11g: Administration Workshop II A-291

b. The year is not displayed using a four-digit year. Change your session to display a
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.
alter session set nls_language=FRENCH;
select sysdate from dual;

3) Import the WORDS table (which is in the words.dmp file). Run the
load_words.sh script to do this.
$ cd $HOME/labs
$ ./load_words.sh
Note that the script creates a table, called WORDS, with four rows.
4) In sqldeveloper, display the content of the WORDS table.
SELECT * FROM words;

5) 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;
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 20-1: Using Globalization Support (continued)
Oracle Database 11g: Administration Workshop II A-292

6) Next, 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;

7) Set NLS_SORT to FRENCH_M. 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_M;
SELECT * FROM words
ORDER BY fr_word;

8) 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');
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Practice 20-1: Using Globalization Support (continued)
Oracle Database 11g: Administration Workshop II A-293

9) Drop the table and also remove it from the recycle bin.
DROP TABLE words PURGE;
10) Exit SQL Developer by selecting File > Exit on the menu. If you are prompted with a
Save Files alert window, click No.


O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Index
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 2
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,
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,
3-27, 4-3, 4-5, 4-12, 4-13, 5-4, 5-6, 5-15, 5-17, 6-22, 6-25,
6-26, 7-5, 7-6, 7-14, 8-16, 12-11, 12-12, 12-20, 13-37
Archiver 1-11, 2-11, 2-12, 2-25
ARCn 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 2-11, 2-12, 14-13
ASM 1-1, 1-2, 1-11, 1-20, 1-21, 1-22, 1-23, 1-24, 1-25, 1-26,
1-27, 1-28, 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-43, 1-44, 1-45, 1-46, 1-47, 1-48,
8-17, 10-29, 13-4, 16-36
+ASM 1-24, 1-25
ASM Instance 1-20, 1-22, 1-23, 1-24, 1-25, 1-26, 1-27, 1-28, 1-29,
1-35, 1-37, 1-38, 1-39, 1-48, 13-4
ASM_DISKGROUPS 1-24, 1-25
ASM_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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 3
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
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,
10-29
BACKUP_TAPE_IO_SLAVES 10-16, 10-17, 10-18, 10-19, 10-32
Block 1-14, 1-15, 1-16, 1-18, 1-19, 1-30, 1-37, 1-44, 2-6, 2-9,
2-10, 3-24, 4-3, 4-6, 4-12, 5-4, 5-8, 5-9, 5-10, 5-11, 5-12,
5-13, 5-25, 5-26, 5-40, 6-23, 7-11, 7-14, 7-15, 7-25, 8-6, 8-8,
8-11, 10-10, 10-23, 10-26, 11-6, 12-8, 12-9, 13-28, 13-29, 13-32, 13-33,
13-35, 13-36, 13-37, 13-38, 13-39, 13-42, 13-45, 14-4, 14-5, 14-6, 14-7,
14-25, 14-36, 15-9, 16-7, 16-8, 17-6, 17-21, 18-4, 18-6, 18-8, 18-11,
18-12, 18-15
Block change tracking 4-6, 5-11, 5-12, 5-13, 5-40
Block corruption 13-32, 13-33, 13-36, 13-38, 13-45
Block Media Recovery 2-6, 13-36, 13-37, 13-38
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 4
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
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
CONTROL_FILE_RECORD_KEEP_TIME 2-22, 3-20, 7-13
CONTROL_FILES 7-19, 8-7
CORE_DUMP_DEST 13-4
Corruption 6-4, 9-7, 11-3, 13-2, 13-32, 13-33, 13-34, 13-35, 13-36,
13-38, 13-39, 13-45, 13-47, 13-48
CRS 13-4
CURSOR_SHARING 14-38, 14-39
D
Data block 1-15, 1-18, 4-3, 5-9, 13-28, 13-29, 13-32, 13-33, 13-38,
14-7, 16-8
Data dictionary cache 1-7, 14-10
Data file 1-12, 1-14, 1-16, 1-18, 1-22, 1-30, 2-11, 2-21, 2-24,
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 5
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
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
DB_UNIQUE_NAME 1-24
DBA 1-26, 1-34, 1-45, 2-29, 3-34, 5-26, 6-26, 10-10, 11-9, 11-10,
11-11, 11-12, 11-13, 11-15, 11-16, 11-37, 12-14, 12-29, 13-3, 13-28, 13-32,
14-8, 15-19, 15-42, 16-4, 16-13, 16-23, 16-25, 17-17, 17-25, 18-9, 18-11,
18-14, 18-18, 18-29, 19-14, 19-16, 19-17, 20-4
DBCA 1-23, 14-32
DBV 13-36
DBVERIFY 6-35, 13-38
DBWn 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 14-6, 14-7, 14-13
DBWR_IO_SLAVES 10-14, 10-19, 10-31, 10-32
DDL 11-16, 11-22, 11-25, 11-28, 12-7, 12-26, 12-30, 14-13, 15-39, 15-43,
16-22, 16-26, 20-30
Dedicated 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
E
Encoded character set 20-5, 20-7
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 6
E
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,
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,
20-31
EVENT 2-24, 3-3, 5-34, 13-7, 15-12, 15-13, 15-16, 15-17, 15-18, 16-21,
16-25, 18-2, 18-3, 18-5, 18-8, 18-10, 18-16, 18-17, 18-18, 18-19, 18-20,
18-22, 18-23, 18-25, 18-26, 18-30, 19-3
F
Factor 1-31, 1-45, 14-20
Flash recovery area 2-2, 2-11, 2-19, 2-20, 2-24, 2-25, 2-26,
2-27, 2-28, 2-29, 2-30, 2-31, 2-32, 2-33, 2-34, 2-35, 3-18, 4-4,
4-8, 5-6, 5-14, 5-20, 5-29, 7-17, 7-18, 12-8, 12-10, 12-12, 12-18,
12-19, 12-20, 12-22, 12-23
Flashback buffer 12-9
Flashback Database 2-11, 2-19, 2-25, 4-4, 11-3, 11-39, 12-2, 12-8,
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 7
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
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
Initialization parameters 1-8, 1-24, 2-15, 2-25, 2-26, 8-6,
8-7, 8-8, 9-12, 9-17, 10-18, 11-6, 14-15, 14-32, 15-10, 15-11, 20-15,
20-16, 20-17, 20-18
initorcl.ora 7-24
INSTANCE_TYPE 1-24, 1-25, 1-39
iot 16-13, 16-14, 16-20
J
Java pool 1-7, 1-8, 14-4, 14-5, 14-12, 14-21, 14-25
JAVA_POOL_SIZE 14-12, 14-15, 14-26, 14-28
job 1-11, 2-9, 2-10, 5-21, 5-24, 5-25, 5-37, 6-41, 7-5, 7-6,
8-19, 9-7, 10-5, 10-6, 10-7, 10-8, 10-9, 10-20, 10-33, 11-24, 14-3,
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 8
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
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
LOG_ARCHIVE_DUPLEX_DEST 2-15, 2-18
LOG_ARCHIVE_MIN_SUCCEED_DEST 2-17, 2-18
LOG_BUFFER 14-15, 14-25, 15-14
LOG_FILE_NAME_CONVERT 8-7
M
Media management library 2-19, 4-3, 4-4, 4-6, 5-14, 5-30, 5-40,
10-9
Memory Advisor 14-34, 14-35
Memory Manager 14-12, 14-22
Metric 2-32, 15-9, 15-16
MMAN 14-22
MML 2-19, 4-3, 4-6, 5-14, 5-30, 5-31, 5-32, 10-3
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 9
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
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
Oracle Locale Builder 20-28
Oracle Managed Files 4-4, 8-8, 16-3, 16-39
Oracle Net 8-5, 9-18, 20-9, 20-10
Oracle Shared Server 1-5, 14-10, 14-11
ORACLE_BASE 6-25, 6-27, 6-31, 12-12, 13-4
ORACLE_HOME 6-15, 6-16, 6-26, 9-19, 13-4, 13-31, 15-21
ORACLE_SID 1-25, 1-43, 3-9, 7-23
orcl 1-24, 1-43, 4-8, 6-6, 6-7, 6-24, 6-25, 6-26, 6-27, 6-31,
6-32, 7-23, 7-26, 8-7, 13-5, 13-6, 13-7, 13-38, 13-42, 13-43, 13-46
P
Package 13-3, 13-5, 13-9, 13-10, 13-11, 13-12, 13-16, 13-17, 13-21,
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 10
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,
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
PGA_AGGREGATE_TARGET 14-15, 14-16, 14-17, 14-32, 14-33
PMON 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22, 17-21
Private SQL area 14-5, 14-30
Privilege 1-27, 1-35, 3-30, 6-14, 6-15, 11-13, 12-4, 15-28, 16-23,
17-12, 18-6, 19-6
Proactive Tablespace Monitoring 16-9
Procedure 3-8, 3-35, 5-31, 7-17, 7-19, 7-21, 7-28, 11-28, 11-31,
11-35, 11-36, 13-30, 14-23, 14-39, 15-10, 15-20, 15-39, 15-40, 15-42, 15-43,
15-44, 16-25, 16-30, 16-37, 16-38, 17-11, 17-12, 17-21, 18-3, 18-5, 18-6,
18-7, 18-8, 18-11, 18-12, 18-13, 18-14, 18-15, 18-16, 18-17, 18-18, 18-19,
18-21, 18-22, 18-23, 18-28, 19-6, 19-9, 19-11, 19-12, 19-15, 20-19, 20-29
Profile 15-25, 15-26, 15-28
Program 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 11
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,
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,
14-4, 14-11, 14-12, 14-13, 15-14, 16-39, 18-13, 18-14
Redo log buffer 1-7, 1-8, 14-4, 14-13, 15-14
redo log groups 6-8
REMOTE_LOGIN_PASSWORDFILE 6-15
Resource Manager 17-2, 17-3, 17-4, 17-5, 17-6, 17-8, 17-10, 17-14,
17-17, 17-20, 17-22, 17-24, 17-25, 17-26, 17-27, 17-28, 17-29, 17-30, 19-4,
19-6
RESOURCE_MANAGER_PLAN 17-8, 17-24
restore point 5-20, 5-21, 5-22, 5-23, 6-20, 7-13, 7-14, 12-13,
12-19, 12-20, 12-21
Resumable space allocation 16-2, 16-21, 16-22, 16-23, 16-40
RESUMABLE_TIMEOUT 16-22
Retention 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 12
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,
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,
8-10, 8-11, 8-12, 8-13, 8-14, 8-21, 8-22, 9-3, 9-5, 9-6, 9-7,
9-12, 9-13, 9-15, 9-16, 9-17, 9-18, 9-19, 9-20, 10-1, 10-2, 10-3,
10-4, 10-5, 10-6, 10-7, 10-8, 10-9, 10-10, 10-11, 10-12, 10-13, 10-14,
10-16, 10-17, 10-18, 10-20, 10-23, 10-26, 10-27, 10-29, 10-31, 10-32, 10-33,
10-34, 10-35, 10-36, 12-12, 12-13, 13-36, 13-37, 13-38, 13-39, 13-40, 13-41,
13-42, 13-43, 13-44, 13-45, 16-30, 16-37, 16-38, 18-11, 18-18
RMAN Repository 3-2, 3-3, 3-17, 3-27, 3-28, 3-36, 4-5, 4-7,
5-34, 5-38, 7-22
Role 1-26, 1-28, 3-8, 17-12, 19-17
Rule 10-23, 18-16, 18-23, 18-25, 18-27, 18-29
Rule set 18-29
S
Scheduler 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 13
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
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
SESSIONS 1-5, 10-3, 10-4, 10-5, 10-6, 13-44, 14-7, 14-10, 14-32,
15-2, 15-4, 15-8, 15-12, 15-13, 15-14, 15-15, 15-16, 15-17, 15-39, 15-42,
15-46, 15-47, 16-11, 16-23, 17-3, 17-4, 17-5, 17-6, 17-9, 17-11, 17-13,
17-14, 17-15, 17-17, 17-18, 17-21, 17-22, 17-26, 17-27, 17-28, 18-4, 20-2,
20-16, 20-35
SGA 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-19, 5-11, 10-16, 10-31,
12-9, 14-2, 14-4, 14-6, 14-8, 14-11, 14-12, 14-14, 14-15, 14-16, 14-17,
14-18, 14-19, 14-20, 14-21, 14-22, 14-23, 14-24, 14-25, 14-26, 14-27, 14-28,
14-29, 14-30, 14-33, 14-34, 14-36, 14-37, 14-40, 15-14, 15-20
SGA_MAX_SIZE 14-15, 14-16, 14-17, 14-23, 14-27
SGA_TARGET 1-8, 14-15, 14-16, 14-17, 14-21, 14-23, 14-24, 14-25, 14-26,
14-27, 14-28, 14-29
Shared 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 14
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,
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,
15-9, 15-10, 15-11, 15-12, 15-13, 15-14, 15-16, 15-17, 15-18, 15-19, 15-20,
15-22, 15-23, 15-26, 15-28, 15-32, 15-37, 16-15, 16-18, 17-6, 17-8, 17-20,
17-26, 17-27, 18-3, 18-6
STATISTICS_LEVEL 10-7, 15-9, 15-11, 15-14
Statspack 15-21
Streams pool 1-7, 1-8, 14-4, 14-5, 14-21, 14-25
STREAMS_POOL_SIZE 14-15, 14-26, 14-28
SYSAUX 1-17, 6-7, 6-24, 6-26, 7-26, 12-17, 15-20
SYSDBA 1-12, 1-26, 1-27, 1-28, 1-35, 3-33, 3-34, 3-35, 6-14, 6-15,
6-16, 11-13, 11-27, 11-29, 12-29
SYSOPER 1-12, 1-27, 1-28, 3-33, 3-35, 6-14, 6-15, 6-16
System privilege 6-14, 11-13, 12-4, 15-28, 16-23
System 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 15
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,
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,
3-28, 3-30, 3-31, 3-32, 3-33, 3-34, 3-35, 4-5, 4-9, 5-31, 5-36,
7-21, 7-22, 7-27, 7-28, 8-3, 8-4, 8-5, 8-6, 8-7, 8-10, 8-11,
8-12, 8-14, 9-5, 9-6, 9-16, 9-17, 10-5, 13-37, 13-42, 16-28, 16-29,
16-36, 20-30, 20-32
temporary tablespace 1-14, 1-15, 3-8, 6-5, 6-7, 9-4, 9-19,
16-11
Temporary tablespace 1-14, 1-15, 3-8, 6-5, 6-7, 9-4, 9-19,
16-11
THREAD 1-6, 6-42, 10-5, 10-22, 12-13, 15-12
Threshold 11-6, 16-10, 16-11, 16-18, 16-41, 17-5, 17-13, 17-20, 18-19
TIMED_STATISTICS 15-14
Trace Files 1-12, 1-13, 13-5, 13-6, 13-7, 13-22, 13-24, 13-38
TRANSACTIONS 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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 16
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
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
V$BACKUP_SET 5-25, 5-36
V$BACKUP_SYNC_IO 10-20, 10-22
V$BGPROCESS 1-11, 15-18
V$BLOCK_CHANGE_TRACKING 5-13
V$BUFFER_POOL 15-18
V$BUFFER_POOL_STATISTICS 15-18
V$CONTROLFILE 6-24
V$DATABASE 3-15, 7-23, 12-10, 12-22, 13-36, 13-38, 15-18, 16-31
V$DATABASE_BLOCK_CORRUPTION 13-36, 13-38
V$DATAFILE 5-36, 6-24, 6-30, 6-32, 7-25, 15-18
V$DATAFILE_COPY 5-36
V$DBFILE 15-18
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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 17
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
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
V$RSRC_CONSUMER_GROUP 17-27, 17-28
V$RSRC_PLAN 17-27
V$SEGMENT_STATISTICS 15-18
V$SERVICE_EVENT 15-17
V$SERVICE_WAIT_CLASS 15-17
V$SESSION 10-5, 10-6, 10-7, 15-16, 16-25, 17-27, 17-28
V$SESSION_EVENT 15-16
V$SESSION_LONGOPS 10-7
V$SESSION_WAIT 15-16, 16-25
V$SESSMETRIC 15-16
V$SESSTAT 14-33, 15-16, 17-27
V$SGA 14-23, 14-24
V$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
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y
Oracle Database 11g: Administration Workshop II Index - 18
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
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
Wait event 15-12
window groups 19-2, 19-17, 19-18
Work area 1-15, 1-31, 14-31, 14-33
Workload repository 15-18, 15-20, 15-21, 16-3, 16-9, 16-15
O
r
a
c
l
e

I
n
t
e
r
n
a
l

&

O
A
I

U
s
e

O
n
l
y

You might also like