Documente Academic
Documente Profesional
Documente Cultură
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
t r a ns
Oracle Database 11g: o n -
Administrations Workshopan II
h a ฺ
m ) u i de
o tG
ilฺIIc• Student
g m tuden Guide
a
Volume
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
D50079GC12
Edition 1.2
April 2009
D59863
Computer Pride Limited
Tom Best This document contains proprietary information and is protected by copyright and
Donna Keesling other intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered in
James Spiller any way. Except where your use constitutes "fair use" under copyright law, you may
not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Maria Billings
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
license, post, transmit, or distribute this document in whole or in part without the
Gwen Lazenby express authorization of Oracle.
The information contained in this document is subject to change without notice. If you
Technical Contributors find any problems in the document, please report them in writing to: Oracle University,
and Reviewers 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Sharath Bhujani
Restricted Rights Notice
Timothy Chien
Al Flournoy If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Andy Fortunak applicable:
Gerlinde Frenzen
U.S. GOVERNMENT RIGHTS
ble
Joel Goodman The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
fe r a
Magnus Isaksson license agreement and/or the applicable U.S. Government contract.
an s
Pete Jones
n - t r
no
Trademark Notice
Pierre Labrousse
Jerry Lee s a
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
h a eฺ
names may be trademarks of their respective owners.
)
Hakan Lindfors
m i d
Isabelle Marchand
i l ฺ co nt Gu
Srinivas Putrevu
m a de
Andreas Reinhardt
i @ g S tu
Ira Singer
s y uk this
( M a use
Editors
y u ki se to
Arijit Ghosh as en
M
y Narasimhan
Vijayalakshmi l i c
l e
n Narayan
Sta
Amitha
Atanu Raychaudhuri
Richard Wallis
Graphic Designer
Rajiv Chandrabhanu
Publishers
Pavithran S Adka
Nita Brozowski
Jobi Varghese
Giri Venugopal
Computer Pride Limited
Contents
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
yM li
SYSASM Role 1-26
nle Accessing an ASM Instance 1-27
Sta Using Enterprise Manager to Manage ASM Users 1-28
Shutting Down an ASM Instance 1-29
ASM Storage: Concepts 1-30
ASM Disk Group 1-31
Failure Group 1-33
Disk Group Mirroring 1-34
Disk Group Dynamic Rebalancing 1-35
Managing Disk Groups 1-36
Creating and Dropping Disk Groups 1-37
Adding Disks to Disk Groups 1-38
ASM Disk Group Compatibility 1-39
ASM Disk Group Attributes 1-41
Using Enterprise Manager to Edit Disk Group Attributes 1-42
iii
Computer Pride Limited
iv
Computer Pride Limited
a syu cense
Summary 3-36
yM li
Practice 3 Overview: Using the RMAN Recovery Catalog 3-37
nle
Sta 4 Configuring Backup Specifications
Objectives 4-2
Using RMAN to Create Backups 4-3
Backup Destinations 4-4
Configuring Persistent Settings for RMAN 4-5
Using Enterprise Manager to Configure RMAN Settings 4-6
Control File Autobackups 4-7
Managing Persistent Settings 4-9
Configuring Devices for Backup 4-10
Configuring and Allocating Channels for Use in Backups 4-12
Configuring Backup Optimization 4-13
Summary 4-15
Practice 4 Overview: Configuring Backup Specifications 4-16
v
Computer Pride Limited
syu cense
Using a Media Manager 5-30
a
yM li
Performing Proxy Copies 5-32
n le
Creating an Oracle-Suggested Backup 5-33
Sta Managing Backups: Reporting 5-34
Managing Backups: Dynamic Performance Views 5-36
Using Enterprise Manager to View Backup Reports 5-37
Managing Backups: Cross-Checking and Deleting 5-38
Summary 5-39
Practice 5 Overview: Creating Backups 5-40
vi
Computer Pride Limited
a syu cense
Choosing an Incomplete Recovery Method 6-37
yM li
Performing User-Managed Incomplete Recovery 6-38
nle Performing User-Managed Incomplete Recovery: Steps 6-40
Sta User-Managed Time-Based Recovery: Example 6-41
User-Managed Cancel-Based Recovery: Example 6-43
Recovering a Read-Only Tablespace 6-45
Recovering NOLOGGING Database Objects 6-46
Recovering from the Loss of All Control File Copies: Overview 6-47
Recovering the Control File to the Default Location 6-48
Summary 6-49
Practice 6 Overview: Performing User-Managed Recovery 6-50
vii
Computer Pride Limited
viii
Computer Pride Limited
Summary 8-21
Practice 8 Overview: Using RMAN to Duplicate a Database 8-22
Objectives 9-2
Tablespace Point-in-Time Recovery (TSPITR): Concepts 9-3
Tablespace Point-in-Time Recovery (TSPITR): Terminology 9-4
Tablespace Point-in-Time Recovery: Architecture 9-5
When to Use TSPITR 9-7
Preparing for TSPITR 9-8
Determining the Correct Target Time 9-9
Determining the Tablespaces for the Recovery Set 9-10
Identifying Objects That Will Be Lost 9-11
Performing Basic RMAN TSPITR 9-12 ble
Performing Fully Automated TSPITR 9-13 fe r a
ans
Using Enterprise Manager to Perform TSPITR 9-14
n - t r
RMAN TSPITR Processing 9-15
a no
s
Performing RMAN TSPITR with an RMAN-Managed Auxiliary Instance 9-17
a
) h d eฺ
Performing RMAN TSPITR Using Your Own Auxiliary Instance 9-18
i
m
co nt Gu
Troubleshooting RMAN TSPITR 9-19
i l ฺ
Summary 9-20
g ma tude
u k i@ is S
Practice 9 Overview: Performing TSPITR 9-21
a sy se th
10 Monitoring and
i (M u
Tuning RMAN
t o
k
yu 10-2
Objectives se
a s e n
y M l ic of Backup Sets 10-3
Parallelization
ix
Computer Pride Limited
syu cense
Flashback Query: Example 11-18
a
yM li
Flashback Version Query 11-19
n le
Using Enterprise Manager to Perform Flashback Version Query 11-20
Sta Flashback Version Query: Considerations 11-21
Flashback Transaction Query 11-22
Using Enterprise Manager to Perform Flashback Transaction Query 11-23
Flashback Transaction Query: Considerations 11-24
Flashback Transaction 11-25
Prerequisites 11-26
Flashing Back a Transaction 11-27
Possible Workflow 11-28
Viewing Data 11-29
Flashback Transaction Wizard 11-30
Choosing Other Back-out Options 11-34
Final Steps Without EM 11-36
x
Computer Pride Limited
Summary 11-37
Practice 11 Overview: Performing Flashback Database 11-38
Objectives 12-2
Flashback Table: Overview 12-3
Flashback Table 12-4
Enabling Row Movement on a Table 12-5
Performing Flashback Table 12-6
Flashback Table: Considerations 12-7
Flashback Database 12-8
Flashback Database Architecture 12-9
Configuring Flashback Database 12-10
Configuring Flashback Database Using EM 12-11 ble
Flashback Database: Examples 12-13 fe r a
ans
Performing Flashback Database Using EM 12-14
n - t r
Flashback Database Considerations 12-17
a no
Monitoring Flashback Database 12-18
a s
) h
Monitoring Flashback Database with EM 12-20 i d eฺ
m
co nt Gu
i l ฺ
Guaranteed Restore Points 12-21
ma tude
Flashback Database and Guaranteed Restore Points 12-22
g
u k i@ is S
Flashback Data Archive 12-24
sy se th
Flashback Data Archive Process 12-25
a
k i (M to u
Flashback Data Archive Scenario 12-26
syu cense
Viewing Flashback Data Archives 12-28
a
yM li
Flashback Data Archive DDL Restrictions 12-29
xi
Computer Pride Limited
syu cense
Verifying Block Integrity in Real Time: DB_BLOCK_CHECKING 13-39
a
yM li
Block Media Recovery 13-40
le
Prerequisites for Block Media Recovery 13-41
n
Sta The RECOVER...BLOCK Command 13-42
Data Recovery Advisor 13-43
Data Recovery Advisor: RMAN Command-Line Interface 13-44
Listing of Data Failures 13-45
Advising on Repair 13-47
Executing Repairs 13-48
Classifying (and Closing) Failures 13-49
Data Recovery Advisor Views 13-50
Summary 13-51
Practice 13 Overview: Diagnosing the Database 13-52
14 Managing Memory
Objectives 14-2
Memory Management: Overview 14-3
xii
Computer Pride Limited
syu cense
Enabling Automatic Memory Management with EM 14-33
a
yM li
Monitor Automatic Memory Management 14-34
xiii
Computer Pride Limited
syu cense
System Architecture: Capture 15-39
a li
System Architecture: Processing the Workload 15-40
yM
le
System Architecture: Replay 15-41
n
Sta The Big Picture 15-42
Workloads Supported 15-43
Using Enterprise Manager for Workload Capture 15-44
Using Enterprise Manager for Workload Replay 15-45
Summary 15-46
Practice 15 Overview: Monitor Instance Performance 15-47
16 Space Management
Objectives 16-2
Space Management: Overview 16-3
Free Space Management Within Segments 16-4
Types of Segments 16-5
Allocating Extents 16-6
Block Space Management 16-7
xiv
Computer Pride Limited
syu cense
Database Transportation Procedure: Source System Conversion 16-37
a
yM li
Database Transportation Procedure: Target System Conversion 16-38
17 Managing Resources
Objectives 17-2
Database Resource Manager: Overview 17-3
Database Resource Manager: Concepts 17-4
Why Use Resource Manager 17-5
Accessing Resource Plans 17-7
Default Maintenance Resource Manager Plan 17-8
Example: DEFAULT_PLAN 17-9
Creating a New Resource Plan 17-10
Creating Consumer Groups 17-11
Assigning Users to Consumer Groups 17-12
xv
Computer Pride Limited
syu cense
Creating a Time-Based Job 18-11
a li
Persistent Lightweight Jobs 18-13
yM
le
Choosing the Right Job 18-14
n
Sta Creating a Single Lightweight Job 18-16
Creating an Event-Based Schedule 18-17
Creating Event-Based Schedules with Enterprise Manager 18-18
Creating an Event-Based Job 18-19
Event-Based Scheduling 18-20
Creating Complex Schedules 18-22
Creating Job Chains 18-23
Example of a Chain 18-25
1. Creating a Chain Object 18-26
2. Defining Chain Steps 18-27
3. Defining Chain Rules 18-28
4. Starting the Chain 18-29
Monitoring Job Chains 18-30
xvi
Computer Pride Limited
Summary 18-31
Practice 18 Overview: Automating Tasks with the Scheduler 18-32
Objectives 19-2
Advanced Scheduler Features 19-3
Job Classes 19-4
Creating a Job Class 19-6
Windows 19-7
Creating a Window 19-8
Prioritizing Jobs Within a Window 19-10
Creating an Array of Lightweight Jobs 19-11
Creating Lightweight Jobs 19-12
Viewing Lightweight Jobs in Dictionary 19-14 ble
PL/SQL APIs 19-15 fe r a
ans
Generic Scheduler Data Dictionary Views 19-16
n - t r
Summary 19-18
a no
a s
20 Globalization ) h i d eฺ
m
co nt Gu
Objectives 20-2
i l ฺ
ma tude
Globalization Support Features 20-3
g
What Every DBA Needs to Know
u k i@ 20-4is S
sy 20-5
What Is a Character Set?
a e th
M to20-7
Understanding (Unicode
i us
How Arey k sSets
uCharacter e Used? 20-9
a s
Problems toic e n
Avoid 20-10
y M l
nle Another Sample Problem 20-11
Sta Choosing Your Character Set 20-12
Database Character Sets and National Character Sets 20-13
Obtaining Character Set Information 20-14
Specifying Language-Dependent Behavior 20-15
Specifying Language-Dependent Behavior for the Session 20-16
Language-Dependent and Territory-Dependent Parameters 20-17
Specifying Language-Dependent Behavior 20-19
Linguistic Searching and Sorting 20-20
Using Linguistic Searching and Sorting 20-22
Case-Insensitive and Accent-Insensitive Search and Sort 20-24
Support in SQL and Functions 20-25
Linguistic Index Support 20-26
Customizing Linguistic Searching and Sorting 20-27
Implicit Conversion Between CLOB and NCLOB 20-29
xvii
Computer Pride Limited
Summary 20-35
Practice 20 Overview: Using Globalization Support 20-36
Appendix A
Index
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
xviii
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Tuning Activities
• Performance planning
• Instance tuning
• SQL tuning
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tuning Activities k i
a s yu ense
The three facets
M of tuningic
involve performance planning, instance tuning, and SQL tuning.
y l
t a nle system,
• Performance
operating
planning is the process of establishing the environment: the hardware, software,
network infrastructure, and so on.
S
• Instance tuning is the actual adjustment of Oracle database parameters and operating system
(OS) parameters to gain better performance of the Oracle database.
• SQL tuning involves making your application submit efficient SQL statements. SQL tuning is
performed for the application as a whole, as well as for individual statements. At the application
level, you want to be sure that different parts of the application are taking advantage of each
other’s work and are not competing for resources unnecessarily. In this lesson, you learn about
some common actions that you can take to tune specific SQL statements.
Note: For more information about performance tuning, refer to the Oracle Database Performance
Tuning Guide.
Performance Planning
• Investment options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• System architecture
• Scalability
• Application design principles
• Workload testing, modeling, and implementation
• Deploying new applications
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performance Planning k i
a s yu ense
y l ic
There are manyMfacets to performance planning. Planning must include a balance between
t a nle the
performance
architecture:
(speed), cost, and reliability. You must consider the investment in your system
hardware and software infrastructure needed to meet your requirements. This, of
S
course, requires analysis to determine the value for your given environment, application, and
performance requirements. For example, the number of hard drives and controllers has an impact on
the speed of data access.
The ability of an application to scale is also important. This means that you are able to handle more
and more users, clients, sessions, or transactions, without incurring a huge impact on overall system
performance. The most obvious violator of scalability is serializing operations among users. If all
users go through a single path one at a time, then as more users are added, there are definitely
adverse effects on performance. This is because more and more users line up to go through that path.
Poorly written SQL also affects scalability. It requires many users to wait for inefficient SQL to
complete; each user competing with the other on a large number of resources that they are not
actually in need of.
The principles of application design can greatly affect performance. Simplicity of design, use of
views and indexes, and data modeling are all very important.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Instance Tuning
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Instance Tuning k i
a s yu ense
At the start of any
y M l c
tuning iactivity, it is necessary to have specific goals. A goal such as “Process 500
e
nlwe’ll
sales transactions per minute” is easier to work toward than one that says, “Make it go as fast as you
can,
S t a
and know when it’s good enough.”
You must allocate Oracle database memory suitably for your application to attain optimum
performance. You have a finite amount of memory to work with. Too little memory allotted to
certain parts of the Oracle database can cause inefficient background activity, which you may not
even be aware of without doing some analysis.
Disk I/O is often the bottleneck of a database and, therefore, requires a lot of attention at the outset of
any database implementation.
The operating system configuration can also affect the performance of an Oracle database. For more
information, see the Oracle Database Installation Guide for your particular platform.
t a nletheisOS
1. Check
problem in
statistics and general machine health before tuning the instance to be sure that the
the database. Use the Enterprise Manager database home page.
S2. Tune from the top down. Start with the design, then the application, and then the instance. For
example, try to eliminate the full tables scans causing the I/O contention before tuning the
tablespace layout on disk. This activity often requires access to the application code.
3. Tune the area with the greatest potential benefit. The tuning methodology presented in this
course is simple. Identify the biggest bottleneck and tune it. Repeat this step. All the various
tuning tools have some way to identify the SQL statements, resource contention, or services that
are taking the most time. The Oracle database provides a time model and metrics to automate
the process of identifying bottlenecks. The Advisors available in Oracle Database 11g use
precisely this methodology.
4. Stop tuning when you meet your goal. This step implies that you set tuning goals.
This is a general approach to tuning the database instance and may require multiple passes.
Performance Monitoring
• Cumulative statistics:
– Wait events with time information
– Time model
• Metrics: Statistic rates
• Sampled statistics: Active session history
– Statistics by session
– Statistics by SQL ble
fe r a
– Statistics by service
ans
– Other dimensions n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Performance Tuning u k
Data i (M e to u
a y ens
sserver
The Oracle database
y M l icsoftware captures information about its own operation. Three major types
t a nlecollected: cumulative statistics, metrics, and sampled statistics.
of data are
S
Cumulative statistics are counts and timing information of a variety of events that occur in the
database server. Some are quite important, such as buffer busy waits. Others have little impact on
tuning, such as index block split. The most important events for tuning are usually the ones showing
the greatest cumulative time values. The statistics in Oracle Database 11g are correlated by the use of
a time model. The time model statistics are based on a percentage of DB time, giving them a
common basis for comparison.
Metrics are statistic counts per unit. The unit could be time (such as seconds), transaction, or session.
Metrics provide a base to proactively monitor performance. You can set thresholds on a metric
causing an alert to be generated. For example, you can set thresholds for when the reads per
millisecond exceed a previously recorded peak value or when the archive log area is 95% full.
Sampled statistics are gathered automatically when STATISTICS_LEVEL is set to TYPICAL or
ALL. Sampled statistics allow you to look back in time. You can view session and system statistics
that were gathered in the past, in various dimensions, even if you had not thought of specifying data
collection for these beforehand.
statistics
• Optimizer statistics:
– Object statistics
– Operating system statistics
• Ways to collect statistics:
– Automatically: Automatic Maintenance Tasks
– Manually: DBMS_STATS package
ble
– By setting database initialization parameters fe r a
ans
– By importing statistics from another database n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Optimizer Statistics Collectionk i
a s yu ense
Optimizer statistics
y M l ic
are collections of data that are specific details about database objects. These
t a n eThese
statistics lare
statement.
essential for the query optimizer to choose the best execution plan for each SQL
statistics are gathered periodically and do not change between gatherings.
S
The recommended approach to gathering optimizer statistics is to allow the Oracle database to
automatically gather the statistics. The Automatic Maintenance Tasks can be created automatically at
database creation time and is managed by the Scheduler. It gathers statistics on all objects in the
database that have either missing or stale optimizer statistics by default. You can change the default
configuration through the Automatic Maintenance Tasks page.
System statistics describe the system’s hardware characteristics, such as I/O and CPU performance
and utilization, to the query optimizer. When choosing an execution plan, the optimizer estimates the
I/O and CPU resources required for each query. System statistics enable the query optimizer to more
accurately estimate I/O and CPU costs, and thereby choose a better execution plan. System statistics
are collected using the DBMS_STATS.GATHER_SYSTEM_STATS procedure. When the Oracle
database gathers system statistics, it analyzes system activity in a specified period of time. System
statistics are not automatically gathered. Oracle Corporation recommends that you use the
DBMS_STATS package to gather system statistics.
You can also manage optimizer and system statistics collection through database initialization
parameters. For example:
• The OPTIMIZER_DYNAMIC_SAMPLING parameter controls the level of dynamic sampling
performed by the optimizer. You can use dynamic sampling to estimate statistics for tables and
relevant indexes when they are not available or are too out of date to trust. Dynamic sampling
also estimates single-table predicate selectivity when collected statistics cannot be used or are
likely to lead to significant errors in estimation.
• The STATISTICS_LEVEL parameter controls all major statistics collections or advisories in
the database and sets the statistics collection level for the database. The values for this parameter
are BASIC, TYPICAL, and ALL. You can query the V$STATISTICS_LEVEL view to ble
determine which parameters are affected by the STATISTICAL_LEVEL parameter. fera
Note: Setting STATISTICS_LEVEL to BASIC disables many automatic features a s is not
nand
t r
recommended. on-
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
le y
n
Sta
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Oracle Wait Events uki
a s y ense
Wait events areM
y c are incremented by a server process or thread to indicate that it had to
statistics ithat
l
a leevent to complete before being able to continue processing. Wait event data reveals
wait for an
nsymptoms
S t
various of problems that might be impacting performance, such as latch contention, buffer
contention, and I/O contention. Remember that these are only symptoms of problems, not the actual
causes.
Wait events are grouped into classes. The wait event classes include: Administrative, Application,
Cluster, Commit, Concurrency, Configuration, Idle, Network, Other, Scheduler, System I/O, and
User I/O.
There are more than 800 wait events in the Oracle database, including free buffer wait,
latch free, buffer busy waits, db file sequential read, and db file
scattered read.
Using EM, you can view wait events by opening the Performance page and viewing the “Average
Active Sessions” graph, as shown in the slide. By clicking the link for a particular wait event class,
you can drill down to the specific wait events by using the Top Activity interface. In this example,
there was a very small set of buffer busy waits.
For a list of the most common Oracle events, refer to the Oracle Database Reference 11g
documentation.
Instance Statistics
V$EVENT_NAME
V$SYSTEM_EVENT
• event_number
• event
a b le
• event_id
• total_waits
s fer
• total_timeouts tran
• name
• parameter1
• time_waitednon
-
• parameter2 a
s
• average_wait
a
) h ideฺ
• parameter3
• time_waited_micro
• wait_class
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Instance Statistics uki e to
y
as performance s
en problems, statistics must be available. The Oracle database
To effectively M
diagnose
l i c
l ey many types of cumulative statistics for the system, sessions, and individual SQL
instance generates
n
Sta at the instance level. The Oracle database also tracks cumulative statistics on segments
statements
and services. When analyzing a performance problem in any of these scopes, you typically look at
the change in statistics (delta value) over the period of time you are interested in.
Note: Instance statistics are dynamic and are reset at every instance startup. These statistics can be
captured at a point in time and held in the database in the form of snapshots.
Wait Events Statistics
All the possible wait events are cataloged in the V$EVENT_NAME view.
Cumulative statistics for all sessions are stored in V$SYSTEM_EVENT, which shows the total waits
for a particular event since instance startup.
When you are troubleshooting, you need to know whether a process has waited for any resource.
Systemwide Statistics
All the systemwide statistics are cataloged in the V$STATNAME view: Over 400 statistics are
available in Oracle Database 11g.
The server displays all calculated system statistics in the V$SYSSTAT view. You can query this view
to find cumulative totals since the instance started.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Monitoring Session Performancei
a s yu ense
Enterprise Manager
y M l ic session detail pages so that you can view the wait events occurring in
provides
individuallesessions. On the Performance tabbed page, click Top Activity to view the summary of all
tan In the lower right corner of the Top Activity page is a listing of the Top Sessions. Click the
sessions.
S
session identifier to view the Session Details page.
The Top Activity page and Session Details page are based on performance view in the database.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Displaying Service-Related k i t o
Statistics
a s yu ense
In an n-tier environment
y M l ic there is an application server that is pooling database connections,
where
a le may not provide the information you need to analyze performance. Grouping
viewing sessions
ninto
S t
sessions service names enables you to monitor performance more accurately. These two views
provide the same information that their like-named session counterparts provide, except that the
information is presented at the service level rather than at the session level.
V$SERVICE_WAIT_CLASS shows wait statistics for each service, broken down by wait class.
V$SERVICE_EVENT shows the same information as V$SERVICE_WAIT_CLASS, except that it is
further broken down by event ID.
Enterprise Manager also provides aggregation by service and by module and service. You can click
the legend in each of the views, to view the activity and statistics for each service.
You can define a service in the database by using the DBMS_SERVICE package and use the net
service name to assign applications to a service.
Instance/Database Disk
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
V$DATABASE V$DATAFILE
V$INSTANCE V$FILESTAT
V$PARAMETER V$LOG
V$SPPARAMETER V$LOG_HISTORY
V$SYSTEM_PARAMETER V$DBFILE
V$PROCESS V$TEMPFILE
V$BGPROCESS V$TEMPSEG_USAGE
V$PX_PROCESS_SYSSTAT V$SEGMENT_STATISTICS
V$SYSTEM_EVENT
ble
Contention fe r a
Memory V$LOCK ans
n - t r
V$BUFFER_POOL_STATISTICS V$UNDOSTAT o
V$LIBRARYCACHE V$WAITSTAT an
V$SGAINFO V$LATCH has eฺ
m ) i d
V$PGASTAT
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Troubleshooting andu k i (MViews
Tuning t o
a s y ense
some of theicviews you may need to access to determine the cause of performance
The slide lists M
problemsle y l
or analyze the current status of your database. Many of these views show the same data that
isS tanin creating the reports that the Enterprise Manager produces from the Automatic Workload
used
Repository (AWR). In some cases, the raw data is needed to fully diagnose a problem.
For a complete description of these views, refer to the Oracle Database Reference Manual.
Dictionary Views
ADDM finds
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
MMON
top problems.
SYSAUX
SGA
6:00 AM
Snapshot 1
In-memory 7:00 AM
Snapshot 2
statistics 8:00 AM e
9:00 AM
Snapshot 3
r a bl
Snapshot 4 s fe
- t r an
n no
s a
) h a eฺ
9:30 AM m i d
i l ฺ co nt Gu
g ma tude
Copyright k
u i@ Oracle.isAllSrights reserved.
sy se th
© 2009,
a
Automatic Workload u k i (M e to u
Repository
The AutomaticM Workload ens (AWR) is a collection of persistent system performance
asy licRepository
ey by SYS. The AWR resides in the SYSAUX tablespace.
statistics lowned
n
AS ta is a set of performance statistics captured at a certain time and stored in the AWR. Each
snapshot
snapshot is identified by a snapshot sequence number (snap_id) that is unique in the AWR. By
default, snapshots are generated every 60 minutes. You can adjust this frequency by changing the
snapshot INTERVAL parameter. Because the database advisors rely on these snapshots, be aware
that adjustment of the interval setting can affect diagnostic precision. For example, if the INTERVAL
is set to 4 hours, you may miss transient events that would be noticeable in 60-minute intervals.
You can use the DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS stored
procedure or Database Control to change the settings that control snapshot collection. In Database
Control, click Automatic Workload Repository in the Statistics Management region of the Server
tabbed page. Then click Edit to make the changes. The stored procedure offers more flexibility in
defining INTERVAL values than does Database Control.
You can take manual snapshots by using Database Control or the
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT stored procedure. Taking manual
snapshots is supported in conjunction with the automatic snapshots that the system generates. Manual
snapshots are expected to be used when you want to capture the system behavior at two specific
points in time that do not coincide with the automatic schedule.
collection, and reporting. Statspack snapshots can be marked for retention, as part of a Statspack
baseline, or purged with provided scripts.
Statspack is documented in the $ORACLE_HOME/rdbms/admin/spdoc.txt file.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
SQL Tuning
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Tuning k i
a s yu ense
Generally, the M
y
tuning effort
l icthat yields the most benefit is SQL tuning. Poorly tuned SQL uses more
resourcesle
and t a n thanresponse
increases
required. This inefficiency prevents scalability, uses more OS and database resources,
time. To tune poorly tuned SQL statements, they must be identified, and then
S
tuned. SQL statements can be tuned individually, but often the solution that optimizes one statement
can hurt the performance of several others.
The SQL statements that use the most resources are by definition the statements in need of tuning.
These are statements that have the longest elapsed time, use the most CPU, or do the most physical
or logical reads.
Tune the individual statements by checking the optimizer statistics, check the explain plan for the
most efficient access path, test alternate SQL constructions, and test possible new indexes,
materialized views, and partitioning.
Test the application as a whole, using the tuned SQL statements. Is the overall performance better?
The methodology is sound, but tedious. Tuning an individual statement is not difficult. Testing the
overall impact of the individual statement tuning on an application can be very difficult.
In Oracle Database 11g, a set of SQL advisors are available to identify and tune statements,
individually or as a set.
SQL Advisors
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Advisors k i
a s yu ense
Oracle Database
y M l ic a set of advisors for SQL: the SQL Access Advisor, the SQL Tuning
11g provides
t a n eSQLthestatements.
Advisor, land
high-load
SQL Repair Advisor. The AWR identifies and records statistics about the recent
S
The SQL Tuning Advisor analyzes one or more SQL statements one at a time. It examines statistics,
SQL profiles, indexes, materialized views, and restructured SQL. The SQL Tuning Advisor can be
run manually at any time, but it is run during every maintenance window against the recent high-load
SQL statements. Click Automatic SQL Tuning Results to view and implement the recommendations.
This automatic job can be configured to automatically implement recommended SQL profiles for the
high-load statements.
The SQL Access Advisor considers changes applied to a set of SQL statements and looks for a net
gain in performance. This set can be a hypothetical set of SQL, a historical set, or a manually created
set.
The SQL Repair Advisor is run from the Support Workbench when a SQL statement fails with a
critical error. A critical error also produces an incident. The repair advisor attempts to find and
recommend a SQL patch. If no patch is found, you can continue in the Support Workbench to
package the incident and submit the package to Oracle Support as a Service Request (SR).
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Automatic SQL Tuning k i
Results
a s yu ense
The AutomaticM
y
SQL Tuning
l ic Task runs by default every night. The Automatic SQL Tuning Results
that t a
were
nleexamined
link shows the result summary page. If you click View Report, each of the distinct SQL statements
can be viewed.
S
Clicking the Configure button displays a page where you can change the defaults of the Automatic
Tuning Task and enable automatic implementation of SQL profiles.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Implement AutomaticuTuning k i (M Recommendations
t o
a s y ense
If you click View
y M l c the Automatic Tuning Results Summary page, you will see the
Report ion
Automatic
a leSQL Tuning Result Details. You can implement all the recommendations or drill down to
nimplement
view
S t or individual recommendations. On the Recommendations page, you can click the
eyeglass icon on the right to see the differences that implementing a SQL profile will make in the
explain plan.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
SQL Tuning Advisor Options k i
a s yu ense
On the Schedule
y M SQL Tuning
l ic Advisor page, you can choose the SQL statements to include and
a nlebeen
change the
you thave
automatic defaults for a tuning task. You can set the source of the SQL statements, and if
granted the ADVISOR system privilege, you can submit the task. Enterprise Manager
S
then creates a tuning task for the SQL Tuning Advisor.
The SQL statement options allow you to choose one or more SQL statements from recent Top
Activity, choose Historical SQL stored in the AWR, or choose from a SQL Tuning Set that you have
already created.
It is important to choose the appropriate scope for the tuning task If you choose the Limited option,
then the SQL Tuning Advisor produces recommendations based on statistics check, access path
analysis, and SQL structure analysis. The Limited option will not make a SQL profile
recommendation. If you choose the Comprehensive option, the SQL Tuning Advisor produces all the
recommendations that the Limited option produces, but it also invokes the optimizer under the SQL
profiling mode to build a SQL profile. With the Comprehensive option, you can also specify a time
limit for the tuning task, which by default is 30 minutes. After you select Run SQL Tuning Advisor,
configure your tuning task using the SQL Tuning Options page.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
SQL Tuning Advisor Recommendations
a s yu ense
The SQL Tuning
y M l c the task are displayed as soon as the task completes and can also be
Results ifor
e from the Advisor Central page. A summary of the recommendations are displayed.
accessed llater
n review
You
S t a
can and implement individual recommendations. Select the statement and click view.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M Example u
Using the SQL Tuning k i
Advisor: t o
a s yu ense
You can invoke
y M l c Advisor by performing the following steps:
the SQL iTuning
1. ClickleAdvisor Central in the Related Links region on the Database home page.
S an SQL Advisors. The SQL Tuning Advisor Links page appears.
2. tClick
The advisor can be run on one of the following sources:
- Active SQL: Analyzes the Top SQL statements currently active
- SQL Tuning Sets: Analyzes a set of SQL statements you provide
- Historical SQL (AWR): Analyzes SQL captured by snapshots in the AWR
3. Select Active SQL. Select a five-minute interval to analyze by dragging the shaded box over the
target time period. Select one or more statements to analyze during the selected period.
4. Click Run SQL Tuning Advisor. The SQL Tuning Options page appears showing the SQL
statements in the interval. Give your task a name and description, select Comprehensive as the
scope, and select Immediately for start time. Click OK.
5. Navigate back to the Advisor Central page. The status of Advisor Tasks is listed under this
heading in the Results region. Wait until your task status is completed. Check the status by
clicking Refresh in your browser. Select your task and click View Result. The SQL Tuning
Result page appears.
6. Select the SQL statement and click View Recommendations.
Duplicate SQL
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
t r a ns
Bind
o n -variable
s a ncandidates
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Duplicate SQL
y u ki se to
Duplicate SQLM as licareenstatements that are different only in the literal values they use or in
statements
l ey Statements that are different each get a separate cursor in the Library Cache.
their formatting.
n
Sta that are duplicates can use the same cursor if the literals are replaced with bind variables,
Statements
and the formatting is made to be the same.
Duplicate SQL statements can be identified by clicking Duplicate SQL on the Performance tabbed
page in the Additional Monitoring Links section. SQL that is determined to be duplicate, except for
formatting or literal differences, is listed together. This helps you determine which SQL in your
application can be consolidated, thus lowering the requirements on the Library Cache and speeding
up the execution of the statement.
Workload specification
Recommendations
-SQL statement
-Indexes
-SQL Tuning Set
-Materialized views
-SQL cache contents
-Materialized view logs
-Statistics
-Partitioning
-Schema name e
r a bl
s fe
- t r an
SQL Access nno
Advisor s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
SQL Access Advisor:uOverviewk i (M e to u
a s
sy ccanenrecommend
The SQL Access M Advisor i the proper set of materialized views, materialized view
y l
e
nlwhen
logs, partitioning, and indexes for a given workload. Understanding and using these structures is
S t a
essential optimizing SQL because they can result in significant performance improvements in
data retrieval.
The SQL Access Advisor recommends bitmap, function-based, and B-tree indexes. A bitmap index
offers a reduced response time for many types of ad hoc queries and reduced storage requirements
compared to other indexing techniques. B-tree indexes are most commonly used in a data warehouse
to index unique or near-unique keys.
Another component of the SQL Access Advisor also recommends how to optimize materialized
views so that they can be fast refreshable and take advantage of general query rewrite.
Note: For more information about materialized views and query rewrite, see the Oracle Database
Performance Tuning Guide.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(MSession u
Typical SQL Access Advisor k i t o
a s yu ense
When starting M
y
a SQL Access
l ic Advisor session, you can select Use Default Options and start with a
eset of advisor options that are recommended. Additionally, you can start a task and have it
na lset
predefined
t a
inherit
S of option values as defined by a template or task by selecting “Inherit Options from a
Task or Template.” These include several generic templates designed for general-purpose
environments, OLTP, and data warehousing databases. You can save custom templates from a
previous task and reuse them when needed.
Click Continue to launch the SQL Access Advisor Wizard.
Note: You can access SQL Access Advisor from the Advisor Central page of Database Control.
Workload Source
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Workload Source k i
a s yu ense
Use the SQL Access
y M l ic Wizard’s Workload Source page to provide a defined workload that
Advisor
eAccess Advisor to make recommendations. Supported workload sources are:
anl and Recent SQL Activity: Uses the current SQL from the cache as the workload
allows the
•StCurrent
• Use an existing SQL Tuning Set: Enables you to specify a previously created SQL Tuning Set
as the workload source
• Create a Hypothetical Workload from the Following Schemas and Tables: Provides a
schema that allows the advisor to search for dimension tables and produce a workload
The scope of the workload can be further reduced by applying filters that you can access in the Filter
Options section. With these options, you can reduce the scope of the SQL statements that are present
in the workload. The filters are applied to the workload by the advisor to focus the tuning effort.
Possible filter options are:
• Top resource consuming SQL statements
• Users, module identifier, or actions
• Tables
Recommendation Options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recommendation Options k i
a s yu ense
Use the Recommendations
y M l icOptions page to choose whether to limit the advisor to recommendations
based onlaesingle access method. Choose Indexes, Materialized Views, Partitioning, or a combination
tanfrom the “Access Structures to Recommend” section. You can choose Evaluation Only to
ofSthose
evaluate only existing access structures. In this mode, the advisor does not generate new
recommendations but comments on the use of existing structures. This is useful to track the
effectiveness of the current index, materialized view, and MV log usage over time.
You can use the Advisor Mode section to run the advisor in one of two modes. These modes affect
the quality of recommendations as well as the length of time required for processing. In
Comprehensive mode, the advisor searches a large pool of candidates resulting in recommendations
of the highest quality. In Limited mode, the advisor performs quickly, limiting the candidate
recommendations.
Recommendation Options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Recommendation Options k i t o
(continued)
a s yu ense
You can choose
y M Advanced
l icOptions to show or hide options that enable you to set space restrictions,
for t a nle Volatility
tuning options,
Workload
and default storage locations. Use the Workload Categorization section to set options
and Workload Scope. You can choose to favor read-only operations or you
S
can consider the volatility of referenced objects when forming recommendations. You can also select
Partial Workload, which does not include recommendations to drop unused access structures, or
Complete Workload, which does include recommendations to drop unused access structures.
Use the Space Restrictions section to specify a hard space limit, which forces the advisor to produce
recommendations only with total space requirements that do not exceed the specified limit.
Use the Tuning Options section to specify options that customize the recommendations made by the
advisor. Use the “Prioritize Tuning of SQL Statements by” drop-down list to prioritize by Optimizer
Cost, Buffer Gets, CPU Time, Disk Reads, Elapsed Time, and Execution Count.
Use the Default Storage Locations section to override the defaults defined for schema and tablespace
locations. By default, indexes are placed in the schema and tablespace of the table they reference.
Materialized views are placed in the schema and tablespace of the user who executed one of the
queries that contributed to the materialized view recommendation.
After you define these parameters, you can schedule and review your tuning task.
Reviewing Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Reviewing Recommendations k i
a s yu ense
Using the Advisor
M Centralicpage, you can list all the completed SQL Access Advisor tasks. Select the
y l
l e
one for which
n you want to see the recommendations, and then click the View Result button. Use the
Sta for Task Summary page to get an overview of the advisor findings. The page presents charts
Results
and statistics that provide overall workload performance and query execution time potential
improvement for the recommendations. You can use the page to show statement counts and
recommendation action counts.
To see other aspects of the results for the advisor task, click one of the three other tabs on the page:
Recommendations, SQL Statements, or Details.
The Recommendations page displays a chart and a table that show the top recommendations ordered
by their percentage improvement to the total cost of the entire workload. The top recommendations
have the biggest total performance improvement.
By clicking the Show SQL button, you can see the generated SQL script for the selected
recommendations. You can click the corresponding recommendation identifier in the table to see the
list of actions that need to be performed in order to implement the recommendation. On the Actions
page, you can actually see all the corresponding SQL statements to execute in order to implement the
action. For recommendations that you do not want to implement, keep those check boxes deselected.
Then, click the Schedule Implementation button to implement the retained actions. This step is
executed in the form of a Scheduler job.
Database Replay
Database Replay:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Workload
ble
fe r a
Replay ans
Capture
n - t r
a no
a s
Production ) h i d eฺ Test
m
co nt Gu
database
a i l ฺ database
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Database Replay
y u ki se to
The system is going
M asto change.
l i c enThe hardware must be upgraded, or the operating system, or the
ey or all of them. You have to assure the users that the application will continue to
database lversion,
n
Sta after the upgrade, and often guarantee performance at least as good as it was before the
function
upgrade.
You build a test environment, and test the application with a workload. You make changes and test
again until you are confident that the application is working in the new environment.
This whole process depends on the test workload being representative of the actual production
workload. A single statement in the production workload missing in the test workload could cause
the upgrade to fail in production.
Database Replay captures the actual production workload, and allows you to replay the workload in a
test environment. The replay can be modified to allow for higher throughput, asynchronous
application, and faster or slower replay. Database Replay can also be used to fine-tune by running
exactly the same set of statements repeatedly. You can make changes to the environment and observe
the differences. This capability also allows capture and replay of test cases to resolve errors.
Using actual production workloads allows you to be confident that the testing process is complete
and accurate.
Capture directory
ble
fe r a
ans
n - t r
Database
backup a no
a s
) h i d eฺ
Production m
co nt Gu
database i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
System Architecture:uCapturek i (M e to u
a sy there e n s
Start the recording
y M when
l ic are no active sessions, to be sure to capture all SQL. During recording,
t
while a nleproduction
special recording
the
infrastructure built into the RDBMS records data about all external client requests,
workload is running on the system. External requests are any SQL queries,
S
PL/SQL blocks, PL/SQL remote procedure calls, DML statements, DDL statements, object
navigation requests and OCI calls. Background jobs and, in general all internal clients, continue their
work during recording, without being recorded. The end product is that the workload recording
contains all necessary information for replaying the workload as seen by the RDBMS in the form of
external requests.
The recording infrastructure imposes minimal performance overhead (extra CPU, memory, and I/O)
on the recording system. You should, however, plan to accommodate the additional disk space
needed for the actual workload recording.
A backup of the database corresponding to the beginning of the capture is required for replay.
RAC Note: Instances in a RAC environment have access to the common database files. However,
they do not need to share a common general-purpose file system. In such an environment, the
workload recording is written on each instance’s file system during recording. For processing and
replay, all the parts of the workload recording need to be manually copied into a single directory.
Capture directory
ble
fe r a
ans
n - t r
Database
backup a no
a s
) h i d eฺ
Production m
co nt Gu
database i l ฺ Process
ma tude
capture
g
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k i (M e totheuWorkload
System Architecture:uProcessing
a
The captured workload ns preprocessing to create metadata that are needed to replay the
sy filescerequire
yM
workload.leThe
li
processing includes information about the test system that allows the test system to be
n
Sta from the capture system.
different
The workload capture data is processed and new workload replay–specific metadata files are created.
Only new files are created; no files are modified that were created during the workload capture.
Because of this, you can run the preprocess multiple times on the same capture directory, such as
when the procedure encounters unexpected errors or is canceled.
External client connections are remapped at this stage and any replay parameters can be modified
that affect the replay outcome.
Note: Because processing workload capture can be relatively expensive, best practice is to do that
operation on another system than the production database system.
Capture directory
ble
fe r a
Test
ans
system
with
n - t r
Database
backup
changes
a no
a s
) h i d eฺ
Test m
co nt Gu
database i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
System Architecture Replayk i
a s yu ense
Before replaying
y M l ic on the replay system, you need to ensure:
the workload
t a nle thecapture.
1. Restore
workload
replay database on a test system to match the capture database at the start of the
S2. Make changes (such as perform an upgrade) to the test system as needed.
3. Copy the workload to a directory available to the replay system.
The workload recording is consumed by a special application called the replay driver, which sends
requests to the RDBMS on which the workload is replayed. The RDBMS on which the workload is
replayed is usually a test system. It is assumed that the database of the replay system is suitable for
the replay of the workload that was recorded. The internal RDBMS clients are not replayed. The
replay driver is a special client that consumes the workload recording and sends appropriate requests
to the test system to make it behave as though the external requests were sent by the clients used
during the recording of the workload. The use of a special driver that acts as the sole external client
to the RDBMS allows for the record and replay infrastructure to be client agnostic.
The replay driver consists of one or more clients that connect to the replay system and sends requests
based on the workload capture. The replay driver equally distributes the workload capture streams
among all the replay clients based on network bandwidth, CPU, and memory capability.
Clients/App servers
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
Production
database
Database
backup
Database
n
restore- t r
n o
Can use Snapshot Standby as test system
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
The Big Picture k i
a s yu ense
The significantM
y ic Oracle Database 11g managing system changes is the added confidence
benefit with
l
a n le in the success of performing the change. The record and replay functionality offers
to the business
S t
confidence in the ease of upgrade during a database server upgrade. A useful application of Database
Replay is to test the performance of a new server configuration. Suppose you are utilizing a single-
instance database and want to move to a Real Application Clusters (RAC) setup. You can record the
workload of an interesting period and then set up a RAC test system for replay. During replay, you
can monitor the performance benefit of the new configuration by comparing the performance to the
recorded system.
Database Replay can be used for debugging. You can record and replay sessions emulating an
environment to make bugs more reproducible. Manageability feature testing is another benefit. Self-
managing and self-healing systems need to implement this advice automatically (“autonomic
computing model”). Multiple replay iterations allow testing and fine-tuning of the control strategies’
effectiveness and stability.
The database administrator, or a user with special privileges granted by the DBA, can initiate the
record and replay cycle and has full control of the entire procedure.
Workloads Supported
• Captured operations:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Start
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Workload recording
Plan
Workload Replay
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Process Capture
Replay Files
& Metadata
Raw captured data
(from production
Initialize Replay
system)
Prepare e
r a bl
s fe
Replay
- t r an
Replay
non
Reports a
Analyze
) ha ideฺ End
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Using Enterprise Manager u e to
ki forsWorkload Replay
s y
a haslfour n
e steps:
The workload M replay i c
l ey replay data
1. Initializing
n
S a
2. tPreparing for replay
3. Replay
4. Replay analysis
All the steps performed by Enterprise Manager can also be done through the PL/SQL API. For
detailed information about the manual steps, see the Oracle Database Performance Tuning Guide.
For details of the DBMS_WORKLOAD_CAPTURE and DBMS_WORKLOAD_REPLAY packages, see
the Oracle Database PL/SQL Packages and Types Reference.
Summary
Practice 15 Overview:
Monitor Instance Performance
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Space Management
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
segments
BMB BMB …
Benefits:
BMB …
• More flexible space
… utilization
• Run-time adjustment
…
• Multiple process search
… … … … of BMBs ble
fe r a
ans
…
n - t r
Data n o
block … s a
{
) h a eฺ
m i d
Segment
Extent
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Free Space Management k i
a s yu ense
Free space can
y lic automatically inside database segments. The in-segment free or used
Mbe managed
space n e
is ltracked with bitmaps. To take advantage of this feature, specify Automatic Segment
t
Spacea
S Management, when you create a locally managed tablespace. Your specification then
applies to all segments subsequently created in this tablespace.
Automatic space management segments have a set of bitmap blocks (BMBs) describing the
space utilization of the data blocks in that segment. BMBs are organized in a tree hierarchy. The
root level of the hierarchy, which contains the references to all intermediate BMBs, is stored in
the segment header. The leaves of this hierarchy represent the space information for a set of
contiguous data blocks that belong to the segment. The maximum number of levels inside this
hierarchy is three.
Benefits of using automatic space management include:
• Better space utilization, especially for the objects with highly varying row sizes
• Better run-time adjustment to variations in concurrent access
• Better multi-instance behavior in terms of performance or space utilization
Therefore, less work for you, the DBA.
Types of Segments
Allocating Extents
PCTFREE = 10
FS2
FS3
FS1
FS1
ble
FS2 fe r a
Inserts, t r a ns
FS3 Deletes n -
Deletes
o
updates
s an
FS4 ) ha ideฺ
Full block c o m block
Full G u
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Block Space Management k i
a s yu ense
Space management
y lic the management of free space at the block level. With Automatic
M involves
Segment
a n leSpace Management, each block is divided into four sections, named FS1 (between 0
andt
S 25% of free space), FS2 (25% to50% free), FS3 (50% to 75% free), and FS4 (75% to 100%
free).
Depending on the level of free space in the block, its status is automatically updated. That way,
depending on the length of an inserted row, you can tell whether a particular block can be used
to satisfy an insert operation. Note that a “full” status means that a block is no longer available
for inserts.
In the slide example, the block on the left is an FS3 block because it has between 50% and 75%
free space. After some insert and update statements, PCTFREE is reached (the dashed line) and
it is no longer possible to insert new rows in that block. The block is now considered as a “full”
or FS1 block. The block is considered for insertion again, as soon as its free space level drops
below the next section. In the case above, it gets status FS2 as soon as the free space is more
than 25%.
Note: Large object (LOB) data types (BLOB, CLOB, NCLOB, and BFILE) do not use the
PCTFREE storage parameter.
Example:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Proactive Tablespace k i
Monitoring
a s yu ense
Tablespace disk
y lic is proactively managed by the database in the following ways:
M space usage
a n le the use of database alerts, you are informed when a tablespace runs low on
• Through
t
S available disk space as well as when particular segments are running out of space. You can
then provide the tablespace with more disk space, thus avoiding out-of-space conditions.
• Information gathered is stored in the Automatic Workload Repository (AWR) and is used to
perform growth trend analysis and capacity planning of the database.
To view and modify tablespace information in Enterprise Manager, select Server from the
Database Home page, and then select Tablespaces. Select the tablespace of your choice and
click the Edit button.
Thresholds and
Resolving Space Problems
97% full or 5 MB left
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
critical
Alert
85% full or 100 MB left DBA
warning
Resolve space
Locally managed tablespace problem
Resolve space problem by:
• Adding or resizing data file
• Setting AUTOEXTEND ON ble
fe r a
• Shrinking objects s
- t r an
• Reducing UNDO_RETENTION n
a no
• Checking for long-running queries in temporary a s tablespaces
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Thresholds and Resolvingk i
u nSpace e Problems
s y
a are s
edefined either as full or as available space in the tablespace. Critical
Tablespace thresholds
M l i c
l ey thresholds are the two thresholds that apply to a tablespace. The
and warning
n
Sta
DBMS_SERVER_ALERT package contains procedures to set and get the threshold values. When
the tablespace limits are reached, an appropriate alert is raised. The threshold is expressed in
terms of a percentage of the tablespace size or in remaining bytes free. It is calculated in
memory. You can have both a percentage and a byte-based threshold defined for a tablespace.
Either or both of them may generate an alert.
The ideal setting for the warning threshold trigger value results in an alert that is early enough to
ensure that there is enough time to resolve the problem before it becomes critical, but late
enough so that you are not bothered when space is not a problem.
The alert indicates that the problem can be resolved by doing one or more of the following:
• Adding more space to the tablespace by adding a file or resizing existing files, or making an
existing file autoextendable
• Freeing up space on disks that contain any autoextendable files
• Shrinking sparse objects in the tablespace
MMON
Shrinking Segments
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
HWM
HWM
DML operations and queries can be issued during compaction.
ble
fe r a
2 ALTER TABLE employees SHRINK SPACE; s
- t r an
n no
s a
) h a eฺ
m i d
HWM
DML operations are blocked when the i l ฺHWM Gu
co isntadjusted.
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Shrinking Segmentsuki
a s y ense
The diagram M in the slidelic
describes the two phases of a table shrink operation. The first phase
does the y
lecompaction. During this phase, rows are moved to the left part of the segment as much
as t a n
Spossible. Internally, rows are moved by packets to avoid locking issues. After the rows have
been moved, the second phase of the shrink operation is started. During this phase, the high-
water mark (HWM) is adjusted and the unused space is released.
The COMPACT clause is useful if you have long-running queries that might span the shrink
operation and attempt to read from blocks that have been reclaimed. When you specify the
SHRINK SPACE COMPACT clause, the progress of the shrink operation is saved in the bitmap
blocks of the corresponding segment. This means that the next time a shrink operation is
executed on the same segment, the Oracle database server remembers what has been done
already. You can then reissue the SHRINK SPACE clause without the COMPACT clause during
off-peak hours to complete the second phase.
• Indexes maintained
• Triggers not executed
• Number of migrated rows may be reduced.
• Rebuilding secondary indexes on IOTs recommended
Index ble
fe r a
ans
n - t r
Table Shrink a no
a s DBA
) h i d eฺ
m
o t Gu
Triggers not executed ilฺc
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Results of Shrink Operationk i
a s yu ense
Shrinking a sparsely
y M l ic segment improves the performance of scan and DML operations
populated
e
on that segment.
nlThis This is because there are fewer blocks to look at after the segment has been
S t a
shrunk. is especially true for:
• Full table scans (fewer and denser blocks)
• Better index access (fewer I/Os on range ROWID scans due to a more compact tree)
Also, by shrinking sparsely populated segments, you enhance the efficiency of space utilization
inside your database because more free space is made available for objects in need.
Index dependency is taken care of during the segment shrink operation. The indexes are in a
usable state after shrinking the corresponding table. Therefore, no further maintenance is
needed.
The actual shrink operation is handled internally as an INSERT/DELETE operation. However,
any DML triggers are not executed because the data itself is not changed.
As a result of a segment shrink operation, it is possible that the number of migrated rows is
reduced. However, you should not always depend on reducing the number of migrated rows after
a segment has been shrunk. This is because a segment shrink operation may not touch all the
blocks in the segment. Therefore, it is not guaranteed that all the migrated rows are handled.
Note: It is recommended to rebuild secondary indexes on an index-organized table (IOT) after a
shrink operation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Segment Advisor: Overview k i
a s yu ense
The Segment M
y l ic
Advisor identifies segments that have space available for reclamation. It performs
t
(AWR),a nleandbybyexamining
its analysis
sampling
usage and growth statistics in the Automatic Workload Repository
the data in the segment. It is configured to run automatically at regular
S
intervals, and you can also run it on demand (manually). The regularly scheduled Segment
Advisor run is known as the Automatic Segment Advisor.
After the recommendations are made, you can choose to implement the recommendations. The
shrink advisor can be invoked at the segment or tablespace level.
The EM Database Control Console is the interface to the Segment Advisor. You can access the
Segment Advisor from several places within EM:
• Advisor Central page
• Tablespaces page
• Schema object pages
The Database Control Console provides the option to select various inputs and schedule a job
that calls the Segment Advisor to get shrink advice. The Segment Advisor Wizard can be
invoked with no context, in the context of a tablespace, or in the context of a schema object.
The Segment Advisor makes recommendation on the basis of sampled analysis, historical
information, and future growth trends.
Segment Advisor
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Segment Advisor uki
a s y ense
From the Server
y lic Tablespaces in the Storage section. On the Tablespaces page, select
M page, select
a n le on which you want to perform the shrink analysis, and then select Run Segment
the tablespace
t
Advisor
S in the Actions drop-down list. Click Go to open the Segment Advisor initial page. You
must choose “comprehensive” or “limited” analysis mode. In comprehensive mode, the analysis
is longer because the advisor is sampling the segments to identify the right targets.
Keep clicking Continue to answer the various questions of the advisor. You end up on the
Segment Advisor: Review page, where you can review the details of your analysis. The Segment
Advisor analysis is run as a scheduled job, so you can review the scheduled task from the
Advisor Central page. When completed, you can review the advisor’s recommendations.
Note: In the Segment Advisor, you can specify the duration of the analysis. This enables you to
limit the time the advisor takes to produce recommendations. Generally speaking, a longer
analysis period produces more comprehensive results. The results are stored in the AWR and can
be viewed later. Use the “Number of days to retain” option to instruct the Oracle database server
how long these results should be preserved before being purged from the AWR.
Implementing Recommendations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Implementing Recommendationsi
a s yu ense
After the Segment
y M Advisor lic completes its job, you can view the recommendation details and
t a nle them directly.
implement
S Before shrinking a heap-organized table, you must enable row movement on that table.
Note:
You can do this with Database Control from the Options tab on the Edit Table page.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Manual Segment Shrink k i
u Using e EM
s y n s
Alternatively M(toaimplementing
l i c e the Segment Advisor recommendations), you can shrink
l
individual
n eysegments associated with specific database objects. For example, from the Database
Sta page, select the Schema folder tab then click the Tables link in the Database Objects
Home
section. On the Tables page, select your table, and then select Shrink Segment in the Actions
drop-down list. Then click the Go button. This brings you to the Shrink Segment page, where
you can choose the dependent segments to shrink. You have the opportunity to compact only or
to compact and release the space. You can also choose the CASCADE option.
When done, click the Continue link. This submits the shrink statements as a scheduled job.
t a nleRow
enable row
segment.
movement on the corresponding segment before executing a shrink operation on that
movement by default is disabled at segment level. To enable row movement, the
S
ENABLE ROW MOVEMENT clause of the CREATE TABLE or ALTER TABLE command is
used. This is illustrated in the first example in the slide.
Use the ALTER command to invoke segment shrink on an object. The object’s type can be one
of the following: table (heap- or index-organized), partition, subpartition, LOB (data and index
segment), index, materialized view, or materialized view log.
Use the SHRINK SPACE clause to shrink space in a segment. If CASCADE is specified, the
shrink behavior is cascaded to all the dependent segments that support a shrink operation, except
materialized views, LOB indexes, and IOT (index-organized tables) mapping tables. The
SHRINK SPACE clause is illustrated in the second example.
In an index segment, the shrink operation coalesces the index before compacting the data.
Example 3 shows a command that shrinks a LOB segment, given that the RESUME column is a
CLOB.
Example 4 shows a command that shrinks an IOT overflow segment belonging to the
EMPLOYEES table.
Note: For more information, refer to the Oracle Database SQL Reference guide.
Managing Resumable
Space Allocation
A resumable statement:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
t a n eaction instead
of large ldatabase
corrective
operations in the event of space allocation failures. This enables you to take
of the Oracle database server returning an error to the user. After the
S
error condition is corrected, the suspended operation automatically resumes. This feature is
called “resumable space allocation.” The statements that are affected are called “resumable
statements.” A statement executes in resumable mode only when the resumable statement
feature has been enabled for the system or session.
Suspending a statement automatically results in suspending the transaction. Thus all
transactional resources are held through the suspension and resuming of a SQL statement. When
the error condition disappears (for example, as a result of user intervention or perhaps sort space
released by other queries), the suspended statement automatically resumes execution. A
resumable statement is suspended when one of the following conditions occur:
• Out of space condition
• Maximum extents reached condition
• Space quota exceeded condition
A suspension time-out interval is associated with resumable statements. A resumable statement
that is suspended for the time-out interval (the default is 2 hours) reactivates itself and returns
the exception to the user. A resumable statement can be suspended and resumed multiple times.
Note: A maximum extents reached error only happens with dictionary-managed tablespaces.
Oracle Database 11g: Administration Workshop II 16 - 21
Computer Pride Limited
For example:
SELECT name, sql_text FROM user_resumable;
NAME SQL_TEXT
--------------- --------------------------------------------
multitab insert INSERT INTO oldsales SELECT * FROM sh.sales;
To automatically configure resumable statement settings for individual sessions, you can create
and register a database-level LOGON trigger that alters a user’s session. The trigger issues
commands to enable resumable statements for the session, specifies a time-out period, and
associates a name with the resumable statements issued by the session. a b le
s fer
Because suspended statements can hold up some system resources, users must beagranted n the
tr allocation
RESUMABLE system privilege before they are allowed to enable resumable n
o -
space and
execute resumable statements.
s an
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
1 SQL statement
Full table
2 Suspended
Continue
SQL 3 Optionally 4 ble
operation
fe r a
ans
n - t r
5 Table AFTER
a no
with free
space
SUSPEND
triggerm)
has ideฺ Abort
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Resuming Suspending k iStatements
a s yu ense
Example: M
y statementlic encounters an error saying the table is full.
e
1. An lINSERT
n
S2.taThe INSERT statement is suspended, and no error is passed to client.
3. Optionally, an AFTER SUSPEND trigger is executed.
4. Optionally, the SQLERROR exception is activated to abort the statement.
5. If the statement is not aborted and free space is successfully added to the table, the INSERT
statement resumes execution.
Detecting a Suspended Statement
When a resumable statement is suspended, the error is not raised to the client. In order for
corrective action to be taken, the Oracle database server provides alternative methods for
notifying users of the error and for providing information about the circumstances.
SUSPEND trigger are always nonresumable and are always autonomous. Transactions started
within the trigger use the SYSTEM rollback segment. These conditions are imposed to overcome
deadlocks and reduce the chance of the trigger experiencing the same error condition as the
statement.
Within the trigger code, you can use the USER_RESUMABLE or DBA_RESUMABLE views, or
the DBMS_RESUMABLE.SPACE_ERROR_INFO function to get information about the
resumable statements.
When a resumable statement is suspended:
• The session invoking the statement is put into a wait state. A row is inserted into
a b le
V$SESSION_WAIT for the session with the EVENT column containing “statement
s fer
suspended, wait error to be cleared”.
- t r an
• An operation-suspended alert is issued on the object that needs addition
n onresources for the
suspended statement to complete. s a
Ending a Suspended Statement
a
) h uideฺ
m
When the error condition is resolved (for example, ias
a lฺca oresult
e n t
of G
DBA intervention or perhaps
gm Sstatement
sort space released by other queries), the suspended
@ t ud automatically resumes execution
and the “resumable session suspended”kalert
u i is cleared.
is
s y t h
A suspended statement can be forced
( M se the SERVERERROR exception by using the
a touactivate
DBMS_RESUMABLE.ABORT()
u to
ki seprocedure. This procedure can be called by a DBA, or by the
user who issued athe y
s statement.
e n If the suspension time-out interval associated with the resumable
statement is M l i c
y reached, the statement aborts automatically and an error is returned to the user.
n le
Sta
Transporting Tablespaces
ble
Microsoft Windows IA (32-bit) HP-UX IA (64-bit) Linux 64-bit for AMD
fe r a
Linux IA (32-bit) Linux IA (64-bit) Apple Mac OS ans
n - t r
AIX-Based Systems (64-bit) HP Open VMS no
Microsoft Windows 64-bit AMD
a
a s
IBM Power Based Linux HP IA Open VMS ) h
Solaris x86 and
i d eฺAMD64
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transporting Tablespacesk i
a s yu ense
TransportableM
y licis the fastest way for moving large volumes of data between two
tablespace
a le
Oraclendatabases. Using transportable tablespaces, Oracle data files (containing table data,
S t
indexes, and almost every other Oracle database object) can be directly transported from one
database to another. Furthermore, like import and export, transportable tablespaces provide a
mechanism for transporting metadata in addition to transporting data.
You can use the transportable tablespace feature to move data across platform boundaries. This
simplifies the distribution of data from a data warehouse environment to data marts, which often
run on smaller platforms. It also allows a database to be migrated from one platform to another
by rebuilding the dictionary and transporting the user tablespaces.
Moving data using transportable tablespaces is much faster than performing either an
export/import or unload/load of the same data. This is because the data files containing all of the
actual data are just copied to the destination location, and you use Data Pump to transfer only the
metadata of the tablespace objects to the new database.
To be able to transport data files from one platform to another, you must ensure that both the
source system and the target system are running on one of the supported platforms (see slide).
Note: The cross-platform transportable tablespace feature requires both platforms to be using the
same character sets.
ble
Read/ Read/
fe r a
write write s
- t r an
n
no
Read- Read- Read/s a Read-
only only h a ฺ
) writeuide only
m
COMPATIBLE=9.2.0 a ฺco nt G
ilCOMPATIBLE=10.0.0
g m tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Concept: Minimum Compatibility i
u nse Level
s y
atarget ldatabases
e need to advance their database COMPATIBLE initialization
Both source and M i c
parameter
n l eyto 10.0.0 or greater before they can use the cross-platform transportable tablespace
Sta
feature.
When data files are first opened under Oracle Database 10g or 11g with COMPATIBLE set to
10.0.0 (or greater), the files are made platform-aware. This is represented by the check marks
in the diagram. Each file identifies the platform that it belongs to. These files have identical on-
disk formats for file header blocks that are used for file identification and verification. Read-
only and offline files get the compatibility advanced only after they are made read/write or are
brought online. This implies that tablespaces that are read-only in databases before Oracle
Database 10g must be made read/write at least once before they can use the cross-platform
transportable feature.
a n le level at which the target database must run. This is referred to as the compatibility
compatibility
t
level
S of the transportable set. Beginning with Oracle Database 11g, a tablespace can always be
transported to a database with the same or higher compatibility setting, whether the target
database is on the same or a different platform. The database signals an error if the compatibility
level of the transportable set is higher than the compatibility level of the target database.
The above table shows the minimum compatibility requirements of the source and target
tablespace in various scenarios. The source and target database need not have the same
compatibility setting.
When data files are first opened, each file identifies the platform that it belongs to. These files
have identical on-disk formats for file header blocks that are used for file identification and
verification. Read-only and offline files get the compatibility advanced only after they are made
read/write or are brought online.
Target
uses the same No
endian format?
Convert data files
by using RMAN.
Yes
ble
fe r a
Ship data files and dump file to target. ans
n - t r
n o
Use Data Pump to import metadata. s a
) h a eฺ
m i d
Target Make tablespaces c
l ฺ o t Gu
read/write.
i
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespace k i
u nProcedure
a s y e se
To transport aM
y licfrom one platform to another (source to target), data files belonging to
tablespace
SELECT tp.endian_format
FROM v$transportable_platform tp, v$database d
WHERE tp.platform_name = d.platform_name;
ble
fe r a
Source Target ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Determining the Endian k i
u nse of a Platform
Format
s y
a lice
You can query MV$TRANSPORTABLE_PLATFORM to determine whether the endian ordering is
y
the sameleon both platforms. V$DATABASE has two columns that can be used to determine your
n
Staplatform name and platform identifier. Run the query below for a comprehensive list of
own
supported platforms and their endian formats:
SQL> SELECT * FROM V$TRANSPORTABLE_PLATFORM;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- -------------------------------- --------------
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
10 Linux IA (32-bit) Little
6 AIX-Based Systems (64-bit) Big
3 HP-UX (64-bit) Big
5 HP Tru64 UNIX Little
4 HP-UX IA (64-bit) Big
11 Linux IA (64-bit) Little
15 HP Open VMS Little
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespacesk i
u nswith e Enterprise Manager
s y
a canlibe eused to implement transportable tablespaces. From the Database
Enterprise Manager
M c
home n l eyclick the Data Movement folder tab, and then click Transport Tablespaces under the
page,
Sta Database Files section. Select “Generate a transportable table set” and provide the login
Move
credentials for the oracle user, and then click Continue. On the Select Tablespaces page, add
the tablespaces you want to transport from the displayed list by clicking the Tablespace button,
and then clicking Add. Near the bottom of the page, you must select the level of containment
checking to be done before the tablespaces are processed. The containment check looks for
object dependencies within the tablespaces. When you have finished, click Next. Wait a few
moments while the containment check runs. Address any issues found by the check before
continuing.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespacesk i
u nswith e Enterprise Manager (continued)
s y
a Characteristics
e
On the Destination
y M l i c page, you must supply the destination platform and character
a n le the Destination Database Platform section, select the operating system of the
sets. Under
S t
destination machine from the drop-down list. If the destination platform is different from the
source platform, Enterprise Manger will perform a data conversion. Continue to the Destination
Character Set section of the page and choose the destination character set and national character
set from the drop-down lists. These character sets must be compatible with the source sets.
When you click Next to continue, Enterprise Manager checks the compatibility of the character
sets. If the chosen character sets are flagged as incompatible, you will be returned back to the
Destination Characteristics page to correct your selections.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Transportable Tablespaces k i
u nswith e Enterprise Manager (continued)
s y
apage, supplye a meaningful description for the default job name. You can also
On the ScheduleM l i c
y the job immediately or schedule it for later execution. When you have made your
l
choosento estart
Sta click Next to continue. On the review page, you can verify your choices before
selections,
submitting the job for execution. Click the Submit Job button if the entries are correct. Click the
Back button to correct any incorrect entries.
Transporting Databases
Ship
Read- Read- Read- Read-
only only files only only
CONVERT
DATABASE
ble
TO PLATFORM
fe r a
ans
n - t r
o
Source
s an
Target
system ha systemฺ
ide
)
m
c nt Gu
o
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Database Transportation k i
u Procedure:
e Source System Conversion
s y
a licyour n s
e database, you must open it in READ ONLY mode. Then use
Before you can
M transport
RMAN n l eyconvert the necessary data files of the database.
to
Sta you do the conversion on the source platform, the RMAN CONVERT DATABASE
When
command generates a script containing the correct CREATE CONTROLFILE RESETLOGS
command that is used on the target system to create the new database. The CONVERT
DATABASE command then converts all identified data files so that they can be used on the
target system. You then ship the converted data files and the generated script to the target
platform. By executing the generated script on the target platform, you create a new copy of
your database.
Note: The source database must be running with the COMPATIBLE initialization parameter set
to 10.0.0 or higher. All identified tablespaces must have been READ WRITE at least once
since the time that COMPATIBLE was set to 10.0.0 or higher.
CONVERT
DATABASE Read- Ship Read- Read- Read-
ON DESTINATION only only only only
files
PLATFORM
ble
fe r a
Source Target ans
tr
system on-
system
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Database Transportationu e to Target System Conversion
ki Procedure:
y
as licyour s
en database, you must open it in READ ONLY mode. Then use
Before you can
M transport
RMAN n l eyconvert the necessary data files of the database.
to
Sta you do the conversion on the target platform, the CONVERT DATABASE command
When
(which is executed on the source system) generates only two scripts used on the target system to
convert the data files, and to re-create the control files for the new database. Then, you ship the
identified data files and both scripts to the target platform. After this is done, execute both
scripts in the right order. The first one uses the existing RMAN CONVERT DATAFILE
command to do the conversion, and the second issues the CREATE CONTROLFILE
RESETLOGS SQL command with the converted data files to create the new database.
Note: The source database must be running with the COMPATIBLE initialization parameter set
to 10.0.0 or higher. All identified tablespaces must have been READ WRITE at least once
since COMPATIBLE was set to 10.0.0 or higher.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Database Transportation: k i
u nConsiderations
a s y e se
Redo logs, control
y c tempfiles are not transported. They are re-created for the new
M files,liand
database
a n leon the target platform. As a result, the new database on the target platform must be
t
opened
S with the RESETLOGS option.
If a password file is used, it is not transported and you need to create it on the target platform.
This is because the types of file names allowed for the password file are OS specific. However,
the output of the CONVERT DATABASE command lists all the usernames and their system
privileges, and advises to re-create the password file and add entries for these users on the target
platform.
The CONVERT DATABASE command lists all the directory objects and objects that use BFILE
data types or external tables in the source database. You may need to update these objects with
new directory and file names. If BFILEs are used in the database, you have to transport the
BFILEs.
The generated PFILE and transport script use Oracle Managed Files (OMF) for database files. If
you do not want to use OMF, you must modify the PFILE and transport script.
The transported database has the same DBID as the source database. You can use the DBNEWID
utility to change the DBID. In the transport script as well as the output of the CONVERT
DATABASE command, you are prompted to use the DBNEWID utility to change the database ID.
Summary
Practice 16 Overview:
Managing Storage
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Managing Resources
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
following:
• Configure the Database Resource Manager
• Access and create resource plans
• Create consumer groups
• Specify directives for allocating resources to consumer
groups
• Map consumer groups to plans a b le
• Activate a resource plan s fer
- t r an
• Monitor the Resource Manager non a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
y u ki se to
M as licen
le y
n
Sta
Database
Resource Manager
More resources e
OLTP users
r a bl
s fe
DSS users
Fewer resources - t r an
n
no
Batch users s a
h a eฺ Oracle
Least resourcesm) i d
i l ฺ co nt Gu database
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Database Resource u k
Manager: to u
i (M eOverview
a sy Resource
e n s
By using the Database
y M lic Manager (also called the Resource Manager), you have more
le the allocation of machine resources than is normally possible through operating
controlnover
a
t
system
S resource management alone. If resource management decisions are made by the
operating system, it can lead to problems such as:
• Excessive overhead resulting from operating system context switching of Oracle database
server processes when the number of server processes is high
• Suspension of a database server process that is holding a latch
• Unequal distribution of resources among all Oracle database processes, and an inability to
prioritize one task over another
• Inability to manage database-specific resources, such as parallel execution servers and
active sessions
The Database Resource Manager controls the distribution of resources among various sessions
by controlling the execution schedule inside the database. By controlling which sessions run and
for how long, the Database Resource Manager can ensure that resource distribution matches the
plan directive and, therefore, the business objectives. With the Database Resource Manager, you
can guarantee groups of users a minimum amount of processing resources regardless of the load
on the system and the number of users.
Resource
consumer with similar resource needs
group
A blueprint for resource
allocation among resource
consumer groups (one
Resource plan
active plan)
ble
Specifies how a resource iss fe r a
divided among the resource
- t r an
on the
consumer groupsn(within
Resource plan s a
scope of allocation
directives
a
) h uideฺ
methods)
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Database Resource u
y ki seConcepts
Manager:
as lby
AdministeringMsystems i c n the Database Resource Manager involves the use of resource
eusing
n l ey consumer groups, and resource plan directives.
plans, resource
ta
ASresource consumer group defines a set of users or sessions that have similar requirements for
using system and database resources.
A resource plan specifies how the resources are distributed among various resource consumer
groups. The Database Resource Manager also allows for creation of plans within plans, called
subplans.
Resource plan directives specify how a particular resource is shared among consumer groups or
subplans. You associate resource consumer groups and subplans with a particular resource plan
through plan directives.
Resource allocation methods determine what policy to use when allocating for any particular
resource. Resource allocation methods are used by resource plans and resource consumer
groups.
such as:
– CPU usage
– Degree of parallelism
– Number of active sessions
– Undo generation
– Operation execution time
– Idle time e
r a bl
• You can also specify criteria that, if met, cause the automatic
n s fe
switching of sessions to another consumer group. -tra
n on
s a
a
) h uideฺ
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Why Use Resource Manager
y u ki se to
The DatabaseM as liManager
Resource c en provides several means of allocating resources:
• CPU l y
eMethod: Enables you to specify how CPU resources are allocated among consumer
t a n
S groups and subplans
• Degree of Parallelism Limit: Enables you to control the maximum degree of parallelism
for any operation within a consumer group
• Active Session Pool with Queuing: Allows you to limit the number of concurrent active
sessions for a consumer group or subplan. If a group exceeds the maximum allowed number
of sessions, new sessions are placed in a queue where they wait for an active session to
complete. You can also specify a time limit on how long a session will wait before exiting
with an error.
• Undo Pool: Enables you to control the total amount of undo that can be generated by a
consumer group or subplan. Whenever the total undo space exceeds the amount specified
by UNDO_POOL, no further INSERT, UPDATE, or DELETE commands are allowed until
undo space is freed by another session in the same group or the undo pool is increased for
the consumer group. If the consumer group’s quota is exceeded during the execution of a
DML statement, the operation aborts and returns an error. Queries are still allowed, even if
a consumer group has exceeded its undo threshold.
the Resource Manager chooses the most restrictive of all incoming values.
• Idle Time Limit: Enables you to specify an amount of time for which a session can be idle,
after which it will be terminated (MAX_IDLE_TIME). You can further restrict the Resource
Manager to terminate only those sessions that are blocking other sessions
(MAX_IDLE_TIME_BLOCKER).
• Consumer Group Switching: The initial consumer group is the group that a session would
be in had it just logged in. The top call is defined as treating an entire PL/SQL block as one
call or, similarly, treating SQL statements that are issued separately by the client as separate
calls. This functionality is mostly beneficial for three-tier applications where the middle-tier
server implements session pooling. In this case, the middle tier tends to do one call foraan b le
end user and then use the same session for a call for a different end user. Therefore, f r
ethe
s
n affect the
anot
boundaries of work are really calls, and the actions of a prior end user should- t r
next end user. You can create a plan directive, so that the Resource n on automatically
Manager
switches the user back to the initial consumer group at the end a sofathe top call.
) h uand ฺ
deSWITCH_TIME
Note: You cannot specify both the SWITCH_TIME_IN_CALL
o m i
parameters within the same directive. The SWITCH_TIME G
ilฺc ent parameter is primarily intended
a
@ gm Stud
for client/server applications, while the SWITCH_TIME_IN_CALL parameter is for three-
tier applications. ki is
a syu se th
k i (M to u
a syu cense
yM li
n le
Sta
Enterprise Manager
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
and PL/SQL
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Accessing ResourceuPlans k i (M e to u
a y ens
sManager
Using Enterprise
y M lic
l e
n Manager Database Control provides an easy-to-use graphical interface for
Enterprise
S t a
configuring resource plans, consumer groups, and so on. Select EM > Server, and then the item
you want to work with.
Using the DBMS_RESOURCE_MANAGER Package
This PL/SQL package comprises many procedures, including the following:
• CREATE_PLAN: Names a resource plan and specifies its allocation methods
• UPDATE_PLAN: Updates a resource plan’s comment
• DELETE_PLAN: Deletes a resource plan and its directives
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
Default MaintenanceuResource
o u Plan
i (M e tManager
a sy centaskss
The automatedMmaintenance
li rely on the Resource Manager being enabled during the
y
le windows. When a maintenance window opens, the
maintenance
t a n resource manager plan is automatically set to control the
S
DEFAULT_MAINTENANCE_PLAN
amount of CPU used by automated maintenance tasks. To be able to give different priorities to
each possible task during a maintenance window, various consumer groups are assigned to
DEFAULT_MAINTENANCE_PLAN. The hierarchy between groups and plans is shown in the
slide.
For high priority tasks:
• Optimizer Statistics Gathering automatic task is assigned to the
ORA$AUTOTASK_STATS_GROUP consumer group.
• Segment Advisor automatic task is assigned to the ORA$AUTOTASK_SPACE_GROUP
consumer group.
• Automatic SQL Tuning automatic task is assigned to the ORA$AUTOTASK_SQL_GROUP
consumer group.
Note: If need be, you can manually change the percentage of CPU resources allocated to the
various automated maintenance task consumer groups inside
ORA$AUTOTASK_HIGH_SUB_PLAN.
Example: DEFAULT_PLAN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Allocation Methods
Resource Consumer
Group MGMT_P1 MGMT_P2 MGMT_P3
SYS_GROUP 100% 0% 0%
OTHER_GROUPS 0% 90% 0%
ORA$AUTOTASK_SUB_PLA 0% 5% 0%
N
ble
0% 5% 0% fe r a
ORA$DIAGNOSTICS
ans
n - t r
For automated
a no
maintenance tasks
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Example: DEFAULT_PLAN k i
a s yu ense
The DEFAULT_PLAN
y M ic
lresource plan is one of the default plans provided for you. It contains
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating a New Resource k i
u nPlan
a s y e se
To create a new
y licneed to configure several Resource Manager objects.
M plan, you
le > Server > Plans, and then click Create or choose “Create Like” and click Go.
SelectnEM
a
t
S Scheduler can automatically change the Resource Manager plan at the Scheduler window
The
boundaries. Deselect the default Automatic Plan Switching Enabled check box if this option is
unacceptable.
bl e
fe r a
t r a ns
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
o n -
CONSUMER_GROUP => 'APPUSER',
s an
MGMT_MTH => 'ROUND-ROBIN',
) ha ideฺ
COMMENT => '');
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Creating Consumer u
y ki se to
Groups
To manage a M as consumer
resource l i c en group, select EM > Server > Consumer Groups. Choose the
l eyyou want to perform. You can create a new resource consumer group or you can
actionnthat
Sta a resource consumer group from the results list and choose one of the actions from the
select
Actions drop-down list.
Use the Resource Consumer Groups page to create or edit the consumer group and description,
and to select users assigned to the group. You can add or delete members to the Selected Users
table.
The General property sheet (shown in the slide) is one of the two pages that make up the Create
Resource Consumer Group and Edit Resource Consumer Group pages. You can define or edit
which database roles are associated with the specified resource consumer group by moving to
the other property sheet (Roles).
You specify a resource allocation method for the distribution of CPU among sessions in the
consumer group. “Round Robin” scheduling ensures that sessions are fairly executed. Therefore,
the default allocation method is Round Robin. The “Run to Completion” allocation method
specifies that sessions with the largest active time are scheduled ahead of other sessions. The
equivalent functionality is achieved by the
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP procedure with the MGMT_MTH
option.
Oracle Database 11g: Administration Workshop II 17 - 11
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Assigning Users to Groups i
a s yu ense
Users should M
y licto resource consumer groups. The user’s default consumer group is the
be assigned
le any session created by that user initially belongs. If it is not set for a user, the
one tonwhich
a
t
user’s
S initial consumer group defaults to DEFAULT_CONSUMER_GROUP.
You must directly grant to the user, or to PUBLIC, the switch privilege to a consumer group
before it can be the user’s default consumer group. The switch privilege cannot come from a role
granted to that user.
DBMS_RESOURCE_MANAGER.SET_INITIAL_CONSUMER_GROUP (
user => 'PM', consumer_group => 'APPUSER' );
The DBMS_RESOURCE_MANAGER_PRIVS package contains the procedure to assign resource
consumer groups to users. Granting the switch privilege to a user enables the user to switch to a
different consumer group.
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP (
grantee_name => 'PM',
consumer_group => 'APPUSER',
grant_option => FALSE );
1 2 3 4 5 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Specifying ResourceuPlan k i (MDirectives
t o
se to create the resource plan or resource consumer groups,
sy cenManager
If you do not useaEnterprise
you must first li
y Mcreate a pending area. This is a scratch area that enables you to stage your
n l e
Sta and to validate them before they are made active.
changes
In Enterprise Manager, there are several property pages, which you can use for specifying plan
directives:
1. On the General page, associate consumer groups with plans and specify how much CPU
each consumer group or subplan gets with the MGMT_MTH value.
2. Specify a parallel degree limit to control the maximum degree of parallelism for any
operation within a consumer group.
3. You can control the maximum number of concurrently active sessions allowed within a
consumer group. An entire parallel execution session is counted as one active session.
4. You can control the amount of total undo that can be generated by a consumer group.
5. You can specify threshold values, such as execution time limit (in seconds), I/O limit (in
MB), and I/O request limit (in number of requests).
6. You can specify an amount of time that a session can be idle, after which it will be
terminated. You can further restrict such termination to only those sessions that are
blocking other sessions.
Note: The following slides provide further details about directives using the tab numbers
indicated in this slide. Refer to this slide when you see “Directive Tab n” on subsequent slides.
(Comments)
MGMT_MTH EMPHASIS, RATIO
PARALLEL_DEGREE_LIMIT_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE
ble
ACTIVE_SESS_POOL_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE
fe r a
ans
Limiting number of active sessions, queuing inactive ones
n - t r
QUEUING_MTH FIFO_TIMEOUT a no
a s
h
) sessioni d eฺ
Controlling queues, how inactive sessions enter active m
co nt Gu
pool
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Resource AllocationuMethods k i (M efortoResource Plans
s y
a methods n s
e determine how the Resource Manager allocates a particular
Resource allocation
M l i c
resource
n l etoya resource consumer group or resource plan. You specify values for the following
Sta allocation methods when creating the resource plan.
resource
There are two ways of specifying the CPU distribution with the MGMT_MTH parameter:
• EMPHASIS is the default method for single-level plans. It is also used for multilevel plans
that use percentages to specify how CPU is distributed among consumer groups.
• RATIO is for single-level plans that use ratios to specify how CPU is distributed.
EMPHASIS RATIO
The value specifies the maximum The value specifies a number that indicates
percentage of CPU resources a the ratio of CPU resources to be allocated to
consumer group can use. the consumer group.
You can allocate resources for up to 8 You can specify values for only one level.
different levels.
The sum of percentages at any given You must use integer values, but there is no
level must be less than or equal to 100. limit on the sum of values.
ble
Default value is NULL. Default value is NULL. fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Comparison of EMPHASIS k i and t o
a s yu ense RATIO
The CPU allocation
y M methodlic EMPHASIS determines how much emphasis is given to sessions in
different
a n leconsumer groups in a resource plan. CPU usage is assigned levels from 1 through 8,
t
with
S Level 1 having the highest priority. Percentages specify how to allocate CPU to each
consumer group at each level.
The following rules apply for the EMPHASIS resource allocation method:
• CPU resources are distributed at a given level on the basis of the specified percentages. The
percentage of CPU specified for a resource consumer group is a maximum for how much
that consumer group can use at a given level.
• Consumer resources that are not used at a given level are made available to consumer
groups at the next level. For example, if the consumer groups at Level 1 use only 60% of
the available resources, the additional 40% is made available to consumer groups at
Level 2.
• The sum of percentages at any given level must be less than or equal to 100.
• Any levels that have no plan directives explicitly specified have a default of 0% for all
subplans or consumer groups.
• The EMPHASIS resource allocation method avoids starvation problems, where consumers
with lower priorities are not given the opportunity to run.
• DSS_USERS: 3
• BATCH_USERS: 2
• OTHER: 1
This is similar to saying that OLTP users should get 40% of the resources, DSS users should get
30% of the resources, BATCH users should get 20% of the resources, and all other consumer
groups should get 10% of the available resources.
If there are no consumers in the OTHER or DSS_USERS consumer groups currently utilizing
CPU resources, then the OLTP_USERS consumer group would get two-thirds of the available
resources and the BATCH_USERS consumer group would get the other third.
b le
fe ra
a ns
o n -tr
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
ley
n
Sta
50
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Setting the Active Sessionk i
u nPool
a s y e se
You can easily
y Mconfigurelicthe Active Session Pool settings for a resource plan by using Enterprise
t a nle
Manager.
S
Example, if you limit the Maximum Number of Active Sessions to 50 for the APPUSER
consumer group:
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.update_plan_directive(
plan => 'DEFAULT_PLAN',
group_or_subplan => 'APPUSER',
new_comment => '',
new_cpu_p1 => NULL, new_cpu_p2 => NULL, new_cpu_p3 => 60,
new_cpu_p4 => NULL, new_cpu_p5 => NULL, new_cpu_p6 => NULL,
new_cpu_p7 => NULL, new_cpu_p8 => NULL,
new_parallel_degree_limit_p1 => NULL,
new_switch_io_reqs => NULL,
new_switch_io_megabytes => NULL,
new_active_sess_pool_p1 => 50,
new_queueing_p1 => NULL,
(continued)
Oracle Database 11g: Administration Workshop II 17 - 18
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Specifying Thresholds:
Execution Time Limit
• The Database Resource Manager can estimate the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
a b le
DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVEfer
(PLAN => 'DAY_PLAN', t r a ns
GROUP_OR_SUBPLAN => 'APPUSER', non
-
COMMENT => 'Limit Idle Timeas a
Example',
NEW_MAX_IDLE_TIME => 600, m ) h uideฺ
o
NEW_MAX_IDLE_BLOCKER_TIME
a ilฺc ent=>G 300);
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Setting Idle Timeouts
y u ki se to
as plan’s
You use the resource
M l i c enIdle Time tab to set the maximum idle timeouts for a resource plan.
“Max n l
IdleeyTime (sec)” and “Max Idle Time if Blocking Another Session (sec)” are the
Sta equivalents of the NEW_MAX_IDLE_TIME and NEW_
respective
MAX_IDLE_BLOCKER_TIME resource directives in the
DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE procedure. They are both
specified in seconds.
NEW_MAX_IDLE_TIME specifies the time that a session is neither executing nor waiting for
I/O. When the session exceeds the specified limit, the PMON process forcibly kills the session
and cleans up its state. In addition to limiting the maximum idle time for a session, you can also
limit the amount of time that an idle session can block another session. You impose this limit by
setting the NEW_MAX_IDLE_BLOCKER_TIME resource directive to the number of seconds to
allow a session to be idle while blocking another session. You can also specify a value of
UNLIMITED to indicate that no maximum time has been set. The default is NULL, which means
unlimited. These settings give you a more granular control than profiles, whose single value
cannot distinguish between blocking and nonblocking sessions.
In the slide example, the PMON process kills sessions that are idle for longer than 600 seconds.
The PMON process also kills sessions that are idle for more than 300 seconds and are blocking
other sessions. PMON checks these limits once every minute and if it finds a session that has
exceeded one of the limits, it forcibly kills the session and cleans up all its resources.
Oracle Database 11g: Administration Workshop II 17 - 21
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Resource ConsumeruGroup k i (M Mapping
t o
a s y ense
You can configure
y l ic
M the Database Resource Manager to automatically assign consumer groups to
sessionsle
by providing mappings between session attributes and consumer groups. Further, you
cant a n
S prioritize the mappings so as to indicate which mapping has precedence in case of conflicts.
There are two types of session attributes: login attributes and run-time attributes. The login
attributes (the last five in the Attribute Mappings list shown in the slide) are meaningful only at
session login time, when the Database Resource Manager determines the initial consumer group
of the session. In contrast, a session that has already logged in can later be reassigned to another
consumer group on the basis of its run-time attributes.
From the Database Control home page, navigate to the Server tabbed page, and then click the
Resource Consumer Group Mappings link in the Resource Manager section. For each of the
attributes, set up a mapping that consists of a way to identify a session (for example, username),
and a consumer group. Add or remove rows for each of the resource consumer group categories,
as required, and enter text identifying the user, client, module, or service in the corresponding
group. You can establish a priority ordering between conflicting mappings of the attributes by
using the Priorities tab. You can set the priority from the most important to the least important
by using the navigational arrows (as highlighted). The mappings at the top of the list have the
highest priority.
Using EM Database Control, you can easily view the SQL generated from your actions by
clicking the Show SQL button.
Oracle Database 11g: Administration Workshop II 17 - 22
Computer Pride Limited
dbms_resource_manager.oracle_user,
'SCOTT',
'LOW_GROUP'
);
dbms_resource_manager.set_consumer_group_mapping_pri(
EXPLICIT => 1, SERVICE_MODULE_ACTION => 2,
SERVICE_MODULE => 3,
MODULE_NAME_ACTION => 4,
MODULE_NAME => 5,
SERVICE_NAME => 6,
ORACLE_USER => 7, ble
CLIENT_OS_USER => 8, fe r a
ans
CLIENT_PROGRAM => 9,
n - t r
no
CLIENT_MACHINE => 10
);
s a
h a
dbms_resource_manager.submit_pending_area();
) eฺ
m i d
co nt Gu
END;
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
DBA_RSRC_CONSUMER_GROUP_PRIVS Users/roles
a n le that are declared in the instance. This section discusses some useful information
plan directives
t
that
S can be obtained from these views. For more detailed information about the contents of each
of these views, refer to the Oracle Database Reference manual.
Use the following query to obtain information about resource plans defined in the database:
SQL> SELECT plan, num_plan_directives, status, mandatory
2 FROM dba_rsrc_plans;
PLAN NUM_PLAN_DIRECTIVES STATUS MAN
-------------- ------------------- --------- ---
DEFAULT_PLAN 3 ACTIVE NO
INTERNAL_QUIESCE 2 ACTIVE YES
INTERNAL_PLAN 1 ACTIVE YES
BUGDB_PLAN 4 ACTIVE NO
MAILDB_PLAN 3 ACTIVE NO
MYDB_PLAN 3 ACTIVE NO
A status of ACTIVE indicates that the plan has been submitted and can be used, whereas a status
of PENDING shows that the plan has been created, but is still in the pending area.
If the mandatory column is assigned a value of YES, then the plan cannot be deleted.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Monitoring the Resource k i
u Manager
a s y e n se
You can monitor
y lic
M the functioning of the Database Resource Manager at the session level. It is
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Monitoring the Resource k i
u Manager e (continued)
s y
a lice n s
CPU Utilization M
There n l
are eaty least three different views in the system that can provide you with information about
a utilization inside the Oracle database:
StCPU
the
• V$RSRC_CONSUMER_GROUP shows CPU utilization statistics on a per consumer group
basis, if you are running the Oracle Database Resource Manager. This view displays data
related to currently active resource consumer groups.
• V$SYSSTAT shows the Oracle database CPU usage for all sessions. The statistic “CPU
used by this session” shows the aggregate CPU used by all sessions.
• V$SESSTAT shows the Oracle database CPU usage per session. You can use this view to
determine which particular session is using the most CPU.
The V$RSRC_CONSUMER_GROUP View
The following is a quick description of some of the columns in this view:
• name: Name of the consumer group
• active_sessions: Number of currently active sessions in this consumer group
• execution_waiters: Number of active sessions waiting for a time slice
• requests: Cumulative number of requests executed in this consumer group
• cpu_wait_time: Cumulative amount of time that sessions waited for CPU
• consumed_cpu_time: Cumulative amount of CPU time consumed by all sessions
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
Practice 17 Overview:
Using the Resource Manager
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
A Simple Job
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
WHEN
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
WHAT m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
A Simple Job
a syu cense
A job has twoM
y li
key components: action, “what” needs to be done and schedule, “when” action
l e
occurs.nThe “what” is expressed in the Command region of the screenshot shown in the slide and
the
a
Stjob_type and job_action parameters. The job shown in the slide is also represented
by the following code. The “what” portion is enclosed in the top box while the “when” portion is
defined in the second box.
BEGIN
sys.dbms_scheduler.create_job(
job_name => '"HR"."CREATE_LOG_TABLE_JOB"',
job_type => 'PLSQL_BLOCK', job_action => 'begin
execute immediate (''create table session_history(
snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)''); end;',
start_date => systimestamp at time zone 'America/New_York',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Create the SESSION_HISTORY table',
auto_drop => FALSE, enabled => TRUE);
END;
A job is also defined by “when” the desired action needs to take place. The “when” is expressed
in a “schedule,” which can be based on time (see the start_date parameter) or events, or be
dependent on the outcome of other jobs.
Oracle Database 11g: Administration Workshop II 18 - 4
Computer Pride Limited
following steps:
1. Create a program.
2. Create and use a schedule.
3. Create and submit a job.
4. Monitor a job.
Job
Program Schedule
attributes
ble
fe r a
ans
Job
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
Arguments
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Key Components and
a syu Key e n se
Steps
y ic
The SchedulerMoffers a lmodularized approach for managing tasks within the Oracle database. By
breakingl e
n down a task into its components, such as time, location, and database object, the
S t a
Scheduler offers you an easier way to manage your database environment. The Scheduler uses
three basic components:
• A job specifies what needs to be executed and when. For example, the “what” could be a
PL/SQL procedure, a native binary executable, a Java application, or a shell script. You can
specify the program (what) and schedule (when) as part of the job definition, or you can use
an existing program or schedule instead. You can use arguments for a job to customize its
run-time behavior.
• A schedule specifies when and how many times a job is executed. A schedule can be based
on time or an event. You can define a schedule for a job by using a series of dates, an event,
or a combination of the two, along with additional specifications to denote repeating
intervals. You can store the schedule for a job separately and then use the same schedule for
multiple jobs.
• A program is a collection of metadata about a particular executable, script, or procedure.
An automated job executes some task. Using a program enables you to modify the job task,
or the “what,” without modifying the job itself. You can define arguments for a program,
enabling users to modify the run-time behavior of the task.
1. Creating a Program
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
BEGIN
ble
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name => 'CALC_STATS2',
fe r a
program_action =>
ans
'HR.UPDATE_HR_SCHEMA_STATS',
n - t r
program_type =>
a no
'STORED_PROCEDURE',
a s
enabled => TRUE);
) h i d eฺ
END;
m
co nt Gu
/
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
1. Creating a Program
a syu cense
M
Use the CREATE_PROGRAM
y li procedure to create a program. Creating a program is an optional
l e
part ofnusing the Scheduler. You can also encode the action to be performed within an
Sta
anonymous PL/SQL block in the CREATE_JOB procedure. By creating the program separately,
you can define the action once, and then reuse this action within multiple jobs. This enables you
to change the schedule for a job without having to re-create the PL/SQL block. You can also
customize the job by specifying argument values.
To create a program in your own schema, you need the CREATE JOB privilege. A user with the
CREATE ANY JOB privilege can create a program in any schema.
A program is created in a disabled state by default (unless the enabled parameter is set to
TRUE). A disabled program cannot be executed by a job until it is enabled. You can specify that
a program should be created in the enabled state by specifying a value of TRUE for enabled.
The program action is a string specifying a procedure, executable name, or a PL/SQL
anonymous block, depending on what program_type is set to.
If you have a procedure called UPDATE_HR_SCHEMA_STATS that collects the statistics for the
hr schema, then you can create a program to call this procedure.
In Enterprise Manager, click Programs in the Oracle Scheduler region of the Server page. Click
Create.
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE(
ble
schedule_name => 'stats_schedule',
fe r a
start_date => SYSTIMESTAMP,
ans
end_date => SYSTIMESTAMP + 30,
n - t r
repeat_interval =>
a no
'FREQ=HOURLY;INTERVAL=1',
a s
comments => 'Every hour');
) h i d eฺ
END; m
co nt Gu
/ i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
2. Creating and Using
a syu Schedules
e n se
M (instead
By using a schedule
y lic of specifying the execution times for a job within the job
l e
definition),
n you can manage the scheduled execution of multiple jobs without having to update
S t a
multiple job definitions. If a schedule is modified, then each job that uses that schedule
automatically uses the new schedule.
Use the CREATE_SCHEDULE procedure in the DBMS_SCHEDULER PL/SQL package to create
a schedule.
The start_date represents the date on which the schedule becomes active. The schedule
cannot refer to any dates before this date. The schedule is not valid after the end_date.
You can schedule repeated executions by supplying a calendaring expression for
repeat_interval. This calendaring expression is used to generate the next date of the
schedule. Dates falling after the end_date time are not included in the schedule.
In the example in the slide, a schedule named STATS_SCHEDULE is created, specifying a
repeat interval of every hour (starting now) and continuing for 30 days. For more information
about calendaring expressions, refer to the Oracle Database Administrator’s Guide.
You can use Enterprise Manager to create schedules, as shown in the slide.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
syu ceanJob
3. Creating and Running
a se
M
A job is a combination
y lofi a schedule and a description of what to do, along with any additional
l
arguments e
n that are required by the job.
t a
S program or “Command” can be a pre-created PL/SQL or Java program, an anonymous
The
PL/SQL block, or an executable that is run from the operating system’s command line.
The schedule for a job can be a predefined schedule (created with the
DBMS_SCHDULER.CREATE_SCHEDULE procedure) or defined as part of the job creation.
The schedule specifies attributes about when the job is run, such as:
• A start time, which defines when the job is picked for execution and an end time, which
specifies the time after which the job is no longer valid and is not scheduled any more
• An expression specifying a repeating interval for the job
• A complex schedule created by combining existing schedules
• A condition or change in state, called an event, that must be met before the job is started
There are many attributes that you can set for a job. Attributes control how the job executes.
To run a job in Enterprise Manager, click the Server folder tab, then select Jobs from the Oracle
Scheduler section.
4. Monitoring a Job
SELECT job_name, status, error#, run_duration
FROM USER_SCHEDULER_JOB_RUN_DETAILS;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
4. Monitoring a Jobyu
a
M li
The DBA_SCHEDULER_JOB_RUN_DETAILS
y view has a row for each job instance. Each row
containsl e
n information about the job execution for that instance.
S t a
[DBA|ALL]_SCHEDULER_JOB_RUN_DETAILS views have the following columns:
• LOG_ID: The unique identifier of the log entry
• LOG_DATE: The time stamp of the log entry
• OWNER: The job owner
• JOB_NAME: The name of the job
• STATUS: The status of the job execution
• ERROR#: The number of the first error encountered
• REQ_START_DATE: The time at which the job was scheduled to start
• ACTUAL_START_DATE: The time at which the job was actually started
• RUN_DURATION: The duration of execution of the job
• INSTANCE_ID: The instance upon which the job ran
• SESSION_ID: The session the job ran within
• SLAVE_PID: The process ID of the slave process used to perform the job execution
• CPU_USED: The amount of CPU used for the job run
• ADDITIONAL_INFO: Additional information about the job run
Using a Time-Based or
Event-Based Schedule
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Schedule
ble
fe r a
ans
n - t r
Time
a no Event
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Using a Time-Based
a e nse
syuorcEvent-Based Schedule
M
To specify a time-based
y lischedule for a job, you can specify either a calendaring expression or a
l
date-time e
n expression. When using a calendaring expression, the next start time for a job is
S t a
calculated using the repeat interval and the start date of the job. When using date-time
expressions, the specified expression determines the next time that the job should run. If no
repeat interval is specified, the job runs only once on the specified start date.
If a job uses an event-based schedule, the job runs when the event is raised. At a high level, an
event can be viewed as a change in state. An event occurs when a Boolean condition changes its
state from FALSE to TRUE, or TRUE to FALSE.
The Scheduler uses Oracle Streams Advanced Queuing (AQ) to raise and consume events.
Note: The Scheduler does not guarantee that a job executes on the exact time because the system
may be overloaded and thus resources may be unavailable.
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'HR.DO_BACKUP',
job_type => 'EXECUTABLE',
job_action =>
'/home/usr/dba/rman/nightly_incr.sh',
a b le
start_date=> SYSDATE,
s fer
repeat_interval=>'FREQ=DAILY;BYHOUR=23',
- t r an
/* next night at 11:00 PM o*/
n n
s a
comments => 'Nightly incremental backups');
END;
a
) h uideฺ
m
/ lฺco t G ai den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Creating a Time-Based
y u kiJobse to
M as lprocedure
Use the CREATE_JOB i c en of the DBMS_SCHEDULER package to create a job. Jobs are
l ey by default and they become active and scheduled only when they are explicitly
createdndisabled
Sta All job names are of the form: [schema.]name.
enabled.
You should use SYSTIMESTAMP and specify a time zone so that when the time changes
because of daylight saving time, your job adjusts its execution time automatically.
By default, a job is created in the current schema. You can create a job in another schema
by specifying the name of the schema, as shown in the example in the slide. The job owner is the
user in whose schema the job is created, whereas the job creator is the user who created the job.
Jobs are executed with the privileges of the job owner. The national language support (NLS)
environment of the job when it runs is the same as that present at the time the job was created.
The job_type parameter indicates the type of task to be performed by the job. The possible
values are:
• PLSQL_BLOCK: An anonymous PL/SQL block
• STORED_PROCEDURE: A named PL/SQL, Java, or external procedure
• EXECUTABLE: A command that can be executed from the operating system (OS)
command line
arguments.
An external job is a job that runs outside the database. All external jobs run as a low-privileged
guest user, as has been determined by the database administrator while configuring external job
support. Because the executable is run as a low-privileged guest account, you should verify that
it has access to necessary files and resources. Most, but not all, platforms support external jobs.
For platforms that do not support external jobs, creating or setting the attribute of a job or a
program to type EXECUTABLE returns an error.
Refer to your Oracle database platform-specific documentation for more information about
configuring the environment to run external programs with the Scheduler. ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
Lightweight Jobs yu
a
There are some
y li that have a need to create hundreds of jobs a second. With regular
Mcustomers
l
jobs each e
n job creates a database object describing the job, modifying several tables and creating
t a
S in the process. The overhead associated with this type of job need is substantial. In the
redo
Oracle Database Scheduler, there is a persistent lightweight job. The goal of a lightweight job is
to reduce the overhead and time required to start a job. A minimal amount of metadata is created
for the job. This reduces the time required and redo created when the job starts.
The lightweight job has a small footprint on disk for the job metadata and also for storing run-
time data. The small footprint on disk also makes load-balancing possible in RAC environments.
The lightweight job is always created from a job template. The job template can be a stored
procedure or a program. The stored procedure holds all the information needed for the job. A
few job attributes may be set such as job arguments.
Job templates are created using the DBMS_SCHEDULER.CREATE_PROGRAM procedures.
• Regular jobs:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Creating a Single
Lightweight Job
BEGIN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_lightweight_job1',
program_name => 'MY_PROG',
repeat_interval => 'FREQ=DAILY;BY_HOUR=9',
end_time => '30-APR-07 04.00.00 AM CST',
job_style => 'LIGHTWEIGHT');
END;
/
BEGIN
ble
DBMS_SCHEDULER.CREATE_JOB (
fe r a
job_name => 'my_lightweight_job2',
ans
program_name => 'MY_PROG',
n - t r
schedule_name => 'MY_SCHED',
a no
job_style => 'LIGHTWEIGHT');
a s
END;
) h i d eฺ
/ m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Lightweight
a syuJobs e n se
M
The DBMS_SCHEDULER
y licpackage has updated several packages to allow the lightweight jobs to
l
be createde
n with a minimum of new code. Lightweight jobs have very few parameters that can be
S t a
specified: job arguments and schedule. The rest of the metadata for the job is inherited from the
job template, including privileges. The template for a lightweight job must be a PL/SQL block
or a stored procedure. Lightweight jobs must be created through PL/SQL using the
DBMS_SCHEDULER package; the JOB_STYLE argument is not available in EM. In the first
example, MY_PROG is the job template, and the schedule is created as part of the CREATE_JOB
method. In the second example, the schedule is applied from a named schedule.
A simple template could look like this:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name=>'"SYSTEM"."MY_PROG"',
program_action=>
'DECLARE time_now DATE;
BEGIN
SELECT SYSDATE INTO time_now FROM DUAL;
END;',
program_type=>'PLSQL_BLOCK',
enabled=>TRUE);
END;
Oracle Database 11g: Administration Workshop II 18 - 16
Computer Pride Limited
Oracle Database
ble
fe r a
t r a ns
n -
Scheduler
o
s an
Event ADT
) ha ideฺ
Application
(Abstract
c o mQueueGu
Data Type) a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Creating an Event-Based u ki Schedulee to
y
as based n
eon s
M
Jobs can be triggered
y l i c events. An application can notify the Scheduler to start a job by
l
enqueuing e
n a message onto an Oracle Streams queue. A job started in this way is referred to as an
S t a
event-based job. To create an event-based job, you must set the following two additional
attributes with the CREATE_JOB procedure:
• queue_spec: A queue specification that includes the name of the queue where your
application enqueues messages to raise job start events, or in the case of a secure queue, the
<queue_name>, <agent_name> pair
• event_condition: A conditional expression based on message properties that must
evaluate to TRUE for the message to start the job. You can include user data properties in
the expression, provided that the message payload is a user-defined object type, and that
you prefix object attributes in the expression with tab.user_data.
You can either specify queue_spec and event_condition as in-line job attributes, or
create an event-based schedule with these attributes and then create a job that references this
schedule.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Event-Based
a e nse with Enterprise Manager
syu cSchedules
M page
The Create Schedule
y li enables you to choose between a standard, time-based schedule and
l e
an event-based
n schedule. If you choose an event-based schedule, then the interface changes and
t a
S can specify the queue name, agent name, and event condition, in addition to the other
you
schedule attributes.
Note: The Scheduler runs the event-based job for each occurrence of an event that matches
event_condition. However, events that occur while the job is already running are ignored;
the event gets consumed, but does not trigger another run of the job.
References
• See the Oracle Streams Advanced Queuing User’s Guide and Reference for information
about how to create queues and enqueue messages.
• For more information about Oracle Streams AQ rules and event conditions, see the
DBMS_AQADM.ADD_SUBSCRIBER procedure in the Oracle Database PL/SQL Packages
and Types Reference 11 manual.
Example: Create a job that runs if a batch load data file arrives
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'ADMIN.PERFORM_DATA_LOAD',
job_type => 'EXECUTABLE',
job_action => '/home/usr/dba/rman/report_failure.sh',
start_date => SYSTIMESTAMP,
event_condition =>
event_condition => 'tab.user_data.object_owner
'tab.user_data.object_owner ==
a b le
''HR''
''HR'' and
and tab.user_data.object_name
tab.user_data.object_name == ''DATA.TXT''
''DATA.TXT'' s fer
and
and tab.user_data.event_type
tab.user_data.event_type == ''FILE_ARRIVAL''
''FILE_ARRIVAL''
- t r an
and
and tab.user_data.event_timestamp ', non
tab.user_data.event_timestamp << 99 ',
queue_spec
queue_spec => 'HR.LOAD_JOB_EVENT_Q'); s a
=> 'HR.LOAD_JOB_EVENT_Q');
END; ) ha deฺ m u i
o G
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Creating an Event-Basedy u ki Job s e
s cen
ainformation
M
To specify event
y li as job attributes, you use an alternate syntax of CREATE_JOB that
includesl e
n the queue_spec and event_condition attributes. The job can include event
S t a
information in-line as job attributes or can specify event information by pointing to an event
schedule. The example shown in the slide uses an in-line, event-based schedule.
The example in the slide shows a job that is started when a file arrives on the operating system,
as long as the file arrives before 9:00 AM. Assume that the message payload is an object with
four attributes named object_owner, object_name, event_type, and
event_timestamp.
The example uses a user-defined event. Therefore, before this job can be started, when the file
arrives on the file system, a program or procedure must enqueue the event object type with the
proper information into the specified event queue. The HR.LOAD_JOB_EVENT_Q queue must
be of the same type as the event object type used for notifying the Scheduler of an event
occurrence. That is, the HR.LOAD_JOB_EVENT_Q queue must be a typed queue where the
type has four attributes named object_owner, object_name, event_type, and
event_timestamp.
For more information about how to create queues and enqueue messages, refer to the Oracle
Streams Advanced Queuing User’s Guide and Reference documentation.
Event-Based Scheduling
Event types:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
The default Scheduler event queue is intended primarily for Scheduler-generated events. Oracle
does not recommend the use of this queue for user applications, or user-defined events.
When creating schedules to be used in combinations, you can code the list of dates by including
hard-coded dates of the form [YYYY]MMDD or by including named schedules created with the
CREATE_SCHEDULE procedure. For example, you can specify a list of dates by using the
following values for the repeat interval of a schedule:
0115,0315,0325,0615,quarter_end_dates,1215
This string represents the dates January 15, March 15, March 25, June 15, December 15, and the
list of dates specified by the QUARTER_END_DATES schedule.
If you do not specify the optional year component for hard-coded dates in your schedule, the
dates are included for every year.
ble
Job fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Creating Job Chains
a syu cense
A chain is a named
y li of programs that are linked together for a combined objective. This is
M series
l e
knownnas “dependency scheduling.” An example of a chain may be the following:
Sta
Run program A and then program B, but only run program C if programs A and B complete
successfully, otherwise run program D.
Each position within a chain of interdependent programs is referred to as a step. Typically, after
an initial set of chain steps has started, the execution of successive steps depends on the
completion of one or more previous steps. To create and use a chain, you complete the following
steps in order. All procedures mentioned are part of the DBMS_SCHEDULER package, unless
noted otherwise.
1. Create a chain by using the CREATE_CHAIN procedure. The chain name can be
optionally qualified with a schema name (for example, myschema.myname).
2. Define (one or more) chain steps. Defining a step gives it a name and specifies what
happens during the step. Each step can point to one of the following:
- A program
- Another chain (a nested chain)
- An event
You define a step that points to a program or nested chain by calling the
DEFINE_CHAIN_STEP procedure.
3. After creating the chain object, you define chain rules. Chain rules define when steps run,
and define dependencies between steps. Each rule has a condition and an action:
- If the condition evaluates to TRUE, the action is performed. The condition can contain
any syntax that is valid in a SQL WHERE clause. Conditions are usually based on the
outcome of one or more previous steps. For example, you may want one step to run if
the two previous steps succeeded, and another to run if either of the two previous steps
failed.
- The action specifies what is to be done as a result of the rule being triggered.
A typical action is to run a specified step. Possible actions include starting or stopping
a step. You can also choose to end the execution of the job chain, returning eitheraabl
e
value or a step name and error code. s fer
All rules added to a chain work together to define the overall behavior of-the t r n When
achain.
the job starts and at the end of each step, all rules are evaluated to see
n n action or actions
owhat
occur next. You add a rule to a chain with the DEFINE_CHAIN_RULE s a procedure. You call
h a ฺ
this procedure once for each rule that you want to add to) the chain.
m u i de
4. Starting the chain involves two actions:
a i l ฺco nt G
- Enable a chain with the ENABLE procedure.
g m t(A u e is always created disabled, so
dchain
you can add steps and rules to the
k S it is executed by any job.) Enabling an
i@chainisbefore
u h
t an error.
sy not sreturn
already enabled chain does
a e
u a job of type 'CHAIN'. The job action must refer to
- To run a chain, you
k i (Mmust tcreate
o
yu You scan
the chain name.
s n e use either event-based or time-based schedules for this job.
M a lice
le y
n
Sta
Example of a Chain
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Dependency scheduling
START
Job Load_data_evt 1 Do_bulk_load 2
Stop_when_
disk_full_evt 5 3
Schedule Rebuild_indx
ble
fe r a
an4 s
END -
Run_reports t r
non
(HR.GEN_REPORTS)
a
has
BULK_LOAD_CHAIN
) i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s cense
Example of a Chainyu
a
As an example
y li consider all the tasks and conditions that occur during a bulk data
Mof a chain,
l e
load. First,
n you must have data to load. Then load the data, observing the file system to make
t a
S that you do not run out of space during the load. After the data load completes, you need to
sure
rebuild the indexes defined on the updated tables. Then you run reports against the newly loaded
data. The slide shows an example of dependency scheduling.
1 ble
2 fe r a
3 ans
n - t r
4
5 a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
s u cense
1. Creating a ChainyObject
a
On the ServerM
y li Chains from the Oracle Scheduler region. On the Scheduler Chains
page, select
l
page, you e
n can create or edit a job chain. On the Create Chain page, you must enter the name and
t a
S of the job chain. You can then choose whether the newly created job chain should be
owner
enabled or not. You can enable the chain at a later time.
PL/SQL example:
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => 'bulk_load_chain',
rule_set_name => NULL, evaluation_interval => NULL,
comments => 'Load data and run reports');
After naming the job chain and optionally providing a description, you enter the job chain steps,
one at a time. You can create job chain steps of the following type:
• A step that runs a program (PROGRAM)
• A step that is another job chain (SUBCHAIN)
• A step that uses a stored event-based schedule (EVENT_SCHEDULE)
Only one program can run during a step. Every step in a chain must be defined before the chain
can be enabled and used.
DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP (
1
chain_name => 'bulk_load_chain',
step_name => 'load_data_evt',
event_condition => 'tab.user_data.object_owner =
''HR'' and tab.user_data.object_name =
''DATA.TXT'' and tab.user_data.event_type =
''FILE_ARRIVAL'' ',
queue_spec => 'HR.LOAD_JOB_EVENT_Q');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
2 le
chain_name => 'bulk_load_chain', a b
step_name => 'do_bulk_load', s fer
program_name => 'hr.load_data_prog); - t r an
DBMS_SCHEDULER.DEFINE_CHAIN_STEP ( n o n
chain_name => 'bulk_load_chain', s a 3
step_name => 'rebuild_indx',
a
) h uideฺ
m
ฺco t G
program_name => 'hr.rebuild_indexes');
ail den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
2. Defining Chain Steps
y u ki se to
M as licestep
1. The load_data_evt
n
uses an event-based schedule. The load_data_evt step waits
for l e y
t a n a FILE_ARRIVAL event to be placed in HR.LOAD_JOB_EVENT_Q. This event notifies
S the Scheduler that the DATA.TXT data file has arrived on the file system. Because
queue_spec does not include an agent name, the specified queue is not a secure queue.
2. The do_bulk_load step performs a bulk data load into the schema tables.
3. The rebuild_indx step rebuilds the indexes for the tables following a data load.
4. The run_reports step runs a report against the new data. HR.GEN_REPORTS is another
job chain.
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'bulk_load_chain',
step_name => 'run_reports',
program_name => 'hr.gen_reports');
5. The stop_when_disk_full_evt step ends the chain execution if the system runs out
of disk space.
DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP (
chain_name => 'bulk_load_chain',
step_name => 'stop_when_disk_full_evt'
event_schedule_name => 'disk_full_sched')
Chain steps can also be created in Enterprise Manager. On the Create Chains page, navigate to
the Steps section and make your entries.
Oracle Database 11g: Administration Workshop II 18 - 27
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
syu cense
3. Defining Chain Rules
a
After you have
y Mspecifiedli the job chain steps, you can create rules for the job chain. Chain rules
l e
definenwhen steps run, and define dependencies between steps. Each rule has a condition and an
Sta If the condition evaluates to TRUE, the action is performed. The condition can also
action.
contain the Scheduler’s chain syntax.
To create a rule in EM, you click the Create button in the Rules region.
When entering the rule conditions, character strings should be entered in single quotation marks.
The graphical user interface (GUI) automatically escapes the quotation marks as needed when
executing the commands.
PL/SQL Example
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'bulk_load_chain',
condition => 'TRUE',
action => 'START load_data_evt,stop_when_disk_full_evt',
rule_name => 'dataload_rule1',
comments => 'start the chain');
Note: This PL/SQL example differs from the EM one in that it uses a user-defined rule name,
whereas the EM example shows the default generated name.
BEGIN
DBMS_SCHEDULER.ENABLE ('bulk_load_chain');
END;
/
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'bulk_load_chain_job',
job_type => 'CHAIN',
a b le
job_action => 'bulk_load_chain',
s fer
repeat_interval => 'freq=daily;byhour=7;
- t r an
byminute=5;bysecond=0',
n on
enabled => TRUE);
s a
END;
) a
h ideฺ
/ o m Gu
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
4. Starting the Chain y u ki se to
After you have M as licreating
finished c en and modifying the job chain, you enable it by calling the
l y
eprocedure or enabling it from the Chains page in Enterprise Manager.
ENABLE
t a n
S run a chain, you must create a job. Set the job_type to 'CHAIN' and the job action to the
To
name of the job chain you want to execute. The rest of the arguments are configured as you
would configure them for any other type of job. Alternatively, the job calling the job chain can
be created and enabled using Enterprise Manager.
ble
fe r a
tra ns
[DBA | ALL | USER]_SCHEDULER_CHAINS
n -
[DBA | ALL | no
USER]_SCHEDULER_CHAIN_RULES
a
a s
[DBA | ALL | h eฺ
USER]_SCHEDULER_CHAIN_STEPS
) i d
[DBA | ALL | o m Gu
USER]_SCHEDULER_RUNNING_CHAINS
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Monitoring Job Chainsy u ki se to
M as licen view contains information about the chain owner and name;
The ALL_SCHEDULER_CHAINS
the rule
n l eyname and rule set owner for the chain; the number of rules; the number of steps;
set
Sta or not the chain is enabled; whether or not the chain uses an evaluation interval; and
whether
whether or not the chain uses a user-defined rule set.
The ALL_SCHEDULER_CHAIN_RULES view displays information such as the name and
owner of the chain for which the rule was defined; the rule name, owner, and condition; and the
action to be performed if the condition evaluates to TRUE.
The ALL_SCHEDULER_CHAIN_STEPS displays information such as the name and owner of
the chain for which the step was created; the step name; the program name and owner; whether
the step should be skipped or not; and whether or not the step should be paused after it
completes.
The ALL_SCHEDULER_RUNNING_CHAINS view contains information such as the chain
name and owner; the name and owner of the job that points to the chain; the name of the steps in
the chain and their current state; errors encountered by the chain step; the time at which the
chain step started and ended; how long it took the step to complete; and the name of the job
running the step, if it is currently executing.
Summary
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Practice 18 Overview:
Automating Tasks with the Scheduler
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Note
a syu cense
This practice M i
y uses both lEnterprise Manager Database Control and SQL*Plus.
n l e
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Advanced Scheduler
Features
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
Program Job Schedule ans
n - t r
a no
a s
) h i d eฺ
Arguments Arguments
c o m Time
G u Event
ฺ
ail den t
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
ki se to
Advanced ScheduleruConcepts
y
Using advanced
s cefeatures,
aScheduler n you can exercise more control over various aspects of
y M l i
a n le such as job windows and prioritizing jobs. These advanced features are summarized
scheduling,
t
below,
S and are discussed in detail in the following slides.
• A window is represented by an interval of time with a well-defined beginning and end, and
is used to activate different resource plans at different times. This allows you to change
resource allocation during a time period such as time of day or time of the sales year.
• A window group represents a list of windows, and allows for easier management of
windows. You can use a window or window group as the schedule for a job to ensure that
the job runs only when a window and its associated resource plan are active.
• A job class defines a category of jobs that share common resource usage requirements and
other characteristics. A job class groups jobs into larger entities.
• A resource consumer group associated with the job class determines the resources that are
allocated to the jobs in the job class.
• A resource plan enables users to prioritize resources (most notably CPU) among resource
consumer groups.
Job Classes
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
bl e
fe r a
EXECUTE DBMS_SCHEDULER.CREATE_JOB_CLASS(-t-ra
ns
job_class_name => 'ADMIN_JOBS', - no
n
s a
) h a
resource_consumer_group => 'DAYTIME_JOBS',
e ฺ -
o m u id
logging_level => DBMS_SCHEDULER.LOGGING_OFF) -
ilฺc
service_name => RACDB1; t G
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating a Job Classuki
a s y ense
You can use the
y ic
M CREATE_JOB_CLASS
l procedure of the DBMS_SCHEDULER package to
e class. A class always belongs to the sys schema. To create a class, you must have
create a ljob
n
the t a
S MANAGE SCHEDULER privilege.
After a job class has been created, you can specify jobs as members of this job class when you
create the jobs, or after the jobs are created, by using the SET_ATTRIBUTE procedure of the
DBMS_SCHEDULER package.
If you are using Enterprise Manager Database Control, use the Job Class page to create or edit a
job class that you will assign to a job. Enter the name of the job class and the resource consumer
group with which this job class is associated. You can select the resource consumer group by
using the search function.
There is a default job class named DEFAULT_JOB_CLASS that is created with the database. If
a job is not associated with a job class, then the job belongs to this default job class.
If a resource consumer group is not specified when a job class is created, the job class maps to
the DEFAULT_CONSUMER_GROUP resource consumer group. Jobs in the default job class or in
a job class associated with the default resource consumer group may not be allocated enough
resources to complete their tasks when the Resource Manager is enabled.
In addition, you can assign a job class an affinity to a specific service in a RAC environment.
Windows
Creating a Window
BEGIN
DBMS_SCHEDULER.CREATE_WINDOW(
window_name => 'DEC_NIGHTS',
resource_plan => 'END_OF_YEAR',
start_date => '01-DEC-07 06.00.00 PM EST',
a b le
repeat_interval => 'FREQ=DAILY; BYHOUR=18',
s fer
duration => '0 12:00:00',
- t r an
end_date => '31-DEC-07 06.00.00 AM EST',
n on
comments => 'Every day at 6:00 PM');
s a
END; a
) h uideฺ
/ o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Creating a Window uki e
y s
asif it islicineeffect.
n Only one window can be in effect at any given time. In the
A window is M open
example l y in the slide:
eshown
n
S• taThe window opens (becomes active) at 6:00 PM on December 1, 2007
• The duration, specified as an INTERVAL DAY TO SECOND data type, indicates that the
window closes at 6:00 AM on December 2, 2007
• The next time the window opens is calculated using the value for REPEAT_INTERVAL,
which evaluates to 6:00 PM on December 2, 2007
• At 6:00 AM on December 31, 2007, the window closes and is disabled. While the
DEC_NIGHTS window is open, the resources allocated to the jobs are determined by the
guidelines specified in the END_OF_YEAR resource plan.
Creating a Window
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Creating a Window (continued) i
a s yu ense
Windows canM
y lic using Enterprise Manager (EM). From the Database home page,
also be created
click the
a n leServer tab, and then click Windows under the Oracle Scheduler section. The example
t
inSthe slide creates the same window as the DBMS_SCHEDULER.CREATE_WINDOW procedure
illustrated in the previous slide.
Job Priority
APPL_JOBS Job2 2
Job3
Job3 3
OTHER
ble
Job4 Job5 Job4 5
fe r a
ans
ADMIN_JOBS Job5
n2- t r
a no
Daytime window a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Prioritizing Jobs Within k i
u nWindow
a
a s y e se
When creating
y c in a database, you need a way to align the job processing with your
Mmultiplelijobs
business
a n lerequirements and specify which jobs have the highest priority. For a particular window,
yout
S may have several classes of jobs running, each with its own priority.
Job classes are used to categorize jobs. The job class maps to a resource consumer group. The
active resource plan determines the resources allocated to each resource consumer group, and
thus to each job class.
There are two levels at which jobs can be prioritized: at the class level and at the job level.
• The first prioritization is at the class level, using resource plans. Prioritization among jobs
of different classes is done purely on a class resource allocation basis.
• The second prioritization is within the class, using the job priority attribute of the job.
Prioritization levels are relevant only when two jobs within the same class are supposed to start
at the same time. The job with the higher priority starts first.
Prioritization is not guaranteed for jobs in different job classes. For example, a high-priority job
in the APPL_JOBS job class might not get started before a low-priority job in the
ADMIN_JOBS job class, even if they share the same schedule. If the APPL_JOBS job class has
a lower level of resource available, then the high-priority job in that class has to wait for
resources to become available, even if there are resources available to lower-priority jobs in a
different job class.
Oracle Database 11g: Administration Workshop II 19 - 10
Computer Pride Limited
Creating an Array of
Lightweight Jobs
1. Declare variables of types sys.job and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
sys.job_array:
DECLARE
newjob sys.job;
newjobarr sys.job_array;
BEGIN
newjobarr := SYS.JOB_ARRAY();
ble
fe r a
s
tran
3. Size the job array to hold the number of jobs needed:
n -
o
newjobarr.EXTEND(100); s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
ki se toJobs
Creating an Array ofuLightweight
y
A more efficient
s to create
away c en a set of jobs is the use of a job array. This also applies to
M l i
l eyjobs. The job array type and CREATE_JOBS procedure are new to the
lightweight
n
Sta
DBMS_SCEHDULER packager in Oracle Database 11g.
In the example in the slide, 100 job specifications are created in a job array and submitted to the
job queue in a single transaction. Notice that for a lightweight job there is a very limited amount
of information needed. In the example, the start_time parameter defaults to NULL, so the
job is scheduled to start immediately. The example continues on the next page.
1. Declare the variable to hold a job definition and a job array variable.
2. Initialize the job array using the SYS.JOB_ARRAY constructor. This creates a place for
one job in the array.
3. Set the size of the array to the number of expected jobs.
Note: If the array is very small, the performance will not be significantly better than submitting
a single job.
END;
/
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Viewing LightweightuJobs k to u
i (Min eDictionary
The changes to a sy ceviews
dictionary
ns to support lightweight are small.
li
y M jobs are
l e
• Lightweight
n visible through the same views as regular jobs are:
t a
S DBA_SCHEDULER_JOBS, ALL_SCHEDULER_JOBS, and USER_SCHEDULER_JOBS.
• Arguments to lightweight jobs are visible through the same views as those of regular jobs:
DBA_SCHEDULER_JOB_ARGS, ALL_SCHEDULER_JOB_ARGS, and
USER_SCHEDULER_JOB_ARGS.
• Because lightweight jobs are not database objects, they are not visible through the
DBA_OBJECTS, ALL_OBJECTS, and USER_OBJECTS views.
PL/SQL APIs
– CREATE_JOB
– CREATE_JOBS
– SET_ATTRIBUTE
– GET_ATTRIBUTE
– SET_JOB_ARGUMENT_VALUE
– RESET_JOB_ARGUMENT_VALUE
– e
bl
STOP_JOB, DROP_JOB
– RUN_JOB · fe r a
ans
• Methods that do not apply to lightweight jobs: n - t r
– SET_JOB_ANYDATA_VALUE a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
PL/SQL APIs k i
a s yu ense
Lightweight jobs
y ic modified and dropped using DBMS_SCHEDULER APIs. Most calls
M are created
l
a n le regular jobs work on lightweight jobs. The methods SET_ATTRIBUTE,
to manipulate
S t
GET_ATTRIBUTE, SET_JOB_ARGUMENT_VALUE, RESET_JOB_ARGUMENT_VALUE,
STOP_JOB, DROP_JOB, and RUN_JOB work with lightweight jobs. The
SET_JOB_ARGUMENT_VALUE procedure can be used to set arguments of lightweight jobs but
only if the arguments are of type VARCHAR2. The job-related DBMS_SCHEDULER calls that do
not apply to lightweight jobs are SET_JOB_ANYDATA_VALUE because lightweight jobs
cannot take ANYDATA arguments.
Note: In the views listed above, the asterisk at the beginning of a view name can be replaced
with DBA, ALL, or USER.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
Globalization
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
• Language support
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Territory support
• Character set support
• Linguistic sorting
• Message support French Japanese
• Date and time formats data data
• Numeric formats
ble
• Monetary formats
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Globalization Support k i
Features
a s yu ense
Different countries
y ic
M andlgeographies dictate different cultural conventions that directly affect
a n le Globalization support ensures that utilities and error messages, sort order, and date,
data formats.
t
time,
S monetary, numeric, and calendar conventions automatically adapt to the native language.
Users can interact, store, process, and retrieve data in their native languages and formats:
• Time zones can be used to support daylight saving time.
• National calendars such as Gregorian, Japanese, Imperial, and Thai Buddha are supported.
• Currency symbols reflect the local economy and ISO conventions. Credit and debit symbols
also differ from location to location.
Oracle’s globalization support is implemented with Oracle NLS Runtime Library (NLSRTL).
NLSRTL provides a comprehensive suite of language-independent functions that allow proper
text and character processing and language convention manipulations. The behavior of these
functions for a specific language and territory is governed by a set of locale-specific data that is
identified and loaded at run time.
You can control the language-dependent operations by using several parameters and
environment variables on both the client and the server sides. The server and the client may run
in the same or different locations. When the client and the server use different character sets, the
Oracle database handles character set conversion automatically.
encoding schemes:
• Single-byte character sets
– 7-bit
– 8-bit
• Multibyte character sets, including Unicode
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
What Is a Character u k
Set?i (M e to u
When computer a sy cprocess
systems e ns characters, they use numeric codes instead of the graphical
li
y Mof the character.
l e
representation
n An encoded character set maps numeric codes to characters that
aS t a
computer or terminal can display and receive. The Oracle database currently supports about 30
encoded character sets, but many more languages and territories (about 100). This is possible
because Unicode is a universal character set, which encompasses most major scripts of the
modern world.
Different character sets support different character repertoires. Because character sets are
typically based on a particular writing script, they can support more than one language.
However, script-based character sets are restricted in the sense that they are limited to groups of
languages based on similar scripts. Universal character sets encompass most major scripts of the
modern world and provide a more useful solution to multilingual support. For information about
the Unicode standards, see the Web site at http:www.unicode.org.
The Oracle database provides different classes of encoding schemes:
• Single-byte
• Varying-width multibyte
• Universal
Understanding Unicode
AL32UTF8 AL16UTF16
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
c 63 0063
á C3 91 Supplementary 00E1
characters
t 74 0074
EE AA 9E A89E
F0 9D 84 9E D834 DD1E
d 64 0064 ble
fe r a
ö C3 B6 00F6 ans
n - t r
o
D0 A4 an
0424
s
h a eฺ
) byte sequences
Encoding: Representing characters with m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Understanding Unicode k i
a s yu ense
Unicode is a universal
y M lic character set that enables information from any language to be
encoded
le a single character set. Unicode provides a unique code value for every character,
storednusing
a
S t
regardless of the platform, program, or language.
The Unicode standard has been adopted by many software and hardware vendors. Many
operating systems and browsers now support Unicode. Unicode is required by standards such as
XML, Java, JavaScript, LDAP, and WML. It is also synchronized with the ISO/IEC 10646
standard.
AL32UTF8 Encoding
AL32UTF8 encoding is the 8-bit encoding of Unicode. It is a variable-width type of encoding
and also a strict superset of ASCII. A strict superset means that each and every character in 7-bit
ASCII is available in AL32UTF8 with the same corresponding codepoint value.
One Unicode character can be 1, 2, 3, or 4 bytes in this encoding. Characters from the European
scripts are represented in either 1 or 2 bytes; characters from most Asian scripts are represented
in 3 bytes, whereas supplementary characters are represented in 4 bytes.
NLS_LANG
ble
fe r a
Oracle Net ans
n - t r
n o
Client a
Server
s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
How Are Character Sets k i
u Used?
a s y e n se
The NLS_LANG
y lic defines a client terminal’s character-encoding scheme. Different
M parameter
le use different encoding schemes. Data passed between the client and the server is
clientsncan
a
S t
converted automatically between the two encoding schemes. The database’s encoding scheme
should be a superset, or equivalent, of all the clients’ encoding schemes. The conversion is
transparent to the client application.
When the database character set and the client character set are the same, the database assumes
that the data being sent or received is of the same character set, so no validations or conversions
are performed.
Character set conversion may be required in a client/server environment, if a client application
resides on a different platform than the server and if the platforms do not use the same character-
encoding schemes. Character data passed between the client and the server must be converted
between the two encoding schemes. Character conversion occurs automatically and
transparently through Oracle Net.
Problems to Avoid
Example:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
NLS_LANG:
AL32UTF8 Oracle Net
Client Server
Windows English Database character set: e
Code page: WE8MSWIN1252 AL32UTF8 r a bl
sfe
No conversion occurs, because it does not seem to be tran
o n -
required.
s an
ha eฺ
Issue: Invalid data are entered into the database.
) id
o m G u
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Problems to Avoid uki e
y
as enters s
ea ndatabase when the NLS_LANG parameter is not set properly on the
Invalid data usually
M l i c
l
client. The
n eyNLS_LANG value should reflect the encoding of the incoming data.
S• taWhen the NLS_LANG parameter is set properly, the database can automatically convert
incoming data from the client operating system.
• When the NLS_LANG parameter is not set properly, the data entering the database is not
converted properly.
For example, suppose that the database character set is AL32UTF8, the client is an English
Windows operating system (code page: WE8MSWIN1252), and the NLS_LANG setting on the
client is AL32UTF8. Data entering the database is encoded in WE8MSWIN1252 and is not
converted to AL32UTF8 data because the NLS_LANG setting on the client matches the database
character set. Thus the Oracle database assumes that no conversion is necessary, and invalid data
is entered into the database.
bl e
fe r a
ans
n - t r
a no
a s
) h
% export NLS_LANG=‘SIMPLIFIED
i d eฺ
CHINESE_HONG m Gu
co nKONG.ZHS16GBK’
i l ฺ t
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Another Sample Problem k i
a s yu ense
For example, M
y ic character set is US7ASCII and you are using Simplified Chinese
your database
l
Windows
a n leas your client terminal. By setting NLS_LANG to SIMPLIFIED CHINESE_HONG
S t
KONG.ZHS16GBK as the client character set, you can store multibyte Simplified Chinese
characters inside a single-byte database. This means that the database treats these characters as
single-byte characters. Therefore, all SQL string manipulation functions (such as SUBSTR or
LENGTH) are based on bytes rather than characters. All of your non-ASCII characters could be
lost following an export and import into another database.
• Trade-offs to consider
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Choosing Your Character k i
u nSet
a s y e se
For best performance,
y M lic a character set that avoids character set conversion and uses the
choose
a n le encoding for the languages desired. Single-byte character sets result in better
most efficient
S t
performance than multibyte character sets, and they also are the most efficient in terms of space
requirements. However, single-byte character sets limit how many languages you can support.
To choose your correct database character set, evaluate your current and future business
requirements, as well as technical requirements (for example, the XML and Java standards
require Unicode). In general, Oracle recommends the use of Unicode for all new databases,
because it is the most flexible character set and avoids future conversions.
To specify the character set, use the CREATE DATABASE statement with the CHARACTER SET
and NATIONAL CHARACTER SET clauses. If you do not use the NATIONAL CHARACTER
SET clause, then it defaults to AL16UTF16.
You may need to change the character set after database creation, to support unforeseen
requirements, for example, to provide support for new data sources (XA, data warehousing, and
so on). This can often be a time-consuming and costly process. In most cases, you need to do a
full export or import to properly convert all data to the new character set.
PARAMETER VALUE
----------------------- -------------
NLS_CHARACTERSET WE8ISO8859P1
NLS_NCHAR_CHARACTERSET AL16UTF16
ble
fe r a
2 rows selected.
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Obtaining CharacteruSet k i (Information
a s y ense
y M lic
Use the NLS_DATABASE_PARAMETERS view to display the permanent NLS settings for the
database,
a n leincluding the database and national character sets. This view contains the explicitly set
t
values,
S as well as the default values used by the database.
SQL function
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
SELECT sysdate FROM m
co dual;G u
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Specifying Language-Dependent i
u nse Behavior
s y
a retrieving e data for most contemporary languages in a database, additional
Beyond storing
y M and l i c
supportn iseavailable
l for a subset of the languages. The database can display dates by using local
t
date a
S and time formats and can sort text data according to cultural conventions. The database also
supports cultural conventions that are specific to geographical locations, or territories, such as
numeric and monetary conventions.
NLS parameters determine the locale-specific behavior on both the client and the server. There
are four ways to specify national language support (NLS) parameters:
• As initialization parameters on the server side to specify the default server environment.
(These default settings have no effect on the client side.)
• As environment variables for the client to specify locale-dependent behavior overriding the
defaults set for the server
• Using the ALTER SESSION command to override the defaults set for the client and the
server
• In SQL functions, to explicitly to hard-code NLS behavior for an application or query
overriding the default values that are set for the server and client, as well as any values
specified with an ALTER SESSION statement
Specifying Language-Dependent
Behavior for the Session
• Specify the locale behavior with the NLS_LANG environment
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
variable:
– Language
– Territory
– Character set
NLS_LANG=FRENCH_CANADA.WE8ISO8859P1
NLS_LANGUAGE AMERICAN
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_DUAL_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_DATE_FORMAT DD-MON-RR ble
NLS_NUMERIC_CHARACTERS ., fe r a
ans
NLS_TIMESTAMP_FORMAT
NLS_TIMESTAMP_TZ_FORMAT
DD-MON-RRHH.MI.SSXFF AM
n
DD-MON-RRHH.MI.SSXFF AM TZR - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Language-Dependent k i
u nTerritory-Dependent
and e Parameters
s y s
a lice and NLS_TERRITORY initialization parameters determines the
Setting the NLS_LANGUAGE
M
l ey that should be used by the Oracle database. You can override these default values
defaultnvalues
by a
Stexplicitly setting the values for those initialization parameters whose default values depend
on the settings of NLS_LANGUAGE and NLS_TERRITORY.
NLS_LANGUAGE Initialization Parameter
The NLS_LANGUAGE initialization parameter determines the default values of the following
parameters:
Column Description
NLS_DATE_LANGUAGE Determines the language for day and month
names and abbreviations and spelled values of
other date format elements
NLS_SORT Changes the linguistic sort sequence that the
Oracle database uses to sort character values.
(The sort value must be the name of a linguistic
sort sequence.)
Column Description
NLS_CURRENCY Specifies the local currency symbol
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Column Description
NLS_CALENDAR Specifies which calendar system is used by the
Oracle database
NLS_COMP Can be set to ANSI or BINARY. When
NLS_COMP is set to ANSI, SQL operations
perform a linguistic comparison based on the
value of NLS_SORT.
NLS_LENGTH_SEMANTICS Enables you to create CHAR, VARCHAR2, and
LONG columns by using either byte or character
length semantics.
DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT',
'''DD.MM.YYYY''') ;
SELECT TO_CHAR(hire_date,'DD.Mon.YYYY',
ble
'NLS_DATE_LANGUAGE=FRENCH')
fe r a
FROM employees
ans
WHERE hire_date > '01-JAN-2000';
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Specifying Language-Dependent
u nse Behavior
s y
a liissuing e ALTER SESSION commands, you can use the
In addition toM
explicitly c
l ey
DBMS_SESSION.SET_NLS
n database procedure, specifying the name of the parameter to
t a
change
S and the new value of the parameter. The second example shown in the slide performs the
same action as the first example, but uses the DBMS_SESSION package.
Client utilities such as SQL*Plus and SQL*Loader read the environment variables set on the
client and issue the corresponding ALTER SESSION command after they are connected to the
database.
The third example shows the use of the NLS_DATE_LANGUAGE NLS parameter in the
TO_CHAR SQL function.
• Case-sensitivity
• Diacritics or accent characters
• Combination of characters that is treated as a single
character
• Phonetics or character appearance
• Cultural preferences
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Linguistic Searchinguand k i (M
Sortingt o
a s y ense
Different languages
y M have licdifferent sort orders. In addition, different cultures or countries that use
the same
a n lealphabets may sort words differently. For example, in Danish, Æ is after Z, whereas Y
andt
S Ü are considered to be variants of the same letter. Sort order can:
• Be case-sensitive or non-case-sensitive
• Ignore or consider diacritics (a mark near or through a character or combination of
characters that indicates a different sound than the sound of the character without the
diacritic)
• Be phonetic or it can be based on the appearance of the character (such as the number of
strokes in East Asian ideographs)
Another common sorting issue is combining letters into a single character. For example, in
traditional Spanish, ch is a distinct character that comes after c, which means that the correct
order is: cerveza, colorado, cheremoya. This means that the letter c cannot be sorted until the
database has checked whether the next letter is an h.
To produce a sort sequence that matches the alphabetic sequence of characters, another sort
technique must be used that sorts characters independently of their numeric values in the
character-encoding scheme. This technique is called a linguistic sort. A linguistic sort operates
by replacing characters with numeric values that reflect each character’s proper linguistic order.
• Binary sorting
– Sorted according to the binary values of the encoded
characters
• Monolingual linguistic sorting
– A two-pass sort based on a character’s assigned major and
minor values
• Multilingual linguistic sorting e
r a bl
– Based on the ISO standard (ISO 14651), and the Unicode 3.2
n s fe
Standard for multilingual collation
n - tra
– Ordered by the number of strokes, PinYin, or radicals
a no for
Chinese characters a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Linguistic Searchinguand k i (M
Sortingt o (continued)
a s y ense
A binary sort M
y lic sorting mechanism by which letters are sorted according to the
is a conventional
le used to encode the characters. Binary sorts are the fastest type of sort. They
binarynvalues
a
t
produce
S reasonable results for the English alphabet because the ASCII and EBCDIC standards
define the letters A through Z in ascending numeric value. When characters used in other
languages are present, a binary sort usually does not produce reasonable results.
For monolingual sorting, the Oracle database uses major and minor values to compare
characters. Usually, letters with the same appearance have the same major value. For example,
A, a, and ä. The Oracle database defines letters with diacritics and case differences as having the
same major value but different minor values.
In a monolingual sort, the database makes two passes when comparing strings in monolingual
sorts. The first pass is to compare the major value of the entire string from the major table and
the second pass is to compare the minor value from the minor table. Although this provides
better sorting than binary, it is still limited.
Multilingual sorts enable you to sort data in more than one language in a single sort. This is
useful for regions or languages that have complex sorting rules.
Refer to the Oracle Database Globalization Support Guide for more information about the
supported linguistic sorts.
You can specify the type of sort used for character data with
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
the:
• NLS_SORT parameter
– Default value derived from the NLS_LANG environment
variable, if set
– Can be specified for the session, client, or server
• NLSSORT function
– Defines the sorting method at the query level e
r a bl
s fe
- t r an
n
no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Using Linguistic Searching i
u nsand e Sorting
s y
To overcomeM thealimitations
l i c e of binary sorting, you can specify linguistic sorts by setting the
l
NLS_SORT
n ey parameter or by using NLSSORT in your query.
StaNLS_SORT Parameter
The
Consider the following words stored in a database by using the WE8ISO8859P1 character set:
• gelée
• gelé
• gèle
• gelez
If NLS_SORT is set to BINARY, gelez is sorted before gelé. This occurs because e has a
binary value lower than è in the WE8ISO8859P1 character encoding.
If NLS_SORT is set to the FRENCH monolingual sort, the word gelé is sorted before gelez
and gèle, which still does not satisfy all the nuances of the French language. For example, in
the French language, letters are sorted from left to right and accents from right to left.
When NLS_SORT is set to the FRENCH_M multilingual sort, both the characters and the
diacritics are sorted properly.
Session altered.
FR_WORD
-------
gelez
gelé
ble
gelée
fe r a
gèle
ans
n - t r
SQL> SELECT fr_word
a no
2 FROM words a s
3 ORDER BY NLSSORT(fr_word,'NLS_SORT=FRENCH_M');) h i d eฺ
m
co nt Gu
i l
a de ฺ
FR_WORD
g m tu
--------
i @ S
gèle
s y uk this
gelé
( M a use
gelée
y u ki se to
gelez
M as licen
n l ey
Sta
• Examples:
NLS_SORT = FRENCH_M_AI
NLS_SORT = XGERMAN_CI
NLS_COMP settings:
– WHERE
– ORDER BY
– START WITH
– HAVING
– IN/NOT IN
– BETWEEN e
– r a bl
CASE-WHEN
ns fe
n - tra and
• The NLSSORT() function supports the case-insensitive
o
accent-insensitive functionality. an s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
Support in SQL anduFunctionsi (M e to u
a sy incthe e s
nslide
The SQL clauses
M listed l i are affected when the _AI or _CI options are appended to
y
t a nle SELECT
the NLS_SORT parameter.
S cust_last_name
FROM customers
WHERE NLSSORT(cust_last_name, 'NLS_SORT = generic_m_ai')
= NLSSORT('De Niro', 'NLS_SORT=generic_m_ai');
CUST_LAST_NAME
--------------------
de Niro
De Niro
dë Nirõ
You typically use the NLSSORT function in an ORDER BY or WHERE clause when the linguistic
setting of the session parameter NLS_SORT is different from the linguistic setting in the SQL
statement. The example (given on this page) searches for all occurrences of “De Niro”
regardless of the case and accent. You can get the same result as shown in the example by
setting the NLS_COMP parameter:
ALTER SESSION SET NLS_SORT=generic_m_ai;
ALTER SESSION SET NLS_COMP=ansi;
Customizing Linguistic
Searching and Sorting
You can customize linguistic sorting for:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Ignorable characters
• Contracting or expanding characters
• Special combination letters or special letters
• Expanding characters or special letters
• Special uppercase and lowercase letters
• Context-sensitive characters
ble
• Reverse secondary sorting
fe r a
• Canonical equivalence ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Customizing Linguistic k i
u nse and Sorting
Searching
s y
a andlicsorting
e has many features. Many of these features are customizable, so
Linguistic searching
M
you cann l ey the desired results from your data. For example:
retrieve
S• taNow you can also specify a sort or query on the base letters only (accent-insensitive) or on
the base letter and the accents (case-insensitive).
• You can specify that the dash punctuation character should be ignored so that e-mail can
be treated in the same way as email.
• The expanding character ö sorts as if it were oe, after od and before of.
• You can properly sort prolonged sound marks in Japanese.
• Making ä equivalent to its base letter, a, and an umlaut, ¨, so that ä and a¨ are considered
equal.
• You can have a character with a diacritic placed before or after its unmarked variant.
• Whether or not in Thai and Lao, some characters first change places with the following
character before sorting.
• You can map lowercase letters to multiple uppercase letters, such as the German ß to SS,
and uppercase letters to multiple lowercase letters, such as the Turkish I becoming a small,
dotless i: ı.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Implicit Conversion
Between CLOB and NCLOB
Transparent implicit conversion is supported in:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Implicit Conversion u k
Between to uand NCLOB
i (M eCLOB
Converting data a sy cUnicode
between e ns and the database national language character set is becoming
li Explicit conversion between CLOB and NCLOB is already
y M requirement.
l e
a more frequent
n
Sta in SQL and in PL/SQL with the TO_CLOB and TO_NCLOB functions. Oracle
available
Database performs implicit conversion for SQL IN and OUT bind variables in queries and DML
operations, as well as for PL/SQL function and procedure parameter passing and PL/SQL
variable assignment. For example, conversion is completely transparent in the following
scenario:
CREATE TABLE my_table (nclob_col NCLOB);
DECLARE
clob_var CLOB;
nclob_var NCLOB;
BEGIN
clob_var := 'clob data'; -- initialize the CLOB
INSERT INTO my_table VALUES (clob_var);
-- Bind a CLOB into an NCLOB column
SELECT nclob_col
INTO clob_var FROM my_table;
-- Define an NCLOB column as a CLOB var
END;
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
NLS Data Conversion k i
u nData
with e Pump
s y
a settings s
e used by the session that initiated Data Pump are used within the
The NLS parameter
M l i c
l
Data Pump
n eyjob. Therefore, ensure that the parameters are set correctly before you start any Data
Sta job. The client NLS_LANG settings are used only for messages returned by the Data Pump
Pump
utilities, such as impdp or expdp.
During the execution of a job, a log file is optionally written. The log file summarizes the
progress of the job and any errors that were encountered along the way. Data Pump writes the
log file by using the NLS_LANG setting of the client. For example, setting NLS_LANG to
French.WE8DEC causes all messages for the job to be displayed in French, even if the job is
restarted from an American.WE8DEC client.
If you use a parameter file (PARFILE) with Data Pump, the parameter file is assumed to be in
the client’s character set. The Data Pump utility translates the text strings in the parameter files
into the database character set. If the parameter file is in a different character set than that being
currently used by the client, then you must alter the NLS settings of the client to ensure a proper
translation.
Character set
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(Set
Language and Character k i
u nseFile Scanner (LCSSCAN)
s y
a Character e Set File Scanner (LCSSCAN) is a high-performance, statistically
The LanguageMand l i c
based n l ey for determining the language and character set for unknown file text. It can
utility
Sta
automatically identify a wide variety of language and character set pairs. With each text, the
language and character set detection engine sets up a series of probabilities, each probability
corresponding to a language and character set pair. The most statistically probable pair identifies
the dominant language and character set.
The syntax for the lcsscan utility is shown below:
LCSSCAN [RESULTS=number] [FORMAT=file_type] [BEGIN=number]
[END=number] FILE=file_name
Below are the meanings of the parameters:
• FILE: The text file that contains the text to scan
• RESULTS: The number of language and character set pairs you expect to be identified.
• FORMAT: The format of the file to be scanned. This can be text, html, or auto.
• BEGIN: The byte number of where the scanner is to begin scanning the file.
The default is 1.
• END: The byte number of where the scanner is to stop scanning the file. The minimum is 3,
and the default is the last byte of the file.
Note: For more information about LCSSCAN, refer to the Oracle Database Globalization
Support Guide.
Oracle Database 11g: Administration Workshop II 20 - 33
Computer Pride Limited
following:
• The SET TIME_ZONE clause of the CREATE DATABASE
statement
• The time zone of the operating system on the database
server host
• The time zone specified by the ALTER SESSION SET
TIME_ZONE command e
r a bl
s fe
CREATE DATABASE ... SET TIME_ZONE='-04:00';
- t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Setting the DatabaseuTime k i (MZone t o
a s y ense
Set the database
y M time zone
l ic when the database is created by using the SET TIME_ZONE clause
a n le
of the CREATE DATABASE statement. If you do not set the database time zone, then it defaults
t
toSthe time zone of the server’s operating system. The time zone may be set to an absolute offset
from UTC or to a named region. To set the time zone to an offset from UTC, use a statement
similar to the one shown in the slide. To set the time zone to a named region, use a TIME_ZONE
string such as:
SET TIME_ZONE='Europe/London';
You can determine the time zone of the database by running the following query:
SELECT dbtimezone FROM DUAL;
Note: For more information about setting the time zone and how that affects time-based data in
your database, refer to the Oracle Database Globalization Support Guide.
Summary
Practice 20 Overview:
Using Globalization Support
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Appendix A
Practices and Solutions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Table of Contents
Practices for Lesson 1 ......................................................................................................... 4
Practice 1-1: Upgrade the Database Storage to ASM..................................................... 5
Practice 1-2: ASM Fast Mirror Resync ........................................................................ 19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
In these practices, you upgrade the database storage from file system files to ASM. You
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
3) On the next page, select Configure Automatic Storage Management from the list of
possible operations, and then click Next to continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
4) You are asked to irun t u
(Mthe localconfig
o script to set up local Cluster
u k e
sy cService
Synchronization
a e ns (CSS) for high availability purposes.
yM li
n l e
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
5) Open a terminal window and run the localconfig add script as root.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
no
When the script has completed, click OK to close the localconfig dialog box.
a
a s
) h i d eฺ
6) After returning to the Operations page, click Nexto m
c to continue.
G u
i l ฺ t
g ma tuden
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
7) The new ASM instance must have a password for the SYS account. Use oracle for
the password and click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
8) Click OK to start the ASM instance. a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
s y u nse
M a
Wait a few moments
l i c e the instance starts.
while
n l ey
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
a Normal
10) Enter DATA for the Disk Group Name and
g mselect t u de redundancy. Select the first
k i@and click
four raw slices that are 3 GB in size,
i s SOK.
u
sy se t h
a
(M to u
k i
a syu cense
yM li
n l e
Sta
11) Click Create New to create the next diskgroup for the flash recovery area.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
(M Group
12) Enter FRA for thei Disk t o u and select External Redundancy. There will be
Name
k e Select them and click OK to continue.
syu ofc3eGB
four raw slices
a nsleft.
yM li
n l e
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m Guto continue.
coClick nFinish
l
13) Both diskgroups should be mounted at this stage.
i ฺ t
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
ble
fe r a
s
17) In the Files to Be Migrated section, select all three check boxes: Database Files,
an
n - t r
Recovery-related Files, and Parallelze File Copy Operations. The working directory
should be the same as the database home,
a no
/u01/app/oracle/product/11.1.0/db_1/dbs. Click Next to continue.
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
18) In the Database Area section, enter DATA in the Database Area field. In the Flash
Recovery Area section, enter FRA in the Flash Recovery Area field and change the
Flash Recovery Area Size to 4096. Select Setup Flash Recovery Area and Migrate
Recovery-related Files and then click Next to continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
19) On the Schedule page, select Immediately
k S Start section and click Next to
i@ iins the
continue. u
sy se t h
a
(M to u
k i
a syu cense
yM li
n l e
Sta
20) On the Review page, examine your selections. If you have made any errors, use the
Back button to go back and correct them. Click Submit Job when ready.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ
g ma tStatus
21) After the job has been submitted, click the View
progress. It takes several minutes to complete. u denbutton to monitor the job’s
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
That takes you to the Job Activity page. When the job finishes, you will be disconnected
from Enterprise Manager.
ble
fe r a
an
On the +ASM home page, you see that the DATA diskgroup is associated with the orcl s
instance storage. n - t r
n o
23) Now that the database has been migrated to ASM, you can remove a
s allฺthe files that
h a
were stored in the traditional file system.
m ) u i de
o
$ cd $ORACLE_BASE/oradata/orcl
a ilฺc ent G
ud
$ pwd
/u01/app/oracle/oradata/orclgm t
@
ki this S
$ ls -l
y u
total 1906132
-rw-r----- 1 (oracle M as oinstall
u se 9748480 Sep 24 20:44
k i t o
nse oinstall 9748480 Sep 24 20:44
syu c1 eoracle
control01.ctl
a
-rw-r-----
li
l e yM
control02.ctl
tan control03.ctl
-rw-r----- 1 oracle oinstall 9748480 Sep 24 20:44
S -rw-r----- 1 oracle oinstall 104865792 Sep 24 20:44
example01.dbf
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo01.log
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo02.log
-rw-r----- 1 oracle oinstall 52429312 Sep 24 21:08
redo03.log
-rw-r----- 1 oracle oinstall 680140800 Sep 24 20:44
sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Sep 24 20:44
system01.dbf
-rw-r----- 1 oracle oinstall 29368320 Sep 24 20:35
temp01.dbf
-rw-r----- 1 oracle oinstall 209723392 Sep 24 20:44
undotbs01.dbf
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
observe?
a) Set the proper environment variables for the +ASM instance. Run the query in the
following screenshot to check COMPATIBLE values for both ASM and the
database. You should see that both compatibility values are set to 10.1.
$ export ORACLE_SID=+ASM
$ export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
$ export PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:
/usr/bin:/usr/local/bin:/usr/X11R6/bin
$ sqlplus / as sysasm
ble
fe r a
SQL> select name,compatibility,database_compatibility from
ans
v$asm_diskgroup;
n - t r
NAME COMPATIBILITY DATABASE_COMPATIBILITY
a no
a s
-------------------- ------------------ ----------------------
DATA 10.1.0.0.0 ) h
10.1.0.0.0
i d eฺ
FRA 10.1.0.0.0 m
co nt Gu
10.1.0.0.0
i l ฺ
g ma tude
k S disk group page.
i@to theisDATA
s y u
2) Using Enterprise Manager, navigate t h
a s e
to u lab. For example:
i (Mtheeprevious
a) Connect to Enterprise Manager Database Control as user SYS using the URL that
k
was givenuduring
a sy cens
https://edrsr14p1.us.oracle.com:1158/em/
M li
b)y Click the +ASM link on the main Database page.
n l e
Sta c) On the ASM home page, click the Disk Groups tab.
d) On the Automatic Storage Management Login page, enter sys in the Username
field and oracle in the Password field, and select SYSASM from the Connect As
drop-down list. Select the Save as Preferred Credentials check box. Then click
Login.
e) On the ASM home page, click the Disk Groups tab.
f) On the Disk Groups page, click the DATA link in the table.
3) Using Enterprise Manager Database Control, change both the Database compatibility
and ASM compatibility attributes of the DATA disk group. Set them both to
11.1.0.0.0. What do you observe after having changed these two parameters?
a) On the Disk Group: DATA General subpage, click Edit in the Advanced
Attributes section.
Advanced Attributes section. You should also see that disks are around thirty
percent full.
4) Use SQL*Plus to verify that the previous update was done correctly:
a) From a terminal window, connected as the user oracle, launch SQL*Plus and
look at V$ASM_DISKGROUP:
$ export ORACLE_SID=+ASM
$ export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
$ export
PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:/usr/bin:/us
ble
r/local/bin:/usr/X11R6/bin
fe r a
$ sqlplus / as sysasm
ans
SQL> select name,compatibility,database_compatibility from
n - t r
v$asm_diskgroup;
a no
a s
NAME COMPATIBILITY DATABASE_COMPATIBILITY
) h i d eฺ
------ -------------
m
----------------------
c o t Gu
DATA
FRA
11.1.0.0.0
10.1.0.0.0
11.1.0.0.0
i
a denl ฺ
g m10.1.0.0.0 tu
i @ S
s y uk this
5) Execute the asm_setup.sh
( M a script u sefrom the labs directory to set up the
i practice.
environment forkthis
u e toThe script creates a new tablespace called TBSJMW in
the DATA
a y
sdisk groupe s
nusing a 50 MB file. It then creates a new table called
y M
SYSTEM.JMW l i c
residing in this new tablespace. The script then inserts some rows in
n l e
the newly created table.
Sta $ cd ~/labs
$ ./asm_setup.sh
#!/bin/bash
cd /home/oracle/solutions/lesson1
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export
PATH=/u01/app/oracle/product/11.1.0/db_1/bin:/bin:/usr/bin:/us
r/local/bin:/usr/X11R6/bin
commit;
begin
for i in 1..10 loop
ble
insert into jmw select * from jmw;
end loop; fe r a
commit; ans
end; n - t r
/
a no
a s
EOF ) h i d eฺ
m u sure that the Disk
o groupt making
cdisk G
6) Offline the second disk that is part of the DATA i l ฺ
Repair Time attribute is set to 0:
g ma tuden
a) Back to the Disk Group: DATA k i@Generali s S
page, select the second disk
u
sy Offline. t h
(DATA_0001), andaclick
u s e
k i (M page,
b) On the Confirmation t o change the Disk Repair Time from its default (3.6
hours)sto
a n seShow SQL.
yu0 andeclick
y M DISKGROUPlic DATA OFFLINE DISK DATA_0001 DROP AFTER 0 h
n l e
ALTER
SQL> commit;
9) Add the dropped ASM disk back to the DATA disk group:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
a) You now need to wipe out the dropped disk before you can add it back. You must
be root to do this:
# dd if=/dev/zero of=/dev/raw/raw2 bs=1M count=20
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.
level (around 30% full), without the need of any rebalance operation. The disk is
added back immediately.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
$ export ORACLE_SID=+ASM
$ asmcmd
ASMCMD> ls +DATA/*
+DATA/ASMTESTING/:
DATAFILE/
+DATA/ORCL/:
CHANGETRACKING/
DATAFILE/
ble
ONLINELOG/
fe r a
TEMPFILE/
ans
ASMCMD> ls +DATA/ORCL/DATAFILE n - t r
EXAMPLE.260.630800437
a no
SYSAUX.257.628766309
a s
SYSTEM.256.628766309 ) h i d eฺ
TBSJMW.269.628767357 m
co nt Gu
i l ฺ
ma tude
UNDOTBS1.258.628766309
USERS.259.628766309 g
u k i@ is S
a sy se th
i M to u
(create
2) Using ASMCMD,
y u k s e a new directory called jmw in the DATA disk group. Then
create an s
a alias lcalled
c n
e +DATA/jmw/mytbs.f that points to the file used to store
y
yourMTBSJMW i
tablespace.
nle
Sta $ export ORACLE_SID=+ASM
$ asmcmd
ASMCMD> cd +DATA/ORCL/DATAFILE
ASMCMD> ls
...
TBSJMW.269.630835753 (Your numerical extension will be different!)
...
ASMCMD>
3) Use ASMCMD to back up ASM metadata for the DATA disk group:
ASMCMD> md_backup -g data
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
In this practice, you configure your database to archive redo logs before reusing them.
1) Set up the environment for the ORCL database, using the oraenv script, and enter
orcl when prompted for ORACLE_SID. If it is already set up for orcl (that is, you
see orcl in the brackets), press Enter.
Note: This command is a period, followed by a space, and then the oraenv script
name.
$ . oraenv
ORACLE_SID = [+ASM] ? orcl
ble
2) Run the size_memory_down.sh script to size the database appropriately for the
fe r a
following practices.
an s
$ cd ~/labs n - t r
$ ./size_memory_down.sh
a no
a s
) h
3) Determine the archive mode your database is running in now.
i d eฺ
m
co nt Gu
$ sqlplus / as sysdba
i
a de l ฺ
SQL*Plus: Release 11.1.0.6.0g- mProduction tu on Sat Jul 14
i @ S
02:17:17 2007
s y uk this
Copyright (c) 1982,
( M a 2007,
u seOracle. All rights reserved.
y u ki se to
M as to:
Connected l i c en
y
nleOracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Sta Production
With the Partitioning, OLAP and Data Mining options
$ . oraenv
2) Start RMAN.
$ rman target /
RMAN>
5) Take a backup of data file 5, and note where the backup is written.
RMAN> backup datafile 5;
RMAN>
Note that the backup file is written to the Flash Recovery Area.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
$ . oraenv
2) Return to the RMAN session and show the current retention policy setting.
RMAN> show retention policy;
RMAN>
ble
Note that there is currently no retention policy configured. fe r a
ans
t r
3) Change the retention policy to ensure that at least one copy of each file is backed up.
n -
RMAN> configure retention policy to redundancy 1; a no
a s
old RMAN configuration parameters: ) h i d eฺ
CONFIGURE RETENTION POLICY TO NONE;co m G u
new RMAN configuration parameters: i l ฺ
a den1; t
CONFIGURE RETENTION POLICY TO g mREDUNDANCY
tu successfully stored
new RMAN configuration k i @ is Sare
parameters
a s yu e th
RMAN>
i ( M to us
y uk policy
4) Check the retention
s n se setting again.
a ic e
l e y M show lretention
RMAN> policy;
n
Sta RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
RMAN> exit
$lsnrctl stop
ble
Copyright (c) 1991, 2007, Oracle. All rights reserved.
fe r a
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
an s
TNS-12541: TNS:no listener
n - t r
TNS-12560: TNS:protocol adapter error
a no
TNS-00511: No listener
a s
Linux Error: 2: No such file or directory
) h i d eฺ
Connecting to
m
co nt Gu
i l ฺ
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edu1r2p0.us.oracle.com)(PORT=
ma tude
1521)))
g
i@pressisCtrlS+ C to escape back to the prompt.
If this command appears to “hang,”kthen
u
a sy se th
k i (M to u
Now, restart the listener:
a yu ense
sstart
lic
$ lsnrctl
l e y Mfor Linux:
tan14:05:03
LSNRCTL Version 11.1.0.6.0 - Production on 12-NOV-2008
S
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edu1r2p0.us.oracle.com)(PORT=
1521)))
The listener supports no services
ble
The command completed successfully
fe r a
ans
n - t r
2) Use DBCA to start the process of creating a recovery catalog database.
a no
$ dbca
a s
) h i d eฺ
m
co nt Gu
3) On the Welcome page, click Next. i l ฺ
g ma tude
4) On the Operations page, select theiCreate
k S option, and then click Next.
@ aisDatabase
u
sy se t h
a
(M to u
k i
a syu cense
yM li
l e
Stan
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
coof General
G u
i l ฺ
5) On the Database Templates page, leave the default
a n t Purpose or Transaction
Processing, and then click Next. gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
n l ey
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m Gu Manager option,
co nEnterprise
7) On the Management Options page, deselect the ฺConfigure
i l t
and then click Next.
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan
8) On the Database Credentials page, select the option Use the Same Administrative
Password for All Accounts. Then enter oracle in the password fields and click Next.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
9) On the Storage Options page, select File System asothe u
storage mechanism,
G and then
click Next. ฺ
ail den t
m
g Stu
i @
s y uk this
( M a use
y u ki se to
M as licen
n l ey
Sta
10) On the Database File Locations Page, select Use Common Location for all Database
Files, and enter /u01/app/oracle/oradata as the path. Then click Next.
ble
fe r a
ans
n - t r
a no
h a s ฺ
11) On the Recovery Configuration page, increase the size )of the Flash
i d eRecovery Area to
o m G u
4096 MB. Then click Next.
a ilฺc ent
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta
12) On the Database Control page, enable the Sample Schemas option, and then click
Next.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co size G u
i l ฺ
13) On the Initialization Parameter page, set the memory
a Next. den tto 300 MB, enable
Automatic Memory Management, and then m
click
g Stu
i @
s y uk this
( M a use
y u ki se to
M as licen
n l ey
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g madisable
15) On the Automatic Maintenance Task page,
t u dtheeautomatic tasks, and click
Next.
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i
a del ฺ
g mthat
17) On the Creation Options page, make sure tu Database is the only option
Create
selected, and then click Finish. uk i @ is S
s y t h
( M a use
y u ki se to
M as licen
n l ey
Sta
18) Review the Confirmation page, and then click OK to start the database creation
process.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g mthea database.
The Database Creation Assistant now creates t u de
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ
then click Exit. g m tuden view the final page, and
19) When the Database Configuration Assistantafinishes running,
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options
ble
SQL>
fe r a
an s
t r
2) Create a tablespace named RCAT to hold the repository data. Make it 15 MB in size.
n -
n o
SQL> create tablespace rcat datafile a
ssize 15M;
‘/u01/app/oracle/oradata/rcat/rcat01.dbf’
) h a eฺ
m i d
Tablespace created.
i l ฺ co nt Gu
SQL> g ma tude
k i@ catalog
3) Create a user who will own theurecovery i s Sdata. Name the user RCATOWNER.
The default tablespace should sbey the RCAT
e h
t tablespace, and the user should have
unlimited quota on that (M a
tablespace. u s
k
u nsei t o
a syuser c ercatowner identified by oracle
M
SQL> create
y l i
l e
2 default tablespace rcat
SQL>
Grant succeeded.
SQL> exit
18 03:38:21 2007
RMAN>
2) Create the recovery catalog. This command may take several minutes to complete.
RMAN> create catalog;
ble
fe r a
recovery catalog created
ans
n - t r
no
RMAN> exit
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
$ . 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
ble
fe r a
ans
n - t r
n o
d) On the Review page, click Finish. s a
e) Back on the Recovery Catalog Settings page, select)Use haRecovery
i d eฺCatalog.
m u
o t isGselected
cregistered
i l
f) Make sure that the recovery catalog you just
a ฺ n in the drop-
down list, and then click OK. gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
y
nle
Sta
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ sqlplus / as sysdba
SQL> alter tablespace users offline;
Tablespace altered.
SQL>
Tablespace k i (M to us
altered.
a s yu ense
yM
SQL> lic
l e
n4) Start an RMAN session, connecting to the ORCL instance as the target, and also
Sta connecting to the RCAT instance as the recovery catalog. Again, use oraenv to set
up the environment for the ORCL instance.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ rman target / catalog rcatowner/oracle@rcat
RMAN>
RMAN-00571:
===========================================================
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
RMAN>
Note that there are none at this point.
6) Catalog the image copy of the USERS data file. ble
fe r a
RMAN> catalog datafilecopy '/tmp/users_copy.dat';
an s
n - t r
cataloged datafile copy
a no
datafile copy file name=/tmp/users_copy.dat RECID=3
a s
STAMP=628295424
) h i d eฺ
m
co nt Gu
RMAN> i l
a de ฺ
g
7) Again, list the data file copies available.mThen exittuRMAN.
i @ S
RMAN> list datafilecopy
s y ukall; this
( M a use
starting full
u i resync
kcomplete e toof recovery catalog
y
asDatafile
full resync s
en Copies
M
List
y
of
l i c
nle
=======================
RMAN> exit
Note that the data file copy you made manually is now listed as a backup in the
recovery catalog.
RMAN>
2) Make sure that the retention policy is set to redundancy greater than 1. If it is not, set ble
it to at least 2.
fe r a
ans
RMAN> show retention policy;
n - t r
a no
using target database control file instead of recovery catalog
a s
RMAN configuration parameters for database with db_unique_name
) h i d eฺ
RCAT are:
m
co nt Gu
i l ฺ
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of backup plus archivelog command at
07/18/2007 22:55:45
ORA-19602: cannot backup or copy active file in NOARCHIVELOG
mode
RMAN>
Note that you cannot back up an open database that is not in ARCHIVELOG mode.
The recovery catalog database should be run in ARCHIVELOG mode for maximum ble
availability. fe r a
ans
4) Exit RMAN.
n - t r
RMAN> exit
a no
a s
5) Run the rcat_to_archivelog.sh script to change ) h
the recovery
i d eฺcatalog
database to run in ARCHIVELOG mode. m
co nt Gu
i l ฺ
$ cd ~/labs
g ma tude
$ ./rcat_to_archivelog.sh
u k i@ is S
Database closed.
Database dismounted. a sy se th
ORACLE instance i u
(Mshuttodown.
k se
syu censtarted.
ORACLE instance
a
l e y M Systemli Global Area 263639040 bytes
Total
n Fixed Size
Sta
1299164 bytes
Variable Size 230690084 bytes
Database Buffers 25165824 bytes
Redo Buffers 6483968 bytes
Database mounted.
Database altered.
Database altered.
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
RMAN> syu
a e n se
yM
8) eRun lic
the disable_asynch_io.sh script to disable asynchronous input/output
n l
Sta (I/O). This improves performance on the following labs:
$ ~/labs/disable_asynch_io.sh
Practice 4-1: Setting the Date and Time Format for RMAN
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
In this practice, you set the date/time format that RMAN uses for displaying timestamps.
1) Set the NLS_LANG and NLS_DATE_FORMAT variables such that RMAN includes
time information in any timestamp values. Add the following two lines to the
~oracle/.bashrc file. Then exit all of your terminal windows. This ensures that
when you create new ones, these settings will be in effect.
export NLS_LANG=american_america.al32utf8
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"
2) Start a new terminal window, and verify the settings by starting RMAN and listing
the backups of the recovery catalog database.
ble
a) Start RMAN. fe r a
ans
$ rman target sys/oracle@rcat
n - t r
a
b) List the backups, and note the timestamp format. no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
ma tude
RMAN> list backup;
g
List of Backup Sets yuk
i@ is S
a s e th
===================
i ( M to us
s y uk nse
BS Keya TypecLV e Size
y M l i Device Type Elapsed Time Completion
Sta ---------
1 Full 9.36M DISK 00:00:02 2007-10-
05:03:49:29
BP Key: 1 Status: AVAILABLE Compressed: NO Tag:
TAG20071005T034926
Piece Name:
+FRA/rcat/backupset/2007_10_05/ncsnf0_tag20071005t034926_0.268
.635140169
SPFILE Included: Modification time: 2007-10-05:03:48:04
SPFILE db_unique_name: RCAT
Control File Included: Ckp SCN: 656862 Ckp time: 2007-
10-05:03:49:27
.
.
.
RMAN>
RMAN>
RMAN> exit
Note that the control file and SPFILE are automatically backed up now.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
2) Start RMAN by connecting to the ORCL as the target database and using the recovery
catalog database.
$ rman target / catalog rcatowner/oracle@rcat
RMAN>
RMAN>
5) Perform a backup to the tape device to make sure it works. Back up the USERS
tablespace. Then exit RMAN.
ble
fe r a
RMAN> backup device type sbt tablespace users;
ans
...
Starting backup at 2007-08-20:02:13:50 n - t r
released channel: ORA_DISK_1
a no
using channel ORA_SBT_TAPE_1
a s
) h d eฺ
channel ORA_SBT_TAPE_1: starting full datafile backup set
i
m
co nt Gu
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
i l ฺ
ma tude
input datafile file number=00004
g
name=+DATA/orcl/datafile/users.263.630812119
u k i@ is S
channel ORA_SBT_TAPE_1: starting piece 1 at 2007-08-
20:02:13:57
a sy se th
(M to u
channel ORA_SBT_TAPE_1: finished piece 1 at 2007-08-
k
20:02:13:58 i
syu cense
piece handle=0gipqqqu_1_1 tag=TAG20070820T021350 comment=API
a
yM li
Version 2.0,MMS Version 8.1.3.0
Sta
00:00:01
Finished backup at 2007-08-20:02:13:58
RMAN> exit
In this practice, you enable block change tracking so that you can make incremental
backups more quickly.
1) Use Enterprise Manager Database Control to configure backup optimization and
enable block change tracking. Allow a default block change tracking file to be used.
a) From the Database home page of EM, navigate to Availability > Backup Settings
> Policy, and enable backup optimization and block change tracking.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta b) Click OK.
c) If you see the following error, you have not entered the operating system
credentials. Continue with the following steps if that is the case.
d) Scroll to the bottom of the page, and enter oracle and oracle for the
username and password, respectively. Also, select the option to save this as the
preferred credential.
e) Click OK.
2) Make sure that the ORACLE_SID variable is set to ORCL.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
RMAN>
5) In another terminal window, make sure you are at the ~/labs directory.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options
SQL> 2 3 4 5 6 7 8 ble
FILE# AVG(DATAFILE_BLOCKS) AVG(BLOCKS_READ)
fe r a
PCT_READ_FOR_BACKUP AVG(BLOCKS)
ans
---------- -------------------- ---------------- -------------
n - t r
------ -----------
a no
1 89600 193
a s
.215401786 33
) h i d eฺ
2 78968 m
co nt Gu
1565
1.98181542 699
i l ฺ
5 ma tude
12800
g 1
.0078125 1
u k i@ is S
sy se th
4 640 1
.15625 a1
(M to u
3
k i 11520 383
syu cense
3.32465278 196
a li
MDisconnected
l e y
SQL> from Oracle Database 11g Enterprise Edition
n Release 11.1.0.6.0 - Production
Sta With the Partitioning, OLAP and Data Mining options
[oracle@edcdr11p1 labs]$
Note that the percentage of blocks read for making the backup is very low in most cases,
and sometimes very close to zero.
$ 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
y u
M
BS KeyasTypeliLV
c n
eSize Device Type Elapsed Time Completion Time
l e y
------- ---- -- ---------- ----------- ------------ ---------------
n 58
Sta
Full 69.01M DISK 00:00:26 22-AUG-07
BP Key: 61 Status: AVAILABLE Compressed: NO Tag:
TAG20070822T235728
Piece Name:
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
List of Datafiles in backup set 58
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
5 Full 1066265 22-AUG-07
+DATA/orcl/datafile/example.261.631245463
RMAN>
ble
Take note of the only backup that is a full backup of data file 5. Also note that the fe r a
“Piece Name” is the name of the ASM file where the backup file resides. ans
n - t r
a no
4) In an OS terminal window, delete the backup set file. Start a separate terminal
session, so the RMAN session can stay connected. Use the rm_asm_file.sh
a s
) h i d eฺ
script to do this. Supply the full “Piece Name” as an argument to the script.
m
co nt Gu
$ ./rm_asm_file.sh \
i
a del ฺ
g m
> +FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.631324655
tu
$
i @ S
is that corresponds to the example
s
5) List the backups again, andy ukfor thethbackup
look
data file. ( M a use
u
backup s
to
ki ofedatafile
RMAN> list
a y
s cen 5;
y M li
l e
n List of Backup Sets
Sta ===================
RMAN>
RMAN>
ble
fe r a
Note that the backup in question has expired. s
7) Delete all the expired backup sets. - t r an
no n
RMAN> delete expired backupset;
s a
) h a eฺ
m i d
co nt Gu
using channel ORA_DISK_1
i l ฺ
List of Backup Pieces
g ma tuDevice
de Type Piece Name
i@ is S ----------- ----------
BP Key BS Key Pc# Cp# Status
------- ------- --- ---k-----------
1 sy
u th
485 484
M a 1
u e
EXPIRED
s DISK
4655
u k i ( e to
+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.265.63132
sy cewant
youa really
ns to delete the above objects (enter YES or
l e y YES li
Do M
NO)?
n
Sta deleted backup piece
backup piece
handle=+FRA/orcl/backupset/2007_08_22/nnndf0_tag20070822t235728_0.26
5.631324655 RECID=7 STAMP=631324655
RMAN>
8) List the backup sets again. See that the backup you just deleted is no longer listed.
RMAN> list backup of datafile 5;
u k i@ is S
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_8.273.628128279
sy se th
Archive Log 50 2007-07-17:03:44:28
a
+DATA/orcl/archivelog/2007_07_17/thread_1_seq_9.274.628141457
(M to u
Archive Log
k i 53 2007-07-17:22:03:18
syu cense
+FRA/orcl/archivelog/2007_07_17/thread_1_seq_12.262.628207215
a
Archive Log 54 2007-07-18:00:23:14
yM li
nle +FRA/orcl/archivelog/2007_07_18/thread_1_seq_13.264.628215781
Sta
Archive Log 119 2007-07-18:05:49:47
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_14.265.628235371
Backup Set 57 2007-07-17:23:42:43
Backup Piece 60 2007-07-17:23:42:43
+FRA/orcl/backupset/2007_07_17/nnndf0_tag20070717t234236_0.263
.628213363
Archive Log 120 2007-07-18:11:06:54
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_15.266.628254397
Archive Log 121 2007-07-18:17:24:08
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_16.267.628277033
Archive Log 241 2007-07-18:22:26:03
+FRA/orcl/archivelog/2007_07_18/thread_1_seq_17.269.628294951
Datafile Copy 260 2007-07-18:22:30:24
/tmp/users_copy.dat
Archive Log 304 2007-07-19:01:08:12
+FRA/orcl/archivelog/2007_07_19/thread_1_seq_18.268.628304879
Backup Set 312 2007-07-19:01:12:10
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;
nle /tmp/users_copy.dat
Sta
Backup Set 111 2007-08-19:08:24:50
Backup Piece 115 2007-08-19:08:24:50
+FRA/orcl/autobackup/2007_08_19/s_631009483.279.631009489
Backup Set 280 2007-08-20:01:55:44
Backup Piece 282 2007-08-20:01:55:44
+FRA/orcl/autobackup/2007_08_20/s_631072536.294.631072545
Backup Set 434 2007-08-20:02:13:57
Backup Piece 435 2007-08-20:02:13:57 0gipqqqu_1_1
Backup Set 450 2007-08-20:02:14:08
Backup Piece 452 2007-08-20:02:14:08 c-1157684688-
20070820-02
Backup Set 483 2007-08-20:02:14:54
Backup Piece 486 2007-08-20:02:14:54 0iipqqsn_1_1
Backup Set 503 2007-08-20:02:15:04
Backup Piece 505 2007-08-20:02:15:04 c-1157684688-
20070820-03
Backup Set 577 2007-08-20:02:16:06
RMAN>
Note that far fewer backups are obsolete in this hypothetical report. That is because
with an increased redundancy, more of the backups are required. This command is
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Sta
handle=+FRA/orcl/backupset/2007_07_19/annnf0_tag20070719t01081
4_0.270.628304905 RECID=5 STAMP=628304904
deleted backup piece
backup piece
handle=+FRA/orcl/backupset/2007_07_19/ncsnn0_tag20070719t01122
1_0.272.628305353 RECID=7 STAMP=628305353
Deleted 19 objects
RMAN>
4) List the backup archivelog files that could be used to recover to a point in time one
hour ago.
Note: You may need to adjust the following SYSDATE expression to see some results
that differ from the list command that does not use a SYSDATE qualifier at all. For
example, try ‘sysdate-30/60/24’ to indicate 30 minutes ago.
RMAN> list backup of archivelog until time 'sysdate-1/24';
1 y
7 u ki se to
07-16:23:38:05
756123 2007-07-16:23:38:05 764907 2007-
a s cen
li
07-16:23:41:05
yM
e 1 8 764907 2007-07-16:23:41:05 771262 2007-
Stanl 07-17:00:04:09
1 9 771262 2007-07-17:00:04:09 793102 2007-
07-17:03:44:16
1 10 793102 2007-07-17:03:44:16 821341 2007-
07-17:09:20:17
1 11 821341 2007-07-17:09:20:17 850076 2007-
07-17:15:41:20
1 12 850076 2007-07-17:15:41:20 879117 2007-
07-17:22:00:10
1 13 879117 2007-07-17:22:00:10 907242 2007-
07-18:00:23:00
1 14 907242 2007-07-18:00:23:00 934362 2007-
07-18:05:49:29
1 15 934362 2007-07-18:05:49:29 960808 2007-
07-18:11:06:36
RMAN>
5) List the image copies of the single data file in the USERS tablespace.
a) Report on the schema to find out which data file number belongs to the USERS
tablespace.
RMAN> report schema;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
s y u
---- -------- -------------------- ----------- ---------------
-----
1 20 ( M
TEMPa u se 32767
k i t o
syu cense
+DATA/orcl/tempfile/temp.264.627874505
a li
l e yM
RMAN>
n
Sta Note that the file in question is data file number 4.
b) List any image copies of data file number 4.
RMAN> list copy of datafile 4;
RMAN>
Note that, in this case, there is only one image copy of this file. You may not have
any at this point.
RMAN>
7) To simplify things, disable control file autobackup.
RMAN> configure controlfile autobackup off;
9) Make another image copy of the data file, but make this one an archival backup.
RMAN> backup as copy datafile 4 keep forever;
RMAN-00571:
===========================================================
RMAN-03002: failure of backup command at 07/19/2007 06:09:50
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with
keep attributes
RMAN>
Note that the backup command failed. This is because a backup with the KEEP
attribute (an archival backup) cannot be written to the Flash Recovery Area. Allowing
this has the potential of causing the Flash Recovery Area to quickly run out of space,
forcing you to specify a different location. ble
fe r a
ans
10) Reattempt the archival backup, this time providing a FORMAT specifier that causes
the backup to be written to the /tmp directory.
n - t r
a
RMAN> backup keep forever as copy datafile 4 format no
a s
'/tmp/bu_%d_%s_%p.dbf';
) h i d eฺ
m
co nt Gu
i l
Starting backup at 2007-07-19:06:11:04ฺ
current log archived
g ma tude
u k i@ is S
using channel ORA_DISK_1
a
backup will never be e th
syobsolete
i M to utos recover from this backup will
archived logs (required be
backed up uk
a
channel y ense starting datafile copy
sORA_DISK_1:
lic file number=00004
y M datafile
input
n l e
name=+DATA/orcl/datafile/users.259.627874231
Sta output file name=/tmp/bu_ORCL_32_1.dbf tag=TAG20070719T061104
RECID=11 STAMP=628323074
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:01
u k i@ is S
piece handle=/tmp/bu_ORCL_35_1.dbf tag=TAG20070719T061104
comment=NONE
a sy se th
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
k i (M to u
syu cense
Finished backup at 2007-07-19:06:11:42
a
yM li
n l e
RMAN>
RMAN>
RMAN>
Note that the script issues the DELETE NOPROMPT OBSOLETE command. Click
OK.
17) Click Submit Job.
18) After the job is submitted, click View Job.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
19) When the job status appears as Succeeded, navigate back to the backup listing page
for image copies (Database > Availability > Manage Current Backups > Image
Copies).
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i
a del ฺ
20) Click the File Type heading twice, g m
so that the S tu types are listed at the top.
k i @ i s DATAFILE
Note that there are now only u backups
ytwo
sthird thand
of data file 4. The obsolete one has been
a
deleted because it was the
M u e
ofsthree, the retention policy is set to 1, meaning
( to of any given file.
i two backups
there need onlykbe
y u s e
M as licen
y
nle
Sta
21) Return to the RMAN session, and take another backup of the data file in the same
way. This should not be an archival backup.
RMAN> backup as copy datafile 4;
RMAN>
22) Return to the Manage Current Backups page in EM. Click Go to refresh the list of
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
backups.
Note that there are three backups again. The oldest one is an archival backup.
23) Click Delete All Obsolete, and submit the job as you did in the preceding steps. ble
fe r a
24) After the job completes, navigate to the Manage Current Backups page again.
t r a ns
25) Note that there are now only two image copy backups. But the oldest one
o n -was
preserved this time because it is an archival backup.
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
y u
son this spage.
26) Click the Backup Sets M a
tab u e What archival backup sets appear there? Why
are they there?
(
ki se to
y u
M as licen
n l ey
Sta
Answer: These archival backup sets are here because they were taken as a byproduct
of taking the data file image copy as an archival backup. When the data file archival
backup was taken, control file autobackup was enabled, which causes the control file
and the SPFILE to be backed up. Also, any archive redo logs that are required to
recover the image copy are taken. Because the image copy was an archival backup,
every other file that is backed up as a part of that backup task is also an archival
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
backup.
27) Exit RMAN.
RMAN> exit
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
In this practice, you will back up the rcat database using cold and hot backup
techniques.
[oracle@edu1r2p0-rcat ~]cd
[oracle@edu1r2p0-rcat ~] mkdir BACKUP
ble
fe r a
2) Make sure that your environment is pointing at the rcat database.
ans
n - t r
[oracle@edu1r2p0-rcat ~]. oraenv
ORACLE_SID= [orcl]? rcat a no
a s
) h
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
i d eฺ
/u01/app/oracle
m
co nt Gu
3) While the database is open, connect to them
i l ฺ
a asdesys or system and using V$
database
and data dictionary views, make a list@ g
of all the files
S u must be backed up for a whole
tthat
offline database backup.
i
uk this
s
a usey
Note: Copy the redo i (
logsMfor to of restore and recovery in NOARCHIVELOG mode.
ease
u k e
a sy cens~]sqlplus system/oracle
M li
[oracle@edu1r2p0-rcat
y
l e
StanSQL> spool /home/oracle/BACKUP/file_listing.txt
SQL> select name from v$controlfile;
NAME
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/control01.ctl
/u01/app/oracle/oradata/rcat/control02.ctl
/u01/app/oracle/oradata/rcat/control03.ctl
MEMBER
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/redo03.log
/u01/app/oracle/oradata/rcat/redo02.log
/u01/app/oracle/oradata/rcat/redo01.log
NAME
-----------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/system01.dbf
/u01/app/oracle/oradata/rcat/sysaux01.dbf
/u01/app/oracle/oradata/rcat/undotbs01.dbf
/u01/app/oracle/oradata/rcat/users01.dbf
/u01/app/oracle/oradata/rcat/example01.dbf
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
/u01/app/oracle/oradata/rcat/rcat01.dbf
6 rows selected.
4). Shut down the database with the IMMEDIATE option. Make a whole offline database
backup by copying all the data files into the $HOME/BACKUP directory using operating
system commands. This type of backup is suitable for both NOARCHIVELOG and
ARCHIVELOG databases.
ble
SQL> conn / as sysdba
fe r a
ans
SQL> shutdown immediate
n - t r
no
Database closed.
Database dismounted.
s a
ORACLE instance shut down.
) h a eฺ
SQL> exit
m i d
co nt Gu
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
i l ฺ
ma tude
With the Partitioning, Oracle Label Security, OLAP, Data Mining
g
u k i@ is S
and Real Application Testing options
[oracle@edu1r2p0-rcat ~]$
a s e th
ycp /u01/app/oracle/oradata/rcat/*
/home/oracle/BACKUP M
i ( t o us
s y uk nse
5). AlsoM a the spfile
copy l i c e into the $HOME/BACKUP directory.
n l ey
Sta [oracle@edu1r2p0-rcat ~]$ cp $ORACLE_HOME/dbs/spfilercat.ora
/home/oracle/BACKUP
BACKUP/:
total 1883788
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:31 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:28 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf
-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo03.log
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
-rw-r----- 1 oracle oinstall 734011392 Nov 12 17:30 system01.dbf
SQL> startup
ORACLE instance started.
M a tablespace
SQL> alter
l i c e users end backup;
n l ey
Sta Tablespace altered.
8). Use the ALTER DATABASE command to back up the control file as a trace file.
SQL> alter database backup controlfile to trace as
'/home/oracle/BACKUP/trace_control.bck';
Database altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options
This practice makes use of the rcat database. You will create a table in the USERS
tablespace and then simulate the loss of the datafile that belongs to this tablespace. When
you receive error messages stating that this file is missing, you will restore and recover it.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
1) Switch log file a couple of times to simulate the passage of time since the backup was
taken.
[oracle@edu1r2p0-rcat ~]$ sqlplus system/oracle
maccess
5) Now log back in to the database and trygto u data in the system.customers
tthe
i @ S
table.
s y uk this
[oracle@edu1r2p0-rcat a
( M u se system/oracle
~]$ sqlplus
u ki 11.1.0.6.0
e to - Production on Thu Nov 13 10:34:31 2008
y
s cen
SQL*Plus: Release
a s
M
y (c) 1982,
Copyright li 2007, Oracle. All rights reserved.
l e
Stan
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options
Database altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
7) Now go into your $HOME/BACKUP directory to find what backups you have of the
users’ datafile. Then choose the most recent, and copy this file into where the live one
should be.
[oracle@edu1r2p0-rcat ]$ cd /home/oracle/BACKUP/
[oracle@edu1r2p0-rcat ]$ ls -al
total 1888936
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:38 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 12 17:49 ..
-rw-r--r-- 1 oracle oinstall 7011 Nov 12 17:38 cntrl.bck ble
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
fe r a
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
ans
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27
- t r
control03.ctl
n
-rw-r-----
-rw-r-----
1 oracle
1 oracle
oinstall
oinstall
104865792
15736832
Nov
Nov a no
12
12
17:28
17:28
example01.dbf
rcat01.dbf
a s
eฺ
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312) h Nov
i d
12 17:28 redo02.log
-rw-r----- 1 oracle oinstall m
co nt Gu
52429312 Nov 12 17:28 redo03.log
i l ฺ
ma tude
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
-rw-r----- 1 oracle
g
oinstall 734011392 Nov 12 17:30 system01.dbf
-rw-r----- 1 oracle
u k i@ is S
oinstall 20979712 Nov 12 17:30 temp01.dbf
sy se th
-rw-r----- 1 oracle oinstall 209723392 Nov 12 17:31 undotbs01.dbf
-rw-r-----
-rw-r-----
1 oracle
a
(M to u
1 oracle
oinstall
oinstall
5251072
5251072
Nov
Nov
12
12
17:34
17:31
users01.bck
users01.dbf
k i
s yu ensecp /home/oracle/BACKUP/users01.bck
[oracle@edu1r2p0-rcat]$
a
yM lic
/u01/app/oracle/oradata/rcat/users01.dbf
l e
[oracle@edu1r2p0-rcat]$
Stan
8) Now log in to SQL*Plus and try to bring the file online.
[oracle@edu1r2p0-rcat]$ sqlplus system/oracle
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
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/u01/app/oracle/oradata/rcat/users01.dbf'
9) The datafile cannot be brought online as it is too old and, therefore, you need to
perform media recovery to roll it forward.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
10) Because you want to completely recover this datafile, you enter AUTO.
ble
fe r a
ns
auto
t r
- fora
ORA-00279: change 644645 generated at 11/12/2008 17:42:32 needed
o n
an
thread 1
ORA-00289: suggestion :
s
ha ideฺ
/u01/app/oracle/flash_recovery_area/RCAT/archivelog/2008_11_12/o1_mf_1_
27_4kp5n9z0_.arc )
m G#27 u
ORA-00280: change 644645 for thread 1 is ฺin
l c o t
i sequence
g ma tuden
ORA-00279: change 647988 generatedk S
i@ atis11/12/2008 17:46:49 needed for
y u t h
:s
thread 1
ORA-00289: suggestion a
( M u se
y u
28_4kp5z248_.arc ki se to
/u01/app/oracle/flash_recovery_area/RCAT/archivelog/2008_11_12/o1_mf_1_
ORA-00280:
M aschange
l i c n for thread 1 is in sequence #28
e647988
n l
Logeyapplied.
Sta Media recovery complete.
11) Now try to bring the datafile online.
SQL> alter database datafile 4 online;
Database altered.
12) Try again to access the system.customers table, and then exit SQL*Plus.
SQL> select count(*) from system.customers;
COUNT(*)
----------
55500
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
This practice makes use of the rcat database. You will simulate the loss of all
controlfiles, and then restore the controlfiles and recover the database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
3) The information from v$controlfile can be used to determine the physical status
of the control files at the operating system level, but because you have deleted them, you
can start to restore them without any further investigation.
First, the database must be shut down. Try a “shutdown immediate” first, but this will fail
because checkpoint information must be written to the control files. Then try a “shutdown
abort.” Exit SQL*Plus.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
4) Now try to start the instance and open the database. The database will fail to mount
ble
with errors pointing at control file problems. Exit SQL*Plus.
fe r a
ans
SQL> startup mount
ORACLE instance started. n - t r
n o
Total System Global Area 238530560 bytes s a
Fixed Size 1299116 bytes
) h a eฺ
m i d
co nt Gu
Variable Size 159386964 bytes
Database Buffers
i
71303168 bytesl ฺ
Redo Buffers
ma file,
6541312 bytes
g t u decheck alert log for more
i@ is S
ORA-00205: error in identifying control
info
u k
a sy se th
SQL> exit
k i (M to u
a
u Oracle
Disconnectedyfrom
s- Production
e n se Database 11g Enterprise Edition Release
11.1.0.6.0
Withythe lic
M Partitioning,
l e Oracle Label Security, OLAP, Data Mining
tan
and Real Application Testing options
S
5) Now find backups of the controlfile and copy them back into their correct locations.
[oracle@edu1r2p0-rcat]$ cd /home/oracle/BACKUP
[oracle@edu1r2p0-rcat]$ ls -al
total 1888936
drwxr-xr-x 2 oracle oinstall 4096 Nov 12 17:38 .
drwxrwxrwx 24 oracle oinstall 4096 Nov 13 12:30 ..
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control02.ctl
-rw-r----- 1 oracle oinstall 9748480 Nov 12 17:27 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Nov 12 17:28 example01.dbf
-rw-r----- 1 oracle oinstall 15736832 Nov 12 17:28 rcat01.dbf
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Nov 12 17:28 redo03.log
-rw-r----- 1 oracle oinstall 653008896 Nov 12 17:29 sysaux01.dbf
6) Now log in using SQL*Plus, and try to mount the database again. It should work this
time because the controlfiles have been restored.
[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba
a schange n
lic
ORA-00279:
thread
l e yM1
tan/u01/app/oracle/flash_recovery_area/rcat/arhivelog/2008_11_13/o1_mf_1_3
ORA-00289: suggestion :
S 3_4kr5w6b6_.arc
ORA-00280: change 1213429 for thread 1 is in sequence #33
ble
r a
this is sequence number 36. This is probably because sequence number 36 is onera
sfe
8) The recovery failed as it cannot find the next archived redo log. In the example above,
ofnthe
online redo logs.
o n -t
We need to determine which online redo logs have not been archived, a andn what their
s
haas thisidview
sequence numbers are. This is what v$log usually shows,)but eฺ will get its
m uthe information in the
co restored,
information from the controlfile, and these have just been G
view will not be up to date. i
a denl ฺ t
g m tu
SQL> select * from v$log;
i @ S
s y uk thisBYTES MEMBERS ARC STATUS
GROUP# THREAD# SEQUENCE#
---------- ----------
( M u se---------- ---------- --- ------------
a----------
----
y u ki se to
M as ---------
FIRST_CHANGE#
-------------
l i c en
FIRST_TIM
n l ey 1175121
1 1 31 52428800 1 NO CURRENT
Sta 13-NOV-08
SQL> exit
The sequence numbers shown above are earlier sequences than the 36 needed to continue
the recovery in this example.
9) The alert log contains entries for every log file switch. So, as long as this has not been
damaged, it can be searched for a reference to the missing log, which in our example is
sequence 36.
[oracle@edu1r2p0-rcat]$ cd /u01/app/oracle/diag/rdbms/rcat/rcat/trace
[oracle@edu1r2p0-rcat]$ more alert_rcat.log
.
.
Current log# 2 seq# 35 mem# 0: /u01/app/oracle/oradata/rcat/redo02.log
Wed Nov 12 19:09:45 2008
Thread 1 advanced to log sequence 36
Current log# 3 seq# 36 mem# 0:
/u01/app/oracle/oradata/rcat/redo03.log
.
.
.
10) It is now known that sequence 36 is contained within Log Group 3. So, the recover
command can be restarted and /u01/app/oracle/oradata/rcat/redo03.log can be
entered as the name of the next log file to use for recovery. ble
fe r a
ans
[oracle@edu1r2p0-rcat]$ sqlplus / as sysdba
n - t r
SQL> recover database using backup controlfile;
n o
s a
ORA-00279: change 1213915 generated at 11/13/2008 12:05:28 needed for
thread 1
) h a eฺ
m i d
ORA-00289: suggestion :
l ฺ c o t Gu
i
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2008_11_13/o1_mf_1_
en #36
36_%u_.arc
g
ORA-00280: change 1213915 for threadm1ais tinudsequence
u k i@ is S
a th | AUTO | CANCEL}
sy s| efilename
(M to u
Specify log: {<RET>=suggested
k i
syu cense
/u01/app/oracle/oradata/rcat/redo03.log
a
Log y M
applied. li
l e
tan
Media recovery complete.
S
11) Now, try to open the database.
SQL> alter database open;
Alter database open
*
ERROR at line 1:
ORA-01589:must use RESETLOGS or NORESTLOGS option for database open
12) Because we have restored the controlfiles, we need to open with the resetlogs
keyword.
SQL> alter database open resetlogs;
Database altered.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
syu cense
SQL> ! rm /u01/app/oracle/oradata/rcat/redo03.log
a
yM li
l e
Stan3) Now issue the alter system switch logfile command thrice. The third
command should hang.
SQL> alter system switch logfile;
SQL> /
SQL> /
4) In another Xterm window, look at the alert log to see what errors are being reported.
[oracle@edu1r2p0-rcat]$ cd /u01/app/oracle/diag/rdbms/rcat/rcat/trace
[oracle@edu1r2p0-rcat]$ more alert_rcat.log
.<below is an extract from the output>
.
.
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312:online log 3 thread 1:
'/u01/app/oracle/oradata/rcat/redo03.log'
ORA-27037: unable to obtain file status
ble
fe r a
5) The messages report that you cannot allocate a log, as archival is required. There are
ans
also various messages saying that log group 3 cannot be opened.
n - t r
no
This is because the logfile has been deleted, and therefore cannot be archived. Because
a
a s
the log file has not been archived, lgwr is not allowed to overwrite it, even if the file no
longer exists. ) h i d eฺ
m u
o ttheGmissing
cre-create
i l
a den
If you clear the missing log file group, then this willฺ logfile.
[oracle@edu1r2p0-rcat]$ sqlplus / g m tu
i @ is 3S
as sysdba
s y uk tgroup h
se 3
SQL> alter database clear logfile
( M
alter database clear logfilea ugroup
*
y u ki se to
aslog l3icofeninstance rcat (thread 1) needs to be archived
ERROR at line 1:
M
ORA-00350:
y
l e
ORA-00312: online log 3 thread 1:
Stan
'/u01/app/oracle/oradata/rcat/redo03.log'
6) Because the logfile group has not been archived, you must use the keyword
“unarchived” in the command. Then exit SQL*Plus.
SQL> alter database clear unarchived logfile group 3;
Database altered.
SQL> exit
7) If you now look at your original Xterm window, in which you issued the alter
system switch logfile command that hung, you should now find that the session
is no longer hanging.
Now examine the alert log again in your second Xterm window. You will see that the
“alter database clear unarchived logfile group” command has been recorded in the
alert.log, and that warning messages have been issued because of the use of this
command.
[oracle@edu1r2p0-rcat]$ more alert_rcat.log
.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
9) When the backup has completed, start the instance and open the database.
[oracle@edu1r2p0-rcat ~]$ sqlplus / as sysdba
SQL> startup
Database mounted.
Database opened.
SQL> exit
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
In this practice, you recover an image copy of a file to the current SCN, to allow faster
recovery time later. You create a new tablespace called APPRAISAL, which has one
table in it. After creating initially, with a small amount of data, you take an incremental
backup of it. Then you perform more DML on it, adding many more rows. Then you take
another incremental backup. At that point, you have an image copy of the APPRAISAL
tablespace and also an incremental backup of it. Because you need to recover the
tablespace later, you recover the image copy so that it is as up-to-date as the last
incremental backup. This is done without going to the expense of creating a new image
copy.
bl e
1) Make sure you are at the ~/labs directory and your environment points to the orcl ra
instance. n s fe
n - tra
$ cd ~/labs
$ . oraenv a no
a s
ORACLE_SID = [orcl] ? orcl
) h i d eฺ
The Oracle base for
c m
o t Gu is
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
i l ฺ
/u01/app/oracle
$ g ma tuden
u k i@ is S
a s y
2) Run the create_appraisal_ts.sh
e th script to create a new tablespace called
APPRAISAL.
i ( M to us
s y uk nse
$ ./create_appraisal_ts.sh
M a lcreated.
Tablespace
i c e
y created.
nle$
Table
Sta 3) Make a level 1 backup of the tablespace, to be used for image copy recovery. If no
level 1 exists yet, it will actually create a level 0 incremental backup. This takes
several minutes.
$ rman target / catalog rcatowner/oracle@rcat
RMAN> backup incremental level 1 for recover of copy with tag
'app_incr' database;
u k i@ is S
input datafile file number=00005
a sy se th
name=+DATA/orcl/datafile/example.260.635127419
output file name=+FRA/orcl/datafile/example.293.635210123
k i (M to u
tag=APP_INCR RECID=21 STAMP=635210156
syu cense
channel ORA_DISK_1: datafile copy complete, elapsed time:
a
yM
00:00:45
li
nle channel ORA_DISK_1: starting datafile copy
Sta
input datafile file number=00006
name=+DATA/orcl/datafile/tbsjmw.263.635148067
output file name=+FRA/orcl/datafile/tbsjmw.294.635210175
tag=APP_INCR RECID=22 STAMP=635210188
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007
name=+DATA/orcl/datafile/appraisal.256.635209311
output file name=+FRA/orcl/datafile/appraisal.295.635210207
tag=APP_INCR RECID=23 STAMP=635210211
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004
name=+DATA/orcl/datafile/users.262.635127891
output file name=+FRA/orcl/datafile/users.296.635210221
tag=APP_INCR RECID=24 STAMP=635210221
piece
handle=+FRA/orcl/autobackup/2007_10_05/s_635210233.297.6352102
37 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-10-
05:23:17:23
RMAN>
4) In a separate terminal window, perform some DML on the table in the APPRAISAL
tablespace. Use the emp_inserts.sh script.
$ ./emp_inserts.sh
ble
fe r a
107 rows created.
ans
.
n - t r
.
a no
.
a s
) h
5) List the copy of the APPRAISAL tablespace to see its SCN. i d eฺ
m
co nt Gu
i l ฺ
ma tude
RMAN> list copy of tablespace appraisal;
y M l 2007-10-
nle
05:23:16:45
Sta
Name: +FRA/orcl/datafile/appraisal.295.635210207
Tag: APP_INCR
RMAN>
6) Run the script to perform more transactions on the table that resides in the
APPRAISAL tablespace.
$ ./emp_inserts.sh
Commit complete.
Commit complete.
$
sy se th
piece
a
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t23370
(M to u
i
2_0.298.635211431 tag=TAG20071005T233702 comment=NONE
k
a syu cense
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:25
yM li
Finished backup at 2007-10-05:23:37:36
nle
Sta Starting Control File and SPFILE Autobackup at 2007-10-
05:23:37:36
piece
handle=+FRA/orcl/autobackup/2007_10_05/s_635211458.299.6352114
67 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-10-
05:23:37:53
RMAN>
8) List and note the SCN of the APPRAISAL tablespace incremental backup (not the
image copy).
RMAN> list backup of tablespace appraisal;
05:23:37:27
BP Key: 679 Status: AVAILABLE Compressed: NO Tag:
TAG20071005T233702 Piece Name:
+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t233702_0.298
.635211431
List of Datafiles in backup set 676
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
7 1 Incr 824887 2007-10-05:23:37:11
+DATA/orcl/datafile/appraisal.256.635209311
ble
RMAN>
fe r a
9) Use the incremental backup to recover the APPRAISAL tablespace image copy.
ans
n - t r
RMAN> recover copy of tablespace appraisal with tag
'app_incr'; a no
a s
Starting recover at 2007-10-05:23:52:00 )
h i d eฺ
c m
o t Gu
allocated channel: ORA_DISK_1
i l ฺ
ma type=DISK
channel ORA_DISK_1: SID=170 device
channel ORA_DISK_1: startinggincremental u d endatafile backup set
k i @ is St
restore
channel ORA_DISK_1:sy u th datafile copies to recover
M a e
specifying
usfile number=00007
i (
recovering datafile copy
t o
y uk nse reading from backup.635210207
name=+FRA/orcl/datafile/appraisal.295
channelsORA_DISK_1:
M a lice
+FRA/orcl/backupset/2007_10_05/nnn
piece
y
nledn1_tag20071005t233702_0.298.635211431
Sta channel ORA_DISK_1: piece
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag200710
05t233702_0.298.635211431 tag=TAG20071005T233702
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2007-10-05:23:52:03
.
.
.
RMAN>
10) List the SCN for the APPRAISAL tablespace image copy. What is it now?
RMAN> list copy of tablespace appraisal;
RMAN>
Note that it is now equal to the SCN of the last incremental backup.
11) Recover all the data file image copies in the database based on the most recent
incremental backup.
RMAN> recover copy of database with tag 'app_incr';
Sta
name=+FRA/orcl/datafile/tbsjmw.294.635210175
channel ORA_DISK_1: reading from backup piece
+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t233702_0.298
.635211431
channel ORA_DISK_1: piece
handle=+FRA/orcl/backupset/2007_10_05/nnndn1_tag20071005t23370
2_0.298.635211431 tag=TAG20071005T233702
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
Finished recover at 2007-10-06:00:00:54
.
.
.
RMAN>
12) View the SCNs of all the image copies now. They should all be, at the most, equal to
the latest incremental backup.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
offline.
RMAN> sql "alter tablespace appraisal offline";
RMAN>
2) Use the SWITCH command to replace the data file from the flash recovery area.
ble
a) Determine the name of the data file that is currently associated with the
fe r a
APPRAISAL tablespace.
ans
n - t r
RMAN> report schema;
a no
s
Report of database schema for database with adb_unique_name
) h i d eฺ
ORCL
c m
o t Gu
List of Permanent Datafiles i l
a denฺ
=========================== gm tu segs Datafile Name
i @ S
File Size(MB) Tablespace
s y uk this ------- -------------------
RB
-----
( M a use
---- -------- --------------------
1 700
u ki SYSTEMe to YES
y
as liceSYSAUXn s
+DATA/asmtesting/datafile/testing.258.634268145
2 M679 NO
l e y
n +DATA/orcl/datafile/sysaux.259.634164339
Sta 3 200 UNDOTBS1 YES
+DATA/orcl/datafile/undotbs1.260.634164355
4 5 USERS NO
+DATA/orcl/datafile/users.263.634165219
5 100 EXAMPLE NO
+DATA/orcl/datafile/example.261.634164377
6 50 TBSJMW NO
+DATA/orcl/datafile/tbsjmw.269.634202579
7 25 APPRAISAL NO
+DATA/orcl/datafile/appraisal.256.634276429
.
.
.
RMAN>
RMAN>
$ cd ~/labs
7) Remember that the reason for switching was because this data file was considered to
be on a damaged disk, or the data file itself was corrupted in some way. So, run the
rm_asm_file.sh script to delete the file.
$ ./rm_asm_file.sh +DATA/orcl/datafile/appraisal.256.634276429
8) Eventually, you want to refrain from using the Flash Recovery Area as storage for
active data files. By now, the hardware or corruption problem has been remedied, so
switch the data file back to the original location.
a) Back up the data file, specifying the DATA ASM disk group, using the ble
DATAFILE template. fe r a
ans
RMAN> backup as copy to destination '+DATA(datafile)' datafile
n - t r
7;
a no
a s
Starting backup at 2007-09-26:05:11:02
) h i d eฺ
using channel ORA_DISK_1 m
co copy G u
channel ORA_DISK_1: starting datafile i l
a den ฺ t
input datafile file number=00007
g m tu
i @ S
name=+FRA/orcl/datafile/appraisal.295.634277277
is
ukRECID=33
t h
output file name=+DATA/orcl/datafile/appraisal.256.634281073
s y
a
tag=TAG20070926T051102
M u s e STAMP=634281075
i (
channel ORA_DISK_1:
k t o
datafile copy complete, elapsed time:
00:00:03 u
a sybackup e n se
lic
Finished at 2007-09-26:05:11:15
y M
l e
n Starting Control File and SPFILE Autobackup at 2007-09-
Sta 26:05:11:16
piece
handle=+FRA/orcl/autobackup/2007_09_26/s_634281078.304.6342810
91 comment=NONE
Finished Control File and SPFILE Autobackup at 2007-09-
26:05:11:33
RMAN>
RMAN>
RMAN>
d) Report the schema to confirm that the data file location has changed.
RMAN> report schema;
k i (M to u
+DATA/orcl/datafile/example.261.634164377
syu cense
6 50 TBSJMW NO
a
+DATA/orcl/datafile/tbsjmw.269.634202579
li
le
7
yM 25 APPRAISAL NO
n +DATA/orcl/datafile/appraisal.256.634281073
Sta .
.
.
RMAN>
RMAN>
11) Cross-check the image copy backups and remove the obsolete data file 7 image copy.
Exit RMAN when finished.
RMAN> crosscheck copy;
ma tude
STAMP=634281188
g
validation failed for datafile copy
datafile copy file
u k i@ is S
sy se th
name=+DATA/orcl/datafile/appraisal.256.634276429 RECID=32
a
k i (M to u
STAMP=634279041
validation succeeded for archived log
syu cense
archived log file
a
yM li
name=/u01/app/oracle/product/11.1.0/db_1/dbs/arch1_36_63124294
1) Start an RMAN session, connecting to the orcl instance as the target, and also
connecting to the rcat instance as the recovery catalog. Again, use oraenv to set up
the environment for the orcl instance.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ rman target / catalog rcatowner/oracle@rcat
ble
fe r a
2) Make sure that RMAN is configured to automatically back up the control file. ans
n - t r
RMAN> configure controlfile autobackup on;
a no
a s
old RMAN configuration parameters: ) h i d eฺ
CONFIGURE CONTROLFILE AUTOBACKUP OFF; om u
new RMAN configuration parameters: ilฺc t G
CONFIGURE CONTROLFILE AUTOBACKUPm a den
ON;
@ g
new RMAN configuration parameters are tsuccessfully
S u stored
k i i s
full resync complete syu
starting full resync of recovery catalog
a e th
RMAN>
i ( M to us
3) Configure s y uk to nwrite
RMAN sethe control file auto backup to the desired location, so that
a e
c there together.
l e y M filesliare
all the backup
4) You need a backup of the ORCL database to be used as the source of the cloning
operation. Back up all the data files.
6) The PFILE for the cloned database will be based on ORCL’s SPFILE. The dispatcher
parameter references the orclXDB service, so you have to remove it from the SPFILE
while the clone operation is taking place. ble
fe r a
Log in using SQL*Plus and remove the entry for the dispatchers from the SPFILE. Then
ans
t r
archive the current redo logs, to make available as much redo as possible for the clone
n -
operation.
a no
a s
eฺ
$ sqlplus / as sysdba
) h i d
m
co nt Gu
SQL> show parameter disp
i l ฺ
NAME TYPE
g ma VALUE t u de
u k i@ is S----------------------
--------------------------- -----------
dispatchers
a sy integer
string
e th (PROTOCOL=TCP)(SERVICE=orclXDB)
M to us
max_dispatchers
i (
s y uk set
SQL> alter system
n s e
dispatchers='' scope=spfile;
System M
a
altered.lice
n l eyalter system archive log current;
Sta SQL>
System altered.
SQL>
8) Select the option to use an existing backup for the source. Then click Continue.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
no
9) On the Source Options page, enter the backup directory in the RMAN Backup
a
s
Location field. Leave the Staging Area Location as the default setting. Then click Next.
a
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
10) Specify odup for the Global Database Name and the Instance Name. Leave the
default values in all the other fields. Then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
11) On the Destination Options page, leave the default values in all the fields. Then click
Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
h a
12) You see a warning page regarding a sales history data file andsthe control
ฺ file
directory. Click Yes to continue. ) id e
o m G u
a ilฺc ent
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta
13) You may also get an error message similar to the following about controlfiles:
“The following files or directories cannot be created due to the specified reasons:
/u01/app/oracle/oradata/odup/current.267.ctl; These file names are used for more than
one database file.”
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
If this happens, click the Customize button on the Destination Options page and scroll
down on the new page to the section on controlfiles. You will see that both controlfiles
are going to be called the same name, so alter the name of one to stop this happening.
Then click OK to return to the Destination Options page. Then click Next.
14) On the Database Configuration page, leave the default values in all the fields, and
click Next.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
15) On the Schedule page, leave the default values in all the fields, and click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
k i@
16) Review the Review page, anduthen i s
clickhSubmit
S Job.
a sy se t
k i (M to u
a syu cense
yM li
n l e
Sta
17) Click View Results, and view the status of the job until it shows that it is
“Succeeded.”
The entire job takes five to eight minutes to complete.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
18) Configure a terminal window environment to work with a terminal session with the
ORACLE_SID set to ODUP.
ble
$ . oraenv
fe r a
ORACLE_SID = [orcl] ? odup
ans
The Oracle base for
n - t r
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle a no
a s
deฺsure that you
$
h
)table toumake
i
o m
19) Log in to the ODUP database, using SQL*Plus. Query a
have a copy of the source database.
a ilฺc ent G
$ sqlplus / as sysdba
@ gm Stud
SQL*Plus: Release 11.1.0.6.0
y u ki - tProduction
h is on Mon Aug 20
12:50:13 2007 s se All rights reserved.
a2007, uOracle.
Copyright (c) 1982,
Connected to: ki ( M to
Oracle Databasey u
s cen e
11gsEnterprise Edition Release 11.1.0.6.0 -
a li
M Partitioning,
Production
Withy the Oracle Label Security, OLAP, Data
l e
tanand Real Application Testing options
Mining
S
SQL> select count(*) from hr.job_history;
COUNT(*)
----------
10
20) Truncate the HR.JOB_HISTORY table in the ODUP database, and then exit
SQL*Plus.
SQL> truncate table hr.job_history;
Table truncated.
SQL> exit
21) Query the truncated table to prove it is still populated in the ORCL instance.
$ . oraenv
22) Now reinstate the dispatcher parameter in the orcl instance and then exit from
SQL*Plus.
SQL> show parameter disp
f) After the delete operation is finished, click No when asked if you want to perform
another operation.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
ble
Export: Release 11.1.0.6.0 - Production on Monday, 20 August,
fe r a
ns
2007 13:14:53
- t r a
Copyright (c) 2003, 2007, Oracle. All rights reserved.
o n
Connected to: Oracle Database 11g Enterprise s a n Release
ha ideฺ
Edition
11.1.0.6.0 - Production )
m GuOLAP, Data
With the Partitioning, Oracle Label Security,
ฺ c o t
Mining
a il e n
m tud
and Real Application Testinggoptions
k i @ s S
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":
i system/********
u
sy se t
dumpfile=hrexp.dmp schemas=hr h
M a
. . exported "HR"."REGIONS"
( u 5.476
KB 4 rows
u e to
ki"SYSTEM"."SYS_EXPORT_SCHEMA_01"
s y
Master table
a e n s successfully
M lic
loaded/unloaded
.y
l
n .e
Sta .
**************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/admin/orcl/dpdump/hrexp.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at
13:16:13
2) Run the create_hrtest.sql script to create a new tablespace and a new user in
your database.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$ sqlplus / as sysdba
SQL> @create_hrtest.sql
SQL> SET TERMOUT ON
SQL> CONNECT / AS SYSDBA
Connected.
SQL> REM ***** Tablespace for the HR import *****
SQL> DROP TABLESPACE hrtest INCLUDING CONTENTS AND DATAFILES
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
2 /
DROP TABLESPACE hrtest INCLUDING CONTENTS AND DATAFILES
*
ERROR at line 1:
ORA-00959: tablespace 'HRTEST' does not exist
User created.
Grant succeeded.
3) Execute the pop_hrtest.sh script to populate the new tablespace with a copy of
the data from the HR schema.
Note: The import should complete successfully. You receive error messages because
the import excludes the COUNTRIES, REGIONS, and LOCATIONS tables. These
messages can be ignored.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
$ ./pop_hrtest.sh
sy se th
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
a
Processing object type SCHEMA_EXPORT/TABLE/TABLE
(M to u
i
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
k
KB a syu cense
. . imported "HRTEST"."DEPARTMENTS"
27 rows
7.007
yM li
. . imported "HRTEST"."EMPLOYEES" 16.80
nle
Sta
KB 107 rows
. . imported "HRTEST"."JOBS" 6.984
KB 19 rows
. . imported "HRTEST"."JOB_HISTORY" 7.054
KB 10 rows
Processing object type
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type
SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"HRTEST"."EMP_DETAILS_VIEW"
created with compilation warnings
ble
$
fe r a
ans
4) Create a backup of your database using RMAN. n - t r
n o
RMAN> backup database; s a
) h a eฺ
Starting backup at 2007-08-20:13:40:42m i d
l ฺ
starting full resync of recovery icatalog co nt Gu
m a de
full resync complete
i
allocated channel: ORA_DISK_1@ g S tu
y uk device
channel ORA_DISK_1: SID=118 t h is type=DISK
channel ORA_DISK_1: s se full
a starting datafile backup set
( M o u
i filee tnumber=00001
channel ORA_DISK_1: specifying datafile(s) in backup set
u k
sy cens
input datafile
a li
name=+DATA/asmtesting/datafile/testing/system.258.630811685
y M ORA_DISK_1:
n l e
channel starting piece 1 at 2007-08-20:13:40:55
Sta
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:43:21
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.308.631114857 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:02:26
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002
name=+DATA/orcl/datafile/sysaux.259.630811693
channel ORA_DISK_1: starting piece 1 at 2007-08-20:13:43:29
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:45:45
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.309.631115013 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:02:16
channel ORA_DISK_1: starting full datafile backup set
name=+DATA/orcl/datafile/example.261.630811719
input datafile file number=00006
name=+DATA/orcl/datafile/tbsjmw.269.630814117
channel ORA_DISK_1: starting piece 1 at 2007-08-20:13:45:52
channel ORA_DISK_1: finished piece 1 at 2007-08-20:13:46:17
piece
handle=+FRA/orcl/backupset/2007_08_20/nnndf0_tag20070820t13404
8_0.310.631115153 tag=TAG20070820T134048 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:25
Finished backup at 2007-08-20:13:46:17
ble
Starting Control File and SPFILE Autobackup at 2007-08- fe r a
20:13:46:17
ans
piece
n - t r
handle=+FRA/orcl/autobackup/2007_08_20/s_631115181.311.6311151
a no
89 comment=NONE
a s
) h
Finished Control File and SPFILE Autobackup at 2007-08-
i d eฺ
20:13:46:36 m
co nt Gu
i l ฺ
RMAN>
g ma tude
u k i@ is S
a s y e th
5) Record the current SCN
( M fortthe s
udatabase: ____________
i
ukcurrent_scn o
a s y
SQL> select
e n se from V$database;
yM lic
l e
CURRENT_SCN
n -----------
Sta 1416777
SQL>
4 /
8) Execute the give_raise.sql script to update the salaries for the employees in
department 60 and note the highest salary displayed.
Highest salary: _____________
SQL> @give_raise
SQL> update hrtest.employees
2 set salary = salary * 1.25
3 where department_id = 60
4 /
ble
fe r a
5 rows updated.
ans
SQL> select employee_id, last_name, salary
n - t r
2 from hrtest.employees
3 where department_id = 60 a no
a s
4 /
) h i d eฺ
m Gu
co ntSALARY
EMPLOYEE_ID LAST_NAME
i l ฺ
a d----------
----------- -------------------------
g m u e
103 Hunold
i @ is S t 11250
104 Ernst u k t h 7500
105 Austin sy e
( M a u s 6000
106 Pataballa
107 k i
u nse
Lorentz t o 6000
5250
s y
a lice
y M
n9)leYou now want to perform TSPITR for the HRTEST tablespace to return it to the state
Sta prior to the updates. Execute the check_deps.sql script to determine whether
there are any dependencies that prevent the TSPITR operation.
SQL> @check_deps
SQL> SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
2 obj2_owner, obj2_name, obj2_type, ts2_name,
3 constraint_name, reason
4 FROM SYS.TS_PITR_CHECK
5 WHERE (TS1_NAME IN ('HRTEST')
6 AND TS2_NAME NOT IN ('HRTEST'))
7 OR (TS1_NAME NOT IN ('HRTEST')
8 AND TS2_NAME IN ('HRTEST'))
9 /
no rows selected
“No rows selected” indicates that there are no dependencies to any tablespaces
outside the recovery set, so you can proceed with the tablespace point-in-time
recovery.
10) You can use Enterprise Manager Database Control or the RMAN command line to
perform tablespace point-in-time recovery. In Enterprise Manager, navigate to
Availability > Perform Recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Note: The answer presents the solution using Enterprise Manager Database Control.
If you want to use the RMAN command line, refer to the course notes for detailed
information and execute the RECOVER TABLESPACE command as follows:
RECOVER TABLESPACE hrtest UNTIL SCN <scn>
AUXILIARY DESTINATION ‘/u01/app/oracle/oradata/tspitr’;
11) Select Tablespaces for Recovery Scope, enter the login credentials, and then click
Recover.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
t a n12)leOn the Point-in-time page, select the “Recover to a prior point-in-time” option button.
S Choose SCN and enter the SCN that you recorded earlier in this practice. Then click
Next.
ble
fe r a
ans
n - t r
13) Specify the auxiliary instance location of
a no
a s
/u01/app/oracle/oradata/tspitr. Click Add to add the HRTEST
) h
tablespace to the recovery job. Then click Next.i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
15) On the Rename page, specify that the files are to be restored to the default location.
Then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
an s
n - t r
a no
16) Review the Review page, and then click Submit. Watch fora
h s job to ฺcomplete. It
the
runs for six to eight minutes.
m ) u i de
lฺco see
17) When the job completes, note the status. Youishould
a e n G
at page titled “Operation
Succeeded.” When you do, review it, g mthen click
and t u dOK.
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
l e
Stan
18) Using EM, verify that the HRTEST tablespace is online by navigating to Database >
Server > Tablespaces. If there is a green check mark in the Status column, it is online.
19) Verify that the SALARY columns in HRTEST.EMPLOYEES for the employees in
department 60 contain the correct values. Run the query_salary.sql script to do
this.
SQL> @query_salary
SQL> select employee_id, last_name, salary
2 from hrtest.employees
3 where department_id = 60
4 /
Note that the highest salary value is now back to the original value you recorded
earlier.
20) Execute the add_constraint.sql script to add a constraint to the
HRTEST.DEPARTMENTS table. ble
fe r a
SQL> @add_constraint
an s
SQL> connect / as sysdba
n - t r
Connected.
a no
SQL> GRANT references (location_id) on hr.locations to hrtest
a s
2 /
) h i d eฺ
m
co nt Gu
Grant succeeded.
i
a del ฺ
SQL> connect hrtest/hrtest gm tu
i @ S
Connected.
s y uk this
( M
2 ADD CONSTRAINT se
SQL> ALTER TABLE hrtest.departments
a dept_loc_id_fk
u FOREIGN KEY (location_id)
i t o
uk nhr.locations
3 REFERENCES
e (location_id)
4 / sy
a lice s
y M
nleTable altered.
Sta 21) Assume you need to perform TSPITR on the HRTEST tablespace again. Execute the
check_deps.sql query to determine whether there are any dependencies outside
the recovery set.
SQL> @check_deps
SQL> set echo on
SQL> SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
2 obj2_owner, obj2_name, obj2_type, ts2_name,
3 constraint_name, reason
4 FROM SYS.TS_PITR_CHECK
5 WHERE (TS1_NAME IN ('HRTEST')
6 AND TS2_NAME NOT IN ('HRTEST'))
7 OR (TS1_NAME NOT IN ('HRTEST')
8 AND TS2_NAME IN ('HRTEST'))
9 /
OBJ1_OWNER OBJ1_NAME OBJ1_TYPE TS1_NAME
---------------------------------------------------------
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
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
In these practices, you use the recycle bin to flash back dropped objects. You also
explore the workings of Flashback Transaction.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
2) The lab script drops the HR.DEPARTMENTS table including indexes, restraints, and
so on. Query the DBA_RECYCLE_BIN view to confirm this.
$ sqlplus / as sysdba
SQL> SELECT owner, original_name, droptime FROM dba_recyclebin
where owner = 'HR';
ble
OWNER ORIGINAL_NAME DROPTIME
fe r a
------ ------------------ -------------------
ans
HR DEPT_LOCATION_IX 2007-07-24:10:51:11
n - t r
HR DEPT_ID_PK 2007-07-24:10:51:11
a no
HR DEPARTMENTS 2007-07-24:10:51:11
a s
...
) h i d eฺ
m
co Youncan u Flashback Table
Guse
i l ฺ
3) Use Flashback Table to restore the dropped objects. t
a dToeflash back the table using
through Enterprise Manager or through SQL*Plus.
m
Enterprise Manager, skip to step 5.@
i
g S tu
s y uk this TO BEFORE DROP;
SQL> FLASHBACK TABLE
( M a use hr.departments
u ki se to
Flashback complete.
y
SQL>
M as licen
y
n4)lePerform a select operation against the HR.DEPARTMENTS table to confirm the
Sta success of the Flashback Table operation.
SQL> SELECT * FROM hr.departments;
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.
ble
fe r a
6) The Perform Object Level Recovery: Rename page allows you to rename the restored
ans
object. Accept the default or original name and click Next.
n - t r
no
7) On the Review page, inspect the Impact Analysis. Note that the table and dependent
a
a s
objects are to be restored and note the names they will be restored to. Click Submit.
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
...
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
modifies the same data that was changed by the target transaction, or a primary-key
constraint relationship, in which a transaction reinserts the primary-key value that was
deleted by the target transaction. Flashback Transaction utilizes undo and the redo
generated for undo blocks to create and execute a compensating transaction for reverting
the affected data to its original state.
1) Flashback Transaction Backout requires that the database be in ARCHIVELOG mode.
From a terminal session connected as the oracle user, ensure that you are pointing
to the orcl database and execute the flatxn_archivelog.sh script from the
$HOME/labs directory.
ble
fe r a
$ cd $HOME/labs
ans
$ echo $ORACLE_SID
n - t r
orcl
$ ./flatxn_archivelog.sh a no
a s
*******************************************
) h i d eฺ
* Unlock HR account
m
co nt Gu
* Enable ARCHIVELOG mode for database
i l ฺ
The script may appear to hang g mata thetuSQLde prompt
when the database is shuttingk i@ down i s Sand being
opened. Wait a few s y u h
t it should progress.
a minutes
s eand
k i (M to u
*******************************************
s
SQL*Plus:
a yuRelease
e n se11.1.0.6.0 - Production on Thu Jul 12
y M 2007
12:35:19 lic
n l e
Sta Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
SQL> SQL>
User altered.
SQL>
System altered.
SQL>
Database altered.
M a sys/oracle
$ sqlplus
l i c e as sysdba
y
nle12:42:43 2007
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 12
Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
SQL> @flatxn_setup1
SQL> set serveroutput on
SQL> set term on
SQL> set lines 200
SQL> set pause on
SQL>
SQL> /*== Set up the HR database account ==*/
Database altered.
COLUMNS;
Database altered.
Grant succeeded.
Grant succeeded.
ble
SQL> pause Press [Enter] to continue... fe r a
an s
- t r
3) Press Enter to continue to the next step in the script. The script connects to the
n
no
database as HR user and creates the first test transaction, which consists of inserting
a
five rows.
a s
) h i d eฺ
Press [Enter] to continue... m
co nt Gu
SQL>
i l ฺ
a de transaction ==*/
g m
SQL> /*== Create test data for flashback
tu
SQL> connect hr/hr
i @ S
Connected.
s y uk this
SQL>
SQL> /*== Test(M
a use1 ==*/
u kINTO e to
i hr.regions
transaction
SQL> INSERT
s y n s VALUES (10,'Pole');
Macreated.
1yrow lice
nle
Sta SQL> INSERT INTO hr.regions VALUES (20,'Moon');
1 row created.
1 row created.
1 row created.
1 row created.
SQL> COMMIT;
4) Press Enter to continue to the next step in the script. The script continues to create the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
second test transaction, which consists of updating two rows that you just inserted.
This creates a write-after-write (WAW) dependency. A WAW dependency exists
when a transaction updates or deletes a row that has been inserted or updated by a
dependent transaction.
Press [Enter] to continue...
SQL>
SQL> /*== Test transaction 2 ==*/
SQL> /*== Region 10 and 20 has a WAW dependency on transaction
1 ==*/
SQL> UPDATE hr.regions SET region_name='Two Poles' WHERE ble
region_id = 10;
fe r a
ans
1 row updated.
n - t r
n o
SQL> UPDATE hr.regions SET region_name='Many Moons' WHERE
s a
region_id = 20;
) h a eฺ
m i d
1 row updated. i l ฺ co nt Gu
m a de
SQL> COMMIT;
i @ g S tu
Commit complete. asy
uk this
( M u se
SQL> pauseuk
i e to to continue...
y s
Press [Enter]
as licen to the next step in the script. The script continues to create the
y M
5) Press Enter to continue
nlethird transaction, which consists of updating three rows, one of which was also
Sta updated in the previous transaction. This action creates another WAW dependency.
Press [Enter] to continue...
SQL>
SQL> /*== Test transaction 3 ==*/
SQL> /*== Region 10 has a WAW dependency on transaction 1 and
2 ==*/
SQL> /*== Region 40 and 50 has a WAW dependency on transaction
1 ==*/
SQL> UPDATE hr.regions SET region_name='No star' WHERE
region_id = 10;
1 row updated.
1 row updated.
SQL> COMMIT;
Commit complete.
6) Press Enter to continue to the next step in the script. The script continues to create a
fourth transaction, which consists of updating a row that was inserted in transaction 1.
This action creates another WAW dependency.
ble
Press [Enter] to continue...
fe r a
ans
SQL>
n - t r
SQL> /*== Test transaction 4 ==*/
a no
SQL> /*== Region 30 has a WAW dependency on transaction 1 ==*/
a s
) h i d eฺ
SQL> UPDATE hr.regions SET region_name='Still called Venus'
WHERE region_id = 30; m
co nt Gu
i l ฺ
1 row updated.
g ma tude
u k i@ is S
sy se th
SQL> COMMIT;
Commit complete.
a
(M to u
k
u nsei
SQL> asy
M i c e [Enter] to continue...
pause lPress
y
SQL>
nle
Sta 7) Press Enter to continue to the next step in the script. Finally, the script connects to the
database as SYS user and switches archive logs. Flashback Transaction requires at
least one archived log to start analyzing redo.
Press [Enter] to continue...
SQL>
SQL> connect / as sysdba
Connected.
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
System altered.
SQL>
SQL> prompt "Setup for Flashback Transaction completed"
"Setup for Flashback Transaction completed"
SQL> pause Press [Enter] to continue...
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
i) On the Select Transaction: Show Details page, review the erroneous UPDATE
commands and click OK.
j) Click Next to identify any dependent transactions and back out all needed
changes. The Processing: Flashback Transaction window appears. On the
Flashback Transaction: Show Dependencies page, click the first Transaction ID
link. ble
fe r a
s
k) On the Show Dependencies: Details page, review the compensating transactions.
an
- t r
Note that one of the compensating transactions has been executed. It is marked
nno
[exec=yes]. The other one is not executed; it is marked [exec=no]. Click
a
OK.
a s
l) On the Flashback Transaction: Show Dependencies
h
)page, click
i d eฺ Change
the
m
co nt Gu
Recovery Option button. i l ฺ
a Option
m) On the Show Dependencies: Change g mRecovery t u de page, select Cascade,
S transaction changes, and click
i@ isdependent
which will also back out thekerroneous
OK.
u
sy se t h
a u Show Dependencies page, click Next.
(MTransaction:
n) On the Flashback
k i t o
a
o) Click stheyuShow e n seSQL Script button.
Undo
M lic
p)y On the Review: Show Undo SQL page, review all compensating UPDATE
n l e
Sta commands, and then click OK.
q) Enter the following command in the Execute SQL region, and click the Execute
SQL button, to preview the result that the compensating undo statements produce:
SELECT * FROM HR.REGIONS
r) Note that the “Many Moons” row disappeared from the result list. Click OK.
s) On the Flashback Transaction: Review page, click Finish.
t) The Flashback Transaction executed successfully. Click OK.
u) Go back and view the contents of the HR.REGIONS table. Return to the Tables
page. Specify HR as the Schema, click Go, select the REGIONS table, and then
select View Data from the Actions drop-down list and click Go.
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
ble
Connected to:
fe r a
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
ans
Production
n - t r
Testing options a no
With the Partitioning, OLAP, Data Mining and Real Application
a s
) h i d eฺ
m
co nt Gu
SQL>
i l ฺ
SQL> @flatxn_cleanup.sql
g ma tude
SQL> set serveroutput on
u k i@ is S
SQL> set term on
SQL> set lines 200 sy
a e th
SQL> set pause(M
i on
t o us
SQL>
s y uk / nassesysdba
a lice
SQL> connect
M
y
Connected.
nleSQL>
Sta SQL> DELETE FROM hr.regions WHERE region_id=10;
1 row deleted.
1 row deleted.
1 row deleted.
1 row deleted.
SQL> COMMIT;
Commit complete.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL>
SQL> ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY)
COLUMNS;
Database altered.
Database altered.
ble
SQL> REVOKE EXECUTE ON dbms_flashback FROM hr;
fe r a
Revoke succeeded. ans
n - t r
SQL> REVOKE select any transaction FROM hr;
a no
a s
Revoke succeeded. ) h i d eฺ
m
co nt Gu
i l ฺ
ma tude
SQL>
SQL> exit
g
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
These practices cover the use of Flashback Database and Flashback Data Archive.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
instead of performing a recovery. Unless specified otherwise, you should log in as the SYS
user as SYSDBA through SQL*Plus or Database Control.
1) Using Enterprise Manager, turn on flashback logging for your database (enable
Flashback Database).
a. In Database Control, click the Availability tab, and then the Recovery Settings
link in the Backup/Recovery Setup region.
b. Scroll down and select the Enable Flashback Database check box. Click Apply.
On the Confirmation page, click Yes to proceed with the database shutdown.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
c. Entersthe
a n se using oracle/oracle and click OK.
yuhost ecredentials
M lic
d.y Click Yes on the Restart Database: Confirmation page.
n l e
Sta e. Click Refresh and wait for the database to restart. You may need to click Refresh
several times.
2. After the database has been restarted with flashback logging enabled, note the current
SCN of the database by querying the V$DATABASE view.
CURRENT_SCN
-----------
712863
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
3. Note the sum of the salaries in the HR.EMPLOYEES table and the count of the rows
in the JOB_HISTORY table.
SQL> SELECT SUM(salary) FROM hr.employees;
SUM(SALARY)
-----------
691400
SQL> SELECT COUNT(*) FROM hr.job_history;
ble
COUNT(*)
fe r a
----------
ans
10
n - t r
a no
h a
4. Run the flb_db_txn.sql script to perform some HR reorganization s ฺ updates as
was run in the practice for the lesson titled “Database )
Recovery.”id e
o m G u
a. Enter the following at the SQL prompt:ai
lฺc ent
g m tud
SQL> @flb_db_txn.sql k i @ i s S
s y u t h
a u s e
k i (M of that
Following is the output
t o command:
s yu ense
SQL> @flb_db_txn.sql
a
y Mupdatelicemployees set department_id = 90 where job_id =
SQL>
l e
SQL>
n 'IT_PROG';
Sta
5 rows updated.
SQL>
SQL> update employees e set salary = least(e.salary,(select
(min_salary + max_salary)/2 * 1.10 from jobs j where j.job_id
= e.job_id)) where job_id not like 'AD_%';
SQL>
SQL> commit;
Commit complete.
SQL>
CURRENT_SCN
-----------
716681
SUM(SALARY)
-----------
679050
ble
SQL> SELECT COUNT(*) FROM hr.job_history; fe r a
ans
COUNT(*) n - t r
----------
a no
15
a s
) h i d eฺ
SQL> m
co nt Gu
i l
a SCN ฺ
6. Using RMAN, flash back the databasegtom the firsttu devalue noted in step 2.
u k i@ is S
a. Shut down and then mount
a e th by entering the following:
sy thesdatabase
M to u
SQL> SHUTDOWNi (IMMEDIATE
k
syu cMOUNT
SQL> STARTUP
a e nse
M li
b.y Go to the RMAN session in another Xterm window, and exit the current RMAN
n l e
Sta session there. Then log in to RMAN again.
$ rman target / NOCATALOG
c. At the RMAN prompt, enter the FLASHBACK DATABASE command, and supply
the SCN number recorded in step 2:
RMAN> FLASHBACK DATABASE TO SCN=712863;
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
7. Before opening the database for read/write, verify that the database was flashed back
to the correct SCN by looking at the contents of the tables and seeing that they are
back to what was noted in step 3.
a. Enter the following at the SQL prompt to open the database in read-only mode:
$ sqlplus / as sysdba
SQL> alter database open read only;
b. Enter the following at the SQL prompt to determine the salary sum for the
ble
EMPLOYEES table.
fe r a
ans
SQL> SELECT SUM(salary) FROM hr.employees;
n - t r
SUM(SALARY)
a no
a s
eฺ
-----------
691400 ) h i d
c m
o t Gu
i l ฺ n RESETLOGS keyword.
ma totuuse
8. Open the database for read/write use. You have
g dethe
a. Shut down the database by k
entering
S at the SQL prompt:
i@ theisfollowing
u
sy se t h
a
(M to u
SQL> shutdown immediate
k
Database closed.
u nse i
Database
a s ydismounted.
e shut down.
M
ORACLE
y l i
instance c
nle
Sta b. Enter the following at the SQL prompt to start up the database in the MOUNT
state.
SQL> startup mount
ORACLE instance started.
c. Enter the following at the SQL prompt to open the database in read/write mode:
SQL> alter database open resetlogs;
Database altered.
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
M as licen END_TIME
BEGIN_TIME FLASHBACK_DATA
le y
DB_DATA REDO_DATA
SQL>
FLASHBACK_SIZE
--------------
Note: Your results will probably vary slightly from those shown here.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
SQL>
SQL> /*== Create a second undo tablespace for testing ==*/
SQL> DROP TABLESPACE undotbs2 INCLUDING CONTENTS
2 /
DROP TABLESPACE undotbs2 INCLUDING CONTENTS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
*
ERROR at line 1:
ORA-00959: tablespace 'UNDOTBS2' does not exist
Tablespace created.
ble
SQL> pause Press [Enter] to continue...
Press [Enter] to continue... fe r a
t r a ns
SQL> /*== Set up the HR database account for this lesson
o n - ==*/
system privilege. ==*/SQL> s an
SQL> /*== Note: The HR user has the UNLIMITED TABLESPACE
i
SQL> CREATE USER
t u
(MARCHIVE_ADMIN
o PROFILE DEFAULT IDENTIFIED BY
u k e
ARCHIVE_ADMIN
a e ns
sy cTABLESPACE
y
2 DEFAULT
M l i FLA_TBS1 TEMPORARY TABLESPACE TEMP
nle
3 ACCOUNT UNLOCK;
Grant succeeded.
SQL>
SQL> /*== Setup for Flashback Data Archive completed ==*/
SQL> /*== The ARCHIVE_ADMIN user has the password:
ble
ARCHIVE_ADMIN ==*/
SQL> /*== The HR user has the password: HR ==*/ fe r a
SQL>
ans
SQL> pause Press [Enter] to continue...
n - t r
Press [Enter] to continue...
a no
a s
SQL>
) h i d eฺ
m
coprivileges
G u
2) To give the ARCHIVE_ADMIN user administrative
i l ฺ t for creating,
maintaining, and dropping flashback data
g
a dexecute
marchives, u en the following command
as the SYS user:
k i @ is St
GRANT FLASHBACK ARCHIVE
a syu seADMINISTER
th TO archive_admin;
$ sqlplus / as(M sysdbao u
k i
SQL> GRANTuFLASHBACK e t ARCHIVE ADMINISTER TO archive_admin;
a y
s cen s
M
y succeeded.
Grant li
n l e
Sta SQL> exit
SQL>
TABLESPACE fla_tbs1
QUOTA 10M
RETENTION 1 YEAR
/ 2 3 4 5
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;
Grant succeeded.
ble
SQL>
fe r a
ans
6) You now switch to the role of a flashback archive user. Connect as the HR user with
- t r
the HR password. To enable this flashback data archive for the EMPLOYEES table,
n
execute the following command:
a no
ALTER TABLE hr.employees FLASHBACK ARCHIVE fla1; a s
) h i d eฺ
SQL> connect HR/HR m
co nt Gu
Connected. i l ฺ
a deARCHIVE fla1;
SQL> ALTER TABLE hr.employeesm FLASHBACK
i @ g S tu
Table altered.
s y uk this
( M a use
SQL> exit
y u ki se to
s increase
7) To viewaand
c e nthe salary of Mr. Fox three times by 1000, execute the
y M l
flada_dml.sql i script. This produces activity in the flashback data archive.
n l e
Sta $ sqlplus / as sysdba
SQL> @flada_dml
SQL> REM "********************************************** "
SQL> REM "For demo purposes ONLY: Flashback Data Archive "
SQL>
SQL> connect hr/HR
Connected.
SQL>
SQL> set echo on
SQL> set serveroutput on
SQL> -- set verify on
SQL> set term on
SQL> set lines 200
SQL> set pages 44
SQL> set pause on pause "Press [Enter] to continue..."
SQL>
SQL> /*== Query the current salary for Mr. Fox ==*/
SQL>
SQL> SELECT employee_id, last_name, salary
2 FROM hr.employees
3 WHERE last_name = 'Fox'
4 /
Press [Enter] to continue...
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
1 row selected.
SQL>
SQL> pause Press [Enter] to continue...
Press [Enter] to continue...
SQL>
ble
SQL>
SQL>
/*== Increase the salary three times by 1000 ==*/
fe r a
SQL> UPDATE hr.employees
ans
2 SET salary = salary + 1000
n - t r
3 WHERE last_name = 'Fox'
a no
4 /
a s
) h i d eฺ
1 row updated. m
co nt Gu
i l ฺ
SQL> COMMIT
g ma tude
2 /
u k i@ is S
Commit complete. as
y e th
i ( M to us
y
SQL> UPDATE
s ukhr.employees
n sesalary + 1000
a
2 SET
ic e
salary =
l e y3MWHERE llast_name = 'Fox'
n
Sta
4 /
1 row updated.
SQL> COMMIT
2 /
Commit complete.
1 row updated.
SQL> COMMIT
2 /
Commit complete.
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL> /*== Query the up-to-date value for Mr. Fox ==*/
SQL>
SQL> SELECT employee_id, last_name, salary
2 FROM hr.employees
3 WHERE last_name = 'Fox'
4 /
Press [Enter] to continue...
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
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
11) As the HR user, you realize that the recent updates were mistakes. To revert to the
original values for your chosen historic date (for example, ten minutes ago), execute
the following command (replace '10' MINUTE with your chosen historic date):
UPDATE hr.employees
SET salary = (SELECT salary FROM hr.employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '10' MINUTE)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
1 row updated.
SQL>
ble
12) From your SQL*Plus session, connect to the database as the SYS user and list the
fe r a
data dictionary views available to you. Execute the flada_list1.sql file: ans
n - t r
SQL> connect / as sysdba
a no
Connected.
a s
SQL> @flada_list1
) h i d eฺ
m
co nt Gu
SQL> REM "******************************************* "
i l ฺ
SQL> REM "For demo purposes ONLY:"
SQL>
g ma tude
u k i@ is S
SQL> connect / as sysdba
sy se th
Connected.
SQL>
a
(M to u
i
SQL> set echo on
k
syu cense
SQL> set serveroutput on
a
SQL> -- set verify on
li
le yM
SQL> set term on
n SQL> set lines 200
Sta SQL> set pages 44
SQL> set pause on pause "Press [Enter] to continue ..."
SQL>
SQL> /*== To list the available data dictioary views ==*/
SQL>
SQL> SELECT table_name
2 FROM dict
3 WHERE table_name LIKE '%FLASHBACK_ARCHIVE%'
4 /
Press [Enter] to continue ...
TABLE_NAME
------------------------------
DBA_FLASHBACK_ARCHIVE
DBA_FLASHBACK_ARCHIVE_TABLES
DBA_FLASHBACK_ARCHIVE_TS
USER_FLASHBACK_ARCHIVE
USER_FLASHBACK_ARCHIVE_TABLES
SQL>
SQL> col FLASHBACK_ARCHIVE_NAME format A25
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
yM li
l e
SQL>
n SQL> /*== To query the time when the flashback data archive(s)
Sta have been created ==*/
SQL>
SQL> SELECT flashback_archive_name, create_time, status
2 FROM dba_flashback_archive
3 /
Press [Enter] to continue ...
FLASHBACK_ARCHIVE_NAME CREATE_TIME
STATUS
------------------------- ------------------------------------
--------------------------------------- -------
FLA1 25-JUL-07 02.35.23.000000000 PM
SQL>
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)
FLASHBACK_ARCHIVE#
NOT NULL NUMBER
TABLESPACE_NAME
NOT NULL VARCHAR2(30)
QUOTA_IN_MB
VARCHAR2(40)
SQL>
SQL> DESC dba_flashback_archive_tables
Name
Null? Type
-------------------------------------------------------------
---------------------------------------------------- --------
--------------------------------------------------------------
--------------
TABLE_NAME
NOT NULL VARCHAR2(30)
OWNER_NAME
NOT NULL VARCHAR2(30)
FLASHBACK_ARCHIVE_NAME
NOT NULL VARCHAR2(255)
ARCHIVE_TABLE_NAME
VARCHAR2(53)
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL> /*== Query the table name(s), the owner name(s), and ==*/
SQL> /*== the internal "history" table name(s) of the
flashback data archive ==*/
SQL>
SQL> SELECT *
2 FROM dba_flashback_archive_tables
3 /
Press [Enter] to continue ...
SQL> exit
13) To practice additional flashback data archive maintenance tasks, perform the
following steps: Using SQL*Plus, connect to the database as the ARCHIVE_ADMIN
user.
$ sqlplus ARCHIVE_ADMIN/ARCHIVE_ADMIN
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL>
14) Data in the flashback data archive is automatically purged when the retention time
expires. However, you can also purge data explicitly with the following command to
purge data older than two minutes:
ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE TIMESTAMP (SYSTIMESTAMP -
INTERVAL '2' MINUTE);
ble
SQL> ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE fe r a
TIMESTAMP(SYSTIMESTAMP - INTERVAL '2' MINUTE); ans
n - t r
Flashback archive altered.
a no
a s
SQL>
) h i d eฺ
m
cano additional
G u10 MB tablespace as
l
15) Execute the flada_tbs2.sql script to create
i ฺ t
the SYS user.
g ma tuden
u k i@ is S
sy se th
SQL> @flada_tbs2
Connected.
a
(M ontoonu
SQL> set serveroutput
SQL> -- set k i
u onnse
verify
a
SQL> setsyterm c e 200
M l
y set pages 44
SQL> set lines i
n l eSQL>
Sta SQL> set pause on
SQL>
SQL> /*== Create another tablespace ==*/
SQL>
SQL> DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
2 /
DROP TABLESPACE fla_tbs2 INCLUDING CONTENTS
*
ERROR at line 1:
ORA-00959: tablespace 'FLA_TBS2' does not exist
SQL>
SQL> CREATE SMALLFILE TABLESPACE fla_tbs2
2 DATAFILE '/u01/app/oracle/oradata/orcl/fla_tbs02.dbf'
3 SIZE 10M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 32767M
Tablespace created.
SQL>
16) As the ARCHIVE_ADMIN user, add 5 MB of the FLA_TBS2 tablespace to the FLA1
flashback data archive.
SQL> connect ARCHIVE_ADMIN/ARCHIVE_ADMIN
Connected.
SQL> ALTER FLASHBACK ARCHIVE fla1 ADD TABLESPACE fla_tbs2
QUOTA 5M;
ble
Flashback archive altered.
fe r a
ans
SQL>
n - t r
no
17) All tables in one specific flashback data archive have the same retention time. Change
a
a s
the retention time of the FLA1 flashback data archive to two years.
) h i d eฺ
SQL> ALTER FLASHBACK ARCHIVE fla1 MODIFY m Gu 2 YEAR;
co nRETENTION
i
a del ฺ t
Flashback archive altered. gm
i @ S tu
SQL>
s y uk this
( M a user,udropse the FLA1 flashback data archive.
18) As the ARCHIVE_ADMIN
u kai flashback
e todata archive includes dropping the internal tamper-
y
Note: Dropping
s table.
ahistory s
enYou cannot drop this table directly due to auditing and security
proofed
y M l i c
n l erequirements. Dropping a flashback data archive does not drop the tablespaces in
Sta which they are stored, because the tablespaces might contain other data.
SQL> DROP FLASHBACK ARCHIVE fla1;
19) Wait a minute or two and connect as SYS user; clean up your environment by
executing the flada_cleanup.sql script.
SQL> @flada_cleanup
SQL> REM Execute this script script for training purposes only
SQL> REM Undo Cleanup for Flashback Data Archive
SQL> REM Execute script as SYSDBA
SQL>
SQL> set echo on
SQL> set serveroutput on
SQL> set term on
2 DATAFILE '/u01/app/oracle/oradata/orcl/undotbs01.dbf'
3 SIZE 105M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 32767M
4 /
Tablespace created.
SQL> exit
Note: If you execute the DROP command too quickly while internal processing is still
occurring, you might receive an ORA-30013 error. Wait and try again.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
$ cd $HOME/labs
$ ./hm_setup.sh
sqlplus / as sysdba
ble
fe r a
Connected to:
ans
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta n - t r
With the Partitioning, OLAP and Data Mining options
a no
a s
)
SQL> select object_id from dba_objects where h i d eฺ
owner='SCOTT' and
object_name='TABJMW'; m
co nt Gu
i l ฺ
no rows selected g ma tude
k S
i@ is number)
u
sy se t h
SQL> create table scott.tabjmw(c tablespace users;
a
(M to u
k
Table created.i
a syu cense
li obj number;
y Mvariable
l e
SQL>
n SQL> begin
Sta select object_id into :obj from dba_objects where
owner='SCOTT' and object_name='TABJMW';
end;
/
2 3 4
PL/SQL procedure successfully completed.
OBJ
----------
70975
1 row updated.
SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
yM li
l e
DBMS_HM.GET_RUN_REPORT('DICTCHECK')
n --------------------------------------------------------------------
Sta ------------
Basic Run Information
Run Name : DictCheck
Run Id : 381
Check Name : Dictionary Integrity Check
Mode : MANUAL
Status : COMPLETED
Start Time : 2007-07-25 15:16:27.535007 -04:00
End Time : 2007-07-25 15:16:30.929141 -04:00
Error Encountered : 0
Source Incident Id : 0
Number of Incidents Created : 0
DBMS_HM.GET_RUN_REPORT('DICTCHECK')
-------------------------------------------------------------------
Status : OPEN
DBMS_HM.GET_RUN_REPORT('DICTCHECK')
--------------------------------------------------------------------
Priority : CRITICAL
Message : SQL dictionary health check: invalid column number
8 on
object TAB$ failed
Message : Damaged rowid is AAAAACAABAAASpSAAD - description:
Object
SCOTT.TABJMW is referenced
…
ble
fe r a
SQL>
ans
4) Go back to your EM Home page. What do you observe? n - t r
n o
s a
a) You should see a new critical alert (Data Failure) for the previously detected
corruption in the Alerts section of the Home page. ha ฺ
m ) u i de
o
a ilฺc ent G
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
a s cen
M li pool and buffer cache first, and then exit and reconnect as the SYS
y your shared
5) Flush
l e
n user. From a SQL*Plus session connected as the SYS user, execute the following
Sta statement: select * from scott.tabjmw;
What do you observe?
$ sqlplus / as sysdba
SQL> alter system flush shared_pool;
SQL> alter system flush buffer_cache;
SQL> exit
…
$ sqlplus / as sysdba
…
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
b) On the Support Workbench Problems tabbed page, you should see a new Activefe r a
Incident whose description is similar to ORA 7445 [qcstda()+515].
t r a ns
o n -
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
c) Click the “+” icon
( M a
in u secolumn for this problem.
the Details
d) This showsu e to
i the corresponding
kyou first-time incident.
a y
s cen s
e) Click li
y M that incident number.
l e
n f) This takes you to the corresponding Incident Details page. Make a note of the
Sta incident number (26649).
g) Click the incident number. In the Application Information section of that page,
you can clearly see what caused the incident. It was due to "select * from
scott.tabjmw".
h) You can also see two dump files generated from the Dump Files tabbed page. The
first one corresponds to the incident dump file and is located in the ADR directory
/u01/app/oracle/diag/rdbms/orcl/orcl/incident/incdir_n
nnnn. The second one is the classical corresponding trace file located in
/u01/app/oracle/diag/rdbms/orcl/orcl/trace.
i) Click the eyeglasses icon in the View Contents column for the incident trace (first
row).
j) If you did not save your Host credentials previously, you end up on the Host
ble
Credentials page, where you can enter oracle/oracle and click Continue.
fe r a
k) This brings you to the Contents page, where you can see the structured trace ans
information. n - t r
n o
l) For example, click the “current sql statement” link below s a
the “incident dump”
h
link. This prints the culprit SQL statement in the window
) a below etheฺ Trace Map.
m i d
m) Click OK.
i l ฺ co nt Gu
mathetProblem
n) On the Incident Details page again,gclick u de Key link.
o) On the Problem Details page, k @ EditistoSthe right of the SR field.
iclick
s y u th
p) Enter 1234 in the a
MSR Number e
uspop-up window that appears and click OK. It is
i ( t o
s y uk younalready
assumed that
s e opened an SR (1234) with MetaLink.
M a lice
y
nle
Sta
q) You should now see the SR number on the Problem Details page.
r) Click the Activity Log tab.
s) This takes you to the Activity Log tabbed page, on which you can now see your
last action on the problem. You can enter a comment here.
$ ls
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
$ cd incdir_26649
$ ls ble
fe r a
orcl_ora_1487_i26649.trc
ans
orcl_ora_1487_i26649.trm
n - t r
$ cd ../..
a no
$ ls
a smetadata
alert cdump hm incident incpkg ir lck
) h i d eฺ stage
sweep trace m
co nt Gu
$ cd hm i l ฺ
$ ls
g ma tude
HMREPORT_DictCheck.hm
u k i@ is S
sy se th
$ cd ..
$ a u
(Myour incident
8) Use ADRCI to k i
locate
u nse t o and problem information.
s y
a lice
M
$ adrci
y
nleADRCI: Release 11.1.0.6.0 - Beta on Wed Jul 25 16:03:42 2007
Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.
[bad_table_name] 2007-05-24
01:10:19.684541 -07:00
…
adrci>
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.
f) Click Next.
g) On the Quick Packaging: Schedule page, make sure Immediately is selected and
click Submit.
h) The Processing: Generating Upload File for Package page appears. Wait until it is
finished.
i) On the Confirmation page, you should see something similar to: "Upload file
for package: ORA7445qc_20070725160927 has been successfully
generated. The upload file is located at
/u01/app/oracle/product/11.1.0/db_1/stc-raclin06
.us.oracle.com_orcl/sysman/emd/state/
ble
ORA7445qc_20070725160927_COM_1.zip. Please send it manually
fe r a
to Oracle."
ans
j) Click OK. n - t r
n o
k) Back to the Problem Details Activity Log tabbed page, you a
should now see two
sfor
h
new entries in the log reporting about the package creation
) a eฺproblem.
this
m i d
l) In the Summary section, click Yes to the right
i l ฺ t Gu entry.
coof thenPackaged
a wheredyou
mfrom e can see your package.
g
m) This takes you to the Packages page,
S t u
n) Select your package, and u k i@
click View.his
a sy sDetails
e t
o) This takes you toM
i ( the Package
t o u page, where you can see the package
details. uk e
a s y e n s
y M lic tab.
p) Click the Files
nleq) On the Files tabbed page, you can now see the Full Package Content view.
Sta 10) Use ADRCI to determine the list of existing packages.
$ adrci
Stan 2007
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
With the Partitioning, OLAP and Data Mining options
OBJ
----------
70975
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
1 row updated.
SQL> commit;
Commit complete.
SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition
ble
Release 11.1.0.5.0 - Beta
With the Partitioning, OLAP and Data Mining options fe r a
$ an s
n - t r
12) Use Enterprise Manager to close your incident.
a no
s right ฺof the
a) On the Package Details page, click the “problem” link toathe
h
)
“Problems in Package” field in the Summary section.
m u i de
o your Gincident and click
ilฺc select
b) On the Problem Details Incidents tabbed page,
a n t
Close. g m tude
c) On the Confirmation page,
u k i@Yes. is S
click
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
1) To set up this block corruptions practice, use a terminal window, navigate to the
$HOME/labs directory, and execute the block_corrupt.sh script. This script
creates a tablespace called TBSBC and a user called BC. The tablespace is then
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
populated with data from the HR schema. A backup of the new tablespace is
performed, and then a corruption is introduced into the data file. The EMPLOYEES,
DEPARTMENTS, and REGIONS tables are then queried from the BC schema. Take a
few moments to inspect the script actions before executing it.
$ ./block_corrupt.sh
SQL> SQL>
Grant succeeded.
SQL> SQL>
Table created.
SQL> SQL>
Table created.
SQL> SQL>
Commit complete.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options
nlename=/u01/app/oracle/oradata/orcl/tbsbc12.dbf
input datafile file number=00007
RMAN>
List of Database Failures
=========================
4) Alternatively, you can query the V$IR_FAILURE view to garner details about the
failure:
$ sqlplus sys/oracle as sysdba
SQL> select failure_id, time_detected, description, impacts
from V$IR_FAILURE where impacts like '%BC%';
SQL>
FAILURE_ID TIME_DETECTED
------------------
1942 2007-10-07:18:47:21
Datafile 3: '/u01/app/oracle/oradata/orcl/tbsbc12.dbf'
contains one or more corr
upt blocks
Some objects in tablespace TBSBC might be unavailable
1945 2007-10-07:18:47:21
Block 12 in datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corr
ble
FAILURE_ID TIME_DETECTED
---------- ------------------- fe r a
DESCRIPTION ans
n
-------------------------------------------------------------- - t r
------------------
a no
IMPACTS
a s
) h d eฺ
--------------------------------------------------------------
i
------------------ m
co nt Gu
i l ฺ
ma tude
upt
g
Object EMPLOYEES owned by BC might be unavailable
u k i@ is S
a
Block 20 in datafile sy3: se th
1951 2007-10-07:18:47:21
k i (M to u
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corr
upt u e
y ens owned by BC might be unavailable
Objectas
yM lic
DEPARTMENTS
l e
n FAILURE_ID TIME_DETECTED
Sta ---------- -------------------
DESCRIPTION
--------------------------------------------------------------
------------------
IMPACTS
--------------------------------------------------------------
------------------
1957 2007-10-07:18:47:21
Block 28 in datafile 3:
'/u01/app/oracle/oradata/orcl/tbsbc12.dbf' is media corrupt
Object REGIONS owned by BC might be unavailable
SQL> exit
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2716019574.hm
a sy se th
The repair includes complete media recovery with no data loss
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2681015512.hm
k i (M to u0 0 NOT RUN
syu cense
SQL> exit
a
yM li
t a n6)leRerun the RMAN advise failure all command. After inspecting the results
S of that command, run the RMAN repair failure command ( an advise
failure command must precede a repair command).
Note: Your actual script name will vary somewhat from the example.
$ rman target / nocatalog
RMAN> exit
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
Sta
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP and Data Mining options
SQL> SQL>
Tablespace dropped.
SQL> SQL>
User dropped.
$ sqlplus / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
ble
With the Partitioning, OLAP, Data Mining and Real Application
fe r a
Testing options
ans
SQL> @sql_repair1 n - t r
SQL>
a no
a s
SQL> -- This example generates a workaround for a crash. This
bug has already ) h i d eฺ
m
co nt Gu
SQL> -- been fixed but we toggle the bug fix using an
i l ฺ
ma tude
underscore parameter
g
SQL> -- which uses the (internal) feature called bug fix
control.
u k i@ is S
sy se th
SQL> -- This script will pause periodically to allow you to
a
(M to u
read the comments
k i
SQL> -- and see the output of the previous command on the
syu cense
screen. Just press
a
yM li
SQL> -- return to make the demo resume.
nle SQL>
Sta
SQL> pause
2) Press Enter, and then press Enter again to continue. The script now grants privileges
to the user SCOTT that is used for the demo.
SQL>
SQL> -- To begin the demo we will create the user scott and
grant
SQL> -- advisor privileges to him.
SQL>
SQL> pause
SQL>
SQL> grant connect, resource, dba, query rewrite, unlimited
tablespace to scott identified by tiger;
Grant succeeded.
User altered.
SQL>
SQL>
SQL> -- Next we need to create and populate the table used by
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
the demo.
SQL> -- We will also create an index on the table;
SQL>
SQL> pause
3) When you press Enter, a table is created and populated.
SQL> connect scott/tiger;
Connected.
SQL>
SQL> drop table t;
drop table t
ble
*
fe r a
ERROR at line 1:
ans
ORA-00942: table or view does not exist
n - t r
a no
a s
eฺ
SQL>
SQL> create table t(a varchar(40), b number, h
) cuvarchar(240),
i d d
o m
ilฺc ent G
varchar(240));
a
Table created.
@ gm Stud
y u ki this
SQL>
a s tc onset(b, d, a);
SQL> -- create M
i ( index
t o u
SQL> k
syu cinto
SQL> insert
a e nstevalues('a', 1, 'b', 'c');
M li
1yrow created.
n l e
Sta SQL> insert into t values('a', 1, 'x', 'c');
1 row created.
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
4) Press Enter to continue. This time you need to switch off some code in the system to
intentionally cause a crash when executing a particular SQL statement.
SQL>
SQL> -- switch the code
SQL> alter session set "_fix_control"="5868490:OFF";
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Session altered.
n l e
Plan
Sta --------------------------------------------------------------
----------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------
----------------
| 0 | DELETE STATEMENT | | 1 | 507 | 8
(25)| 00:00:01 |
| 1 | DELETE | T | | |
| |
|* 2 | FILTER | | | |
| |
| 3 | HASH GROUP BY | | 1 | 507 | 8
(25)| 00:00:01 |
|* 4 | HASH JOIN | | 1 | 507 | 7
(15)| 00:00:01 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------
------------------
|* 6 | TABLE ACCESS FULL| T | 2 | 362 | 3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
(0)| 00:00:01 |
--------------------------------------------------------------
----------------
2 - filter(ROWID<>MAX(ROWID))
4 - access("T1"."A"="T2"."A" AND "T1"."B"="T2"."B" AND
"T1"."D"="T2"."D")
5 - filter("T2"."A"='a')
ble
6 - filter("T1"."A"='a')
fe r a
PLAN_TABLE_OUTPUT
an s
--------------------------------------------------------------
n - t r
------------------
a no
a s
Note
) h i d eฺ
----- m
o t Gu
cstatement
i l ฺ
ma tuden
- dynamic sampling used for this
g
26 rows selected.
u k i@ is S
SQL> a sy se th
i
SQL> -- The plan (Mshows
t o uthat we we will do a full table scan
k
oun r. yu
a nse this simple system it will crash the
sIf weceexecut
SQL> --
yM li
l e
system.
n SQL>
Sta SQL> Pause
6) Press Enter to continue. Now you execute the statement and see that it crashed.
SQL> --- This statement caused the system to crash.
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);
delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d)
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [13011], [71129],
[16777631], [0],
[16777631], [17], [], []
SQL>
7) You now need to use the SQL Repair Advisor to analyze the situation and find a
better alternative. Remain connected in your SQL*Plus session and execute the
sql_repair2.sql script.
SQL> @sql_repair2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
sy se th
problem lets ensure
a
SQL> -- that the actual code that prevents this issue in real
(M to u
life is switched off.
k i
syu cense
SQL>
a
SQL> pause
li
le yM
8) Press Enter to continue. Make sure that the code for the previous issue is still
n
Sta disabled.
SQL>
SQL> alter session set "_fix_control"="5868490:OFF";
Session altered.
SQL>
SQL> -- Before we can run the SQL Repair Advisor we need to
create a
SQL> -- diagnosis task using dbms_sqldiag. We need to specify
the SQL text
SQL> -- for the statement that causes the crash and a task
name. We also need
SQL> -- to specify the problem type. There are three possible
problem types
SQL>
SQL> -- PROBLEM_TYPE_COMPILATION_ERROR
SQL> -- PROBLEM_TYPE_EXECUTION_ERROR
SQL> -- WRONG_RESULTS
SQL>
SQL> -- In this cause since the statement failed during
execution we will use
SQL> -- PROBLEM_TYPE_EXECUTION_ERROR. When the SQL Repair
Advisor completes we will run
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
18
19 dbms_output.put_line ('executed t_id = ' || t_id);
20
21 rep_out := dbms_sqldiag.report_diagnosis_task (t_id,
DBMS_SQLDIAG.TYPE_TEXT);
22
23 dbms_output.put_line ('Report : ' || rep_out);
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
24
25 end;
26 /
t_id = sqldiag_bug_5869490
executed t_id = sqldiag_bug_5869490
Report : GENERAL INFORMATION SECTION
--------------------------------------------------------------
-----------------
Tuning Task Name : sqldiag_bug_5869490
Tuning Task Owner : SCOTT
Tuning Task ID : 47
ble
Workload Type
Execution Count
: Single SQL Statement
: 1 fe r a
Current Execution : EXEC_47
ans
Execution Type : SQL DIAGNOSIS
n - t r
Scope : COMPREHENSIVE
a no
Time Limit(seconds) : 1800
a s
Completion Status
)
: COMPLETED h i d eฺ
Started at m
co nt Gu
: 05/29/2007 01:19:49
Completed at i l ฺ
: 05/29/2007 01:20:07
g ma tude
u k i@ is S
--------------------------------------------------------------
-----------------
Schema Name: SCOTT a sy se th
SQL ID
k (M to u
: if5z1dvyudh0hj
s cense from t t1 where t1.a = 'a' and rowid <>
SQL Text yu: delete
a
(select
yM li max(rowid) from t t2 where t1.a= t2.a and t1.b =
l e
n t2.b and
Sta t1.d=t2.d)
--------------------------------------------------------------
-----------------
FINDINGS SECTION (1 finding)
--------------------------------------------------------------
-----------------
Recommendation
--------------
- Consider accepting the recommended SQL patch.
Rationale
---------
Recommended plan with hash value 4122352137 has number of
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
rows 0, check
sum 0, execution time 22 and 16 buffer gets
--------------------------------------------------------------
-----------------
ADDITIONAL INFORMATION SECTION
--------------------------------------------------------------
-----------------
- Strategy execution Original plan failed with error code 600
and error
message
ble
- Recommended plan with hash value 4122352137 has number of
rows 0, check sum fe r a
0, execution time 22 and 16 buffer gets
ans
- Alternative plan with hash value 3804998351 has number of
n - t r
rows 0, check sum
a no
0, execution time 1 and 16 buffer gets
a s
) h d eฺ
- Alternative plan with hash value 4122352137 has number of
i
rows 0, check sum m
co nt Gu
i l ฺ
0, execution time 22 and 16 buffer gets
g ma tude
- Plan for strategy outline based feature toggle with plan
directive (hint)
u k i@ is S
plan hash valuea sy se th
NO_USE_HASH_AGGREGATION(@"SEL$80F8B8C6") has cost 7 with
i
4117267572
k (M to u
syu cense
- Plan for strategy outline based feature toggle with plan
a li
directive (hint)
yM
nle NO_USE_HASH(@"SEL$80F8B8C6" "T1"@"DEL$1") has cost 7 with
Sta
plan hash value
2017343943
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_UNNEST(@"SEL$1") has cost 6 with plan hash value
4122352137
- Plan for strategy outline based feature toggle with plan
directive (hint)
NO_MERGE(@"SEL$7D4DB4AA") has cost 7 with plan hash value
3804998351
- Plan for strategy avoid umbrella features with plan
directive (hint)
NOREWRITE has cost 7 with plan hash value 2017343943
- Plan for strategy avoid umbrella features with plan
directive (hint)
STAR_TRANSFORMATION TEMP_DISABLE has cost 7 with plan hash
value 2017343943
4122352137
- Plan for strategy rule optimizer has cost 0 with plan hash
value 4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.0') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.4') has cost 1 with
ble
plan hash value
4122352137 fe r a
- Plan for strategy optimizer features enabled toggle with
ans
plan directive
n - t r
no
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.5') has cost 1 with
a
plan hash value
a s
4122352137
) h i d eฺ
m
co nt Gu
- Plan for strategy optimizer features enabled toggle with
plan directive i l ฺ
g ma tude
(hint) OPTIMIZER_FEATURES_ENABLE('8.0.6') has cost 1 with
plan hash value
u k i@ is S
4122352137
a sy se th
- Plan for strategy optimizer features enabled toggle with
i (M to u
plan directive
k
syu cense
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.0') has cost 1 with
a li
plan hash value
yM
nle 4122352137
Sta
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.5') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.6') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('8.1.7') has cost 1 with
plan hash value
4122352137
- Plan for strategy optimizer features enabled toggle with
plan directive
4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0') has cost 7 with
plan hash value
4117267572
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.3') has cost 7 with
plan hash
value 4117267572
ble
- Plan for strategy optimizer features enabled toggle with
plan directive fe r a
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.4') has cost 7 with
ans
plan hash
n - t r
value 4117267572
a no
s
- Plan for strategy optimizer features enabled toggle with
a
plan directive
) h i d eฺ
m
co nt Gu
(hint) OPTIMIZER_FEATURES_ENABLE('10.1.0.5') has cost 7 with
plan hash i l ฺ
value 4117267572
g ma tude
u k i@ is S
- Plan for strategy optimizer features enabled toggle with
plan directive
a sy se th
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.1') has cost 7 with
plan hash
k i (M to u
syu cense
value 2017343943
a li
- Plan for strategy optimizer features enabled toggle with
yM
nle plan directive
Sta
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.2') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.3') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('10.2.0.4') has cost 7 with
plan hash
value 2017343943
- Plan for strategy optimizer features enabled toggle with
plan directive
(hint) OPTIMIZER_FEATURES_ENABLE('11.1.0.1') has cost 7 with
plan hash
value 2017343943
--------------------------------------------------------------
-----------------
EXPLAIN PLANS SECTION
--------------------------------------------------------------
-----------------
1- Original
-----------
Plan hash value: 2017343943
ble
-------------------------------------------------------------- fe r a
n s
----------------
| Id | Operation | Name | Rows | Bytes |-tCost
n ra
(%CPU)| Time | n o
s a
--------------------------------------------------------------
---------------- h a eฺ |
) 1 |uid507
| 0 | DELETE STATEMENT |
c o|m G 8
(25)| 00:00:01 | ฺ
il | en | t
|a
m d
| 1 | DELETE
g T
t u |
| |
u k i@ |is S |
|* 2 |
|
FILTER
| a sy se th | |
| 3 |
k i
HASH (MGROUPtoBYu | | 1 | 507 | 8
u
y HASH
(25)| 00:00:01 | e
sJOIN
|* 4 a|s c e n
y M l i | | 1 | 507 | 7
nle|* 5 |
(15)| 00:00:01 |
Sta
TABLE ACCESS FULL| T | 2 | 652 | 3
(0)| 00:00:01 |
|* 6 | TABLE ACCESS FULL| T | 2 | 362 | 3
(0)| 00:00:01 |
--------------------------------------------------------------
----------------
1 - SEL$80F8B8C6
5 - SEL$80F8B8C6 / T2@SEL$1
6 - SEL$80F8B8C6 / T1@DEL$1
2 - filter(ROWID<>MAX(ROWID))
2 - "T2"."A"[VARCHAR2,40], "T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240], ROWID[ROWID,10],
ROWID[ROWID,10], MAX(ROWID)[10]
3 - (#keys=5) "T2"."A"[VARCHAR2,40], "T2"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240], ROWID[ROWID,10],
ROWID[ROWID,10], MAX(ROWID)[10]
4 - (#keys=3) "T2"."A"[VARCHAR2,40], "T1"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22], "T1"."B"[NUMBER,22],
"T2"."D"[VARCHAR2,240],
"T1"."D"[VARCHAR2,240], ROWID[ROWID,10],
ble
"T2"."A"[VARCHAR2,40],
"T2"."B"[NUMBER,22], "T2"."D"[VARCHAR2,240], fe r a
ROWID[ROWID,10]
ans
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
n - t r
"T2"."B"[NUMBER,22],
a no
"T2"."D"[VARCHAR2,240]
a s
6 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
) h i d eฺ
"T1"."B"[NUMBER,22], m
co nt Gu
"T1"."D"[VARCHAR2,240] i l ฺ
g ma tude
Note
u k i@ is S
-----
a
- dynamic sampling
th this statement
sy usedsefor
k i (M to u
syu cWith
2- Original e
nsAdjusted Cost
a li e
------------------------------
l e y Mhash value:
Plan 4122352137
n
Sta --------------------------------------------------------------
---------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------
---------------
| 0 | DELETE STATEMENT | | 1 | 169 | 6
(0)| 00:00:01 |
| 1 | DELETE | T | | |
| |
|* 2 | FILTER | | | |
| |
|* 3 | TABLE ACCESS FULL | T | 2 | 338 | 3
(0)| 00:00:01 |
| 4 | SORT AGGREGATE | | 1 | 169 |
| |
1 - DEL$1
3 - DEL$1 / T1@DEL$1
4 - SEL$1
5 - SEL$1 / T2@SEL$1
l ฺ o t Gu
c"T1"."A"[VARCHAR2,40],
i
ma tuden
2 - (cmp=2,3,4) ROWID[ROWID,10],
g
"T1"."B"[NUMBER,22], "T1"."D"[VARCHAR2,240]
i@ is S
3 - ROWID[ROWID,10], "T1"."A"[VARCHAR2,40],
"T1"."B"[NUMBER,22], uk
a sy se th
"T1"."D"[VARCHAR2,240]
i
4 - (#keys=0)
t u
(MMAX(ROWID)[10]
o
k
a syu cense
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
li
"T2"."B"[NUMBER,22],
y M "T2"."D"[VARCHAR2,240]
n l e
Sta Note
-----
- dynamic sampling used for this statement
--------------------------------------------------------------
-----------------
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
10) Press Enter to continue. If you execute the statement again, you get the same error.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
This is because you have not yet accepted the proposed SQL Patch.
SQL>
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);
delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d)
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [13011], [71129],
ble
[16777631], [0], [16777631], [17], [], []
fe r a
ans
n - t r
SQL>
SQL> -- connect scott/tiger a no
a s
SQL>
) h i d eฺ
m
SQL> -- We need to accept the SQL Patch that the SQL Repair
co nt Gu
Advisor recommended before
i l ฺ
g ma tude
SQL> -- our SQL statement will be able to run without
crashing. To accept the SQL Patch
k i@ is S
SQL> -- we must execute dbms_sqldiag.accept_sql_patch and pass
u
it task name
a sy se th
SQL>
k i (M to u
yu ense
SQL> pause
a s
11) Press
y lic This time you accept the SQL Patch.
MEnter to continue.
nleSQL> execute dbms_sqldiag.accept_sql_patch(task_name =>
Sta 'sqldiag_bug_5869490', task_owner => 'SCOTT', replace =>
TRUE);
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.
PLAN_TABLE_OUTPUT
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
----------------------------------------------------
Plan hash value: 4122352137
ble
--------------------------------------------------------------
--------------- fe r a
| Id | Operation | Name | Rows | Bytes | Cost
ans
(%CPU)| Time |
n - t r
no
--------------------------------------------------------------
a
---------------
a s
| 0 | DELETE STATEMENT | |
) h 1 |
i d eฺ
169 | 6
(0)| 00:00:01 | m
co nt Gu
| 1 | DELETE i l
| Tฺ | | |
| |
g ma tude
|* 2 | FILTER
u k i@ is S| | | |
|
|* 3 |
|
a sy se th
TABLE ACCESS FULL | T | 2 | 338 | 3
i (M to u
(0)| 00:00:01 |
k
|
a syu cense
4 | SORT AGGREGATE | | 1 | 169 |
|
yM li |
Sta
(0)| 00:00:01 |
--------------------------------------------------------------
---------------
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
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
END_OUTLINE_DATA
*/
a
"T2"."B"[NUMBER,22],sy se th
5 - ROWID[ROWID,10], "T2"."A"[VARCHAR2,40],
i (M to u
"T2"."D"[VARCHAR2,240]
k
Note as
yu ense
yM lic
l e
-----
n - dynamic sampling used for this statement
Sta - SQL patch "SYS_SQLPTCH_0144b5bb2a078000" used for this
statement
60 rows selected.
SQL>
SQL> -- Now lets execute it.
SQL>
SQL> pause
13) Press Enter to continue. This time you try to execute the statement again. You should
see that it no longer generates the error. The end of the script reestablishes the
original code path.
SQL> delete from t t1 where t1.a = 'a' and rowid <> (select
max(rowid) from t t2 where t1.a= t2.a and t1.b = t2.b and
t1.d=t2.d);
1 row deleted.
SQL>
SQL> -- Finally we need to restore the system back the way we
found it.
SQL> -- We must drop the SQL Patch we have accepted and turn
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
back on the
SQL> -- original code path that prevented this problem in the
first place.
SQL>
SQL> -- execute dbms_sqldiag.drop_sql_patch(
SQL>
SQL> alter session set "_fix_control"="5868490:ON";
Session altered.
SQL>
ble
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition fe r a
Release 11.1.0.5.0 - Beta
ans
With the Partitioning, OLAP, Data Mining and Real Application
n - t r
Testing options
a no
$
a s
) h i d eฺ
c m
o t Gu
i l ฺ
g
Get the patch name under the Note section den
main steptu12.
14) Finally, drop the patch using the DBMS_SQLDIAG.DROP_SQL_PATCH procedure.
u k i@ is S
a sy se th
SQL> execute DBMS_SQLDIAG.DROP_SQL_PATCH (name =>
(M to u
‘SYS_SQLPTCH_0144b5bb2a078000’);
k i e
a syu censsuccessfully
PL/SQL Procedure completed.
l e y Mexit li
SQL>
Stan
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
of PGA memory.
1) Before you start this lab, stop Enterprise Manager Database Control.
$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release
11.1.0.4.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights
reserved.
https://stc-
raclin06.us.oracle.com:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
ble
... Stopped.
fe r a
$
t r a ns
2) Shut down your database instance and make a copy of your SPFILE. Then
o n -restart
your database instance.
s an
) h a eฺ
$ sqlplus / as sysdba
o m u id
ilฺcon eFri
n t G
SQL*Plus: Release 11.1.0.5.0 - a
m tud May 25 01:41:28
Beta
g
2007
u k i@ is S
Copyright (c) 1982, a th All rights reserved.
sy2007,seOracle.
k i (M to u
a
Connectedsyuto:cense
y M Database
Oracle li 11g Enterprise Edition Release 11.1.0.5.0 -
l e
n Beta
Sta With the Partitioning, OLAP and Data Mining options
$ 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
SQL> startup
ORACLE instance started.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
3) Connected as SYS in SQL*Plus, set the following parameters to the given value in
your SPFILE only. You can use the change_parameters.sql file. ble
_PX_use_large_pool = TRUE fe r a
ans
_memory_broker_stat_interval = 5
_memory_management_tracing = 31 n - t r
parallel_execution_message_size = 36864 a no
a s
parallel_max_servers = 200
) h i d eฺ
parallel_adaptive_multi_user = FALSE
m
co nt Gu
processes = 200
i l ฺ
sga_target = 0
g ma tude
pga_aggregate_target = 0
u k i@ is S
memory_target = 280M
a s y e th
( M to us
SQL> @change_parameters.sql
i
uk n20000
SQL> set pages
s y se
SQL>
a ic e
l e y MALTER lSYSTEM
SQL> SET "_PX_use_large_pool" = TRUE
n SCOPE=SPFILE;
Sta System altered.
System altered.
System altered.
SQL>
SQL> ALTER SYSTEM SET "parallel_execution_message_size" =
36864 SCOPE=SPFILE;
System altered.
System altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
System altered.
System altered.
ble
SQL> ALTER SYSTEM SET "sga_target" = 0 SCOPE=SPFILE; fe r a
ans
System altered.
n - t r
n o
SQL> ALTER SYSTEM SET "memory_target" = 280M s a
SCOPE=SPFILE;
) h a eฺ
m i d
System altered.
i l ฺ co nt Gu
SQL>
g ma tude
k i@session
4) Remain connected in your SQL*Plus i s S
as the SYS user and execute the
s y u t h
amm_setup.sql script.
( M a use
u ki se to
SQL> @amm_setup.sql
y
M as tablespace
SQL> drop
l i c entbssgatbssga including contents and datafiles;
y
drop tablespace including contents and datafiles
nle*
Sta ERROR at line 1:
ORA-00959: tablespace 'TBSSGA' does not exist
SQL>
SQL> create tablespace tbssga datafile 'tbssga12.dbf' size
20m;
Tablespace created.
SQL>
SQL> drop tablespace mytemp including contents and datafiles;
drop tablespace mytemp including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'MYTEMP' does not exist
SQL>
SQL> create temporary tablespace mytemp tempfile 'temp12.f'
size 40m reuse;
Tablespace created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL>
SQL> drop user amm cascade;
drop user amm cascade
*
ERROR at line 1:
ORA-01918: user 'AMM' does not exist
SQL>
SQL> create user amm identified by amm
2 default tablespace tbssga
ble
3 temporary tablespace mytemp;
fe r a
User created.
ans
n - t r
SQL>
a no
SQL> grant connect,resource,dba to amm;
a s
) h i d eฺ
Grant succeeded. m
co nt Gu
i l ฺ
SQL>
g ma tude
i@ 0,
SQL> select substr(COMPONENT,
s S COMP, CURRENT_SIZE
10) CS,
USER_SPECIFIED_SIZE USuk t h i
CURRENT_SIZE!=0; as
y from v$memory_dynamic_components
e
where
(M to u s
k i
COMP
a e n seCS ----------
syu---------- US
y M poo lic58720256
----------
n l e
shared 0
Sta
large pool 4194304 0
java pool 4194304 0
SGA Target 176160768 0
DEFAULT bu 100663296 0
Shared IO 8388608 8388608
PGA Target 117440512 0
7 rows selected.
SQL>
SQL> connect amm/amm
Connected.
SQL>
SQL> drop table tabsga purge;
drop table tabsga purge
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL>
SQL> create table tabsga(a number, b number) tablespace
tbssga;
Table created.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL>
SQL> begin
2 for i in 1..100000 loop
3 insert into tabsga values (i, i);
4 end loop;
5 end;
6 /
ble
SQL> commit;
fe r a
Commit complete.
ans
n - t r
SQL>
a no
SQL> alter table tabsga parallel 64;
a s
) h i d eฺ
Table altered. m
co nt Gu
i l ฺ
SQL>
g ma tude
SQL> create or replace procedure
k S
i@ is testpga( psize number ) as
2 begin u
sy se t h
3 declare a
(M to u
u k i
4 TYPE nAllotment_tabtyp
e
IS TABLE OF char(2048) INDEX BY
BINARY_INTEGER;
a e ns
sy cnAllotment_tabtyp;
y6Mbegin li
5 myarray
l e
n 7 for i in 1..psize loop
Sta 8 myarray(i) := to_char(i);
9 end loop;
10 end;
11 end;
12 /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;
COMP CS US
7 rows selected.
SQL>
SQL> connect / as sysdba
Connected.
SQL>
SQL>
5) Still connected as SYS in your SQL*Plus session, shut down and start your database
instance and connect as the AMM user:
ble
SQL> shutdown immediate;
fe r a
Database closed.
ans
Database dismounted.
n - t r
ORACLE instance shut down.
SQL> a no
a s
SQL> startup quiet;
) h i d eฺ
ORACLE instance started. m
co nt Gu
Database mounted.
i l ฺ
Database opened.
g ma tude
SQL>
u k i@ is S
sy se th
SQL> connect amm/amm
Connected.
SQL>
a
(M to u
k i
6) Still connected
a se user in your SQL*Plus session, determine the current
syu ascethenAMM
M for thelivarious memory buffers as well as the list of resized operations that
settings
y
l e
n were done since you started your instance. You can use the components.sql
Sta script for that purpose.
SQL> @$HOME/labs/components.sql
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;
COMP CS US
---------- ---------- ----------
shared poo 62914560 0
large pool 4194304 0
java pool 4194304 0
SGA Target 192937984 0
DEFAULT bu 104857600 0
Shared IO 8388608 8388608
PGA Target 100663296 0
7 rows selected.
i (M to u
22 rows selected.
k
SQL> as
yu ense
y M lic
l e
n7) Remain connected as the AMM user in your SQL*Plus session and execute the
Sta following query. Immediately after that, determine the component sizes and resized
operations. You can use query1.sql script for that purpose. What do you observe?
select /*+ PARALLEL(s 24) */ count(*) from (select /*+
parallel(s 24) */ * from tabsga s group by a);
a) Execute the $HOME/labs/query1.sql script. You can see that the large pool
has a much bigger size while the buffer cache is smaller. This memory transfer
was automatically done by the system.
SQL> @$HOME/labs/query1.sql
SQL> select /*+ PARALLEL(s 24) */ count(*)
from (select /*+ parallel(s 24) */ * from tabsga s group by
a);
COUNT(*)
----------
100000
SQL>
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;
COMP CS US
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
7 rows selected.
sy0 STATIC
e t h IMMEDIATE COMPLETE
ASM Buffer
( a us
M toSTATIC COMPLETE
u k i
PGA Target 100663296
e
COMPLETE
sy ce4194304
shared poo
large apool ns STATIC
54525952 STATIC COMPLETE
y M l i COMPLETE
n l e
java pool 4194304 STATIC COMPLETE
Sta
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
RECYCLE bu 0 STATIC COMPLETE
DEFAULT 2K 0 STATIC COMPLETE
DEFAULT 4K 0 STATIC COMPLETE
DEFAULT 8K 0 STATIC COMPLETE
DEFAULT 16 0 STATIC COMPLETE
DEFAULT 32 0 STATIC COMPLETE
DEFAULT bu 100663296 SHRINK IMMEDIATE COMPLETE
large pool 8388608 GROW IMMEDIATE COMPLETE
DEFAULT bu 88080384 SHRINK IMMEDIATE COMPLETE
large pool 16777216 GROW IMMEDIATE COMPLETE
DEFAULT bu 92274688 SHRINK IMMEDIATE COMPLETE
large pool 12582912 GROW IMMEDIATE COMPLETE
DEFAULT bu 96468992 SHRINK IMMEDIATE COMPLETE
large pool 20971520 GROW IMMEDIATE COMPLETE
a syu cense
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
yM li
large pool 83886080 GROW IMMEDIATE COMPLETE
nle64
Sta
rows selected.
SQL>
8) Redo the same thing as in the previous step, but this time use the following query.
You can use query2.sql script for that purpose. What do you observe?
a) The same trend continues.
SQL> @$HOME/labs/query2.sql
SQL> select /*+ PARALLEL(s 26) */ count(*)
2 from (select /*+ parallel(s 26) */ * from tabsga s group
by a);
COUNT(*)
----------
100000
SQL>
COMP CS US
---------- ---------- ----------
shared poo 62914560 0
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
7 rows selected.
u k i@ is S
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
ASM Buffer
a sy se th
0 STATIC
PGA Target 100663296 STATIC
COMPLETE
COMPLETE
DEFAULT 32
k i (M to u0 STATIC COMPLETE
a syu cense
DEFAULT 16 0 STATIC COMPLETE
yM li
shared poo 54525952 STATIC COMPLETE
Sta
java pool 4194304 STATIC COMPLETE
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
RECYCLE bu 0 STATIC COMPLETE
DEFAULT 2K 0 STATIC COMPLETE
DEFAULT 4K 0 STATIC COMPLETE
DEFAULT 8K 0 STATIC COMPLETE
large pool 8388608 GROW IMMEDIATE COMPLETE
DEFAULT bu 100663296 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 92274688 SHRINK IMMEDIATE COMPLETE
large pool 12582912 GROW IMMEDIATE COMPLETE
large pool 16777216 GROW IMMEDIATE COMPLETE
DEFAULT bu 88080384 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 96468992 SHRINK IMMEDIATE COMPLETE
large pool 20971520 GROW IMMEDIATE COMPLETE
DEFAULT bu 83886080 SHRINK IMMEDIATE COMPLETE
a syu cense
large pool 83886080 GROW IMMEDIATE COMPLETE
yM li
large pool 83886080 GROW IMMEDIATE COMPLETE
Sta
DEFAULT bu 20971520 SHRINK IMMEDIATE COMPLETE
large pool 88080384 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
large pool 92274688 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
large pool 92274688 GROW IMMEDIATE COMPLETE
DEFAULT bu 12582912 SHRINK IMMEDIATE COMPLETE
large pool 96468992 GROW IMMEDIATE COMPLETE
DEFAULT bu 8388608 SHRINK IMMEDIATE COMPLETE
large pool 100663296 GROW IMMEDIATE COMPLETE
76 rows selected.
SQL>
9) Still connected as the AMM user from your SQL*Plus session, execute the following
command and, immediately afterward, determine the memory component sizes and
the list of resize operations. You can use query3.sql for that purpose. What do
you observe?
a) You can now see that SGA is automatically shrunk while PGA is automatically
raised. This is because query 3 needs a lot of untunable PGA memory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SQL> @$HOME/labs/query3.sql
SQL> exec testpga(700000);
SQL>
SQL> -- Same values as previously observed
SQL> select substr(COMPONENT, 0, 10) COMP, CURRENT_SIZE CS,
USER_SPECIFIED_SIZE US from v$memory_dynamic_components where
CURRENT_SIZE!=0;
ble
COMP CS US fe r a
---------- ---------- ----------
ans
shared poo 79691776 0
n - t r
large pool 4194304 0
a no
java pool 4194304 0
a s
SGA Target 113246208 0
) h i d eฺ
DEFAULT bu 8388608 0 m
co nt Gu
Shared IO 8388608 i
8388608 l ฺ
PGA Target 180355072
g ma tude
0
u k i@ is S
sy se th
7 rows selected.
a
(M to u
u k i
SQL> select substr(COMPONENT,
e
0, 10), FINAL_SIZE, OPER_TYPE,
a sy cens
OPER_MODE,
START_TIME;
status from v$memory_resize_ops order by
y M li
l e
n SUBSTR(COM FINAL_SIZE OPER_TYPE
Sta
OPER_MODE STATUS
---------- ---------- ------------- --------- ---------
DEFAULT bu 113246208 STATIC IMMEDIATE COMPLETE
large pool 4194304 GROW IMMEDIATE COMPLETE
shared poo 62914560 GROW IMMEDIATE COMPLETE
DEFAULT bu 104857600 SHRINK IMMEDIATE COMPLETE
shared poo 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 109051904 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 113246208 INITIALIZING IMMEDIATE COMPLETE
ASM Buffer 0 STATIC COMPLETE
PGA Target 100663296 STATIC COMPLETE
shared poo 54525952 STATIC COMPLETE
large pool 4194304 STATIC COMPLETE
java pool 4194304 STATIC COMPLETE
streams po 0 STATIC COMPLETE
SGA Target 192937984 STATIC COMPLETE
DEFAULT bu 113246208 STATIC COMPLETE
KEEP buffe 0 STATIC COMPLETE
a syu cense
large pool 46137344 GROW IMMEDIATE COMPLETE
yM li
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
Sta
DEFAULT bu 58720256 SHRINK IMMEDIATE COMPLETE
large pool 50331648 GROW IMMEDIATE COMPLETE
DEFAULT bu 54525952 SHRINK IMMEDIATE COMPLETE
large pool 54525952 GROW IMMEDIATE COMPLETE
DEFAULT bu 50331648 SHRINK IMMEDIATE COMPLETE
large pool 58720256 GROW IMMEDIATE COMPLETE
DEFAULT bu 46137344 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 33554432 SHRINK IMMEDIATE COMPLETE
large pool 75497472 GROW IMMEDIATE COMPLETE
large pool 79691776 GROW IMMEDIATE COMPLETE
DEFAULT bu 29360128 SHRINK IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
DEFAULT bu 25165824 SHRINK IMMEDIATE COMPLETE
large pool 83886080 GROW IMMEDIATE COMPLETE
DEFAULT bu 20971520 SHRINK IMMEDIATE COMPLETE
large pool 88080384 GROW IMMEDIATE COMPLETE
DEFAULT bu 16777216 SHRINK IMMEDIATE COMPLETE
a syu cense
SGA Target 146800640 SHRINK DEFERRED COMPLETE
yM li
DEFAULT bu 54525952 SHRINK DEFERRED COMPLETE
Sta
SGA Target 142606336 SHRINK DEFERRED COMPLETE
DEFAULT bu 50331648 SHRINK DEFERRED COMPLETE
PGA Target 150994944 GROW DEFERRED COMPLETE
SGA Target 138412032 SHRINK DEFERRED COMPLETE
DEFAULT bu 46137344 SHRINK DEFERRED COMPLETE
PGA Target 155189248 GROW DEFERRED COMPLETE
SGA Target 134217728 SHRINK DEFERRED COMPLETE
DEFAULT bu 41943040 SHRINK DEFERRED COMPLETE
PGA Target 159383552 GROW DEFERRED COMPLETE
SGA Target 130023424 SHRINK DEFERRED COMPLETE
DEFAULT bu 37748736 SHRINK DEFERRED COMPLETE
PGA Target 163577856 GROW DEFERRED COMPLETE
SGA Target 125829120 SHRINK DEFERRED COMPLETE
DEFAULT bu 33554432 SHRINK DEFERRED COMPLETE
PGA Target 167772160 GROW DEFERRED COMPLETE
DEFAULT bu 29360128 SHRINK DEFERRED COMPLETE
SGA Target 121634816 SHRINK DEFERRED COMPLETE
PGA Target 171966464 GROW DEFERRED COMPLETE
SQL>
SQL>
SQL> exit
ble
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.5.0 - Beta fe r a
With the Partitioning, OLAP and Data Mining options
ans
$
n - t r
a no
10) From a terminal window, restart Enterprise Manager Database Control and look at the
a s
) h i d eฺ
memory variations that happened during this lab. What do you observe?
c m
o t Gu
$ emctl start dbconsole
i l ฺ n
11.1.0.4.0 g ma tudeControl
Oracle Enterprise Manager 11g Database Release
ble
fe r a
t r a ns
n
11) To clean up your environment, shut down your database instance, restore
o - original
the
a n
SPFILE, and restart your database instance. Running the amm_cleanup.sh script
accomplishes the same task. s
ha ideฺ
)
m Gu
$ sqlplus sys/oracle as sysdba
ฺ c o t
SQL> shutdown immediate;
a il e n
SQL> exit m tud
g$ORACLE_HOME/dbs/spfileorcl.ora
$ cp /tmp/spfileorcl_bu.ora i @
ksysdba i s S
$ sqlplus sys/oracleyas
s u t h
a u s e
(M
SQL> startup;
SQL> drop user
k i t o
amm cascade;
SQL> drop
a s y e n se tbssga including contents and datafiles;
utablespace
y Mexit lic
SQL> drop tablespace mytemp including contents and datafiles;
leSQL>
Stan
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:
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$ cd /home/oracle/labs
$ ./add_service.sh
edrsr3p1
$
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Production
With the Partitioning, OLAP and Data Mining options
SQL> EXEC -
DBMS_SERVICE.CREATE_SERVICE('SERV1','SERV1.us.oracle.com')
SQL> exit;
Disconnected from Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Production
ble
With the Partitioning, OLAP and Data Mining options
fe r a
ans
2) After you have created your services, try connecting to your database by using your
service name. What happens? Why?
n - t r
a no
Answer: You cannot connect using your service because although it is defined, it is
a s
) i d eฺ
not started on your instance. You can verify this by looking at the SERVICE_NAME
h
m
o t Gu
initialization parameter and by looking at the services known to the listener.
c
i l ฺ
m tuden
[oracle@edrsr3p1 labss]$ lsnrctla services
g
LSNRCTL for Linux: Versionk i S - Production on 16-MAY-
i@11.1.0.6.0
s
2008 02:38:51 u
sy se t h
a
M t2007,
(1991, u Oracle. All rights reserved.
k i o
yu ense
Copyright (c)
a s
yM
Connecting ic
lto
n l e
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
Sta Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for
this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "orcl.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
Service "orclXDB.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
(ADDRESS=(PROTOCOL=tcp)(HOST=edrsr3p1.us.oracle.com)(PORT=2796
9))
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 -
Production
With the Partitioning, OLAP and Data Mining options
descriptor
3) How would you make sure that you can connect using your service? Do it and
connect to your instance using your service.
Answer: You must start your service on your instance.
ble
$ sqlplus / as sysdba
fe r a
s
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug n8-t
ran
13:01:54 2007
a no
a s
Copyright (c) 1982, 2007, Oracle. All rights ) h i d eฺ
reserved.
m
co nt Gu
i l ฺ
Connected to: g ma tude
k i@ iEdition
Oracle Database 11g Enterprise
s S Release 11.1.0.6.0 -
Production u
sy Oracle h
t Label Security, OLAP, Data
a s e
(M to u
With the Partitioning,
Mining
k i
s u cense Testing options
and Real yApplication
a
yM li
l e
n SQL> show parameter service
Sta
NAME TYPE VALUE
----------------------------- ----------- ----------------
service_names string orcl.us.oracle.com
Connecting to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:50 refused:0 state:ready
LOCAL SERVER
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this
service...
ble
Handler(s):
"DEDICATED" established:50 refused:0 state:ready fe r a
LOCAL SERVER ans
Service "SERV1.us.oracle.com" has 1 instance(s). n - t r
no
Instance "orcl", status READY, has 1 handler(s) for this
a
service...
a s
Handler(s): ) h i d eฺ
m
co nt Gu
"DEDICATED" established:0 refused:0 state:ready
i l ฺ
ma tude
LOCAL SERVER
g
Service "orcl.us.oracle.com" has 1 instance(s).
u k i@ is S
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):a sy se th
k i (M to u
"DEDICATED" established:0 refused:0 state:ready
a syu cense
LOCAL SERVER
yM li
Service "orclXDB.us.oracle.com" has 1 instance(s).
Sta
service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022
state:ready
DISPATCHER <machine: edsor6p2.us.oracle.com, pid:
17352>
(ADDRESS=(PROTOCOL=tcp)(HOST=edsor6p2.us.oracle.com)(PORT=3614
0))
Service "orcl_XPT.us.oracle.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully
4) Execute the serv1_load.sh script as SYSDBA. This script creates a new user and
then connects to your instance using this user and the SERV1 service. The script then
executes the following query:
SELECT COUNT(*) FROM DBA_OBJECTS,DBA_OBJECTS,DBA_OBJECTS
Note: Do not wait for the script to complete before proceeding to the next step.
$ cd /home/oracle/labs
$ ./serv1_load.sh
ble
fe r a
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Aug 8
an s
13:16:24 2007
n - t r
Copyright (c) 1982, 2007, Oracle. a no
All rights reserved.
a s
) h i d eฺ
c m
o t Gu
Connected to:
i l ฺ
ma tuden
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production g S Security, OLAP, Data
With the Partitioning, k
u i@ Label
Oracle
i s
Mining syTesting
e t h
(
and Real Application a s
M to u options
i
k SQL>
s
SQL> SQL>
a y uSQL>
e n se SQL> drop user jfv cascade
M at line*lic
y
nle
ERROR 1:
Sta ORA-01918: user 'JFV' does not exist
SQL> SQL> 2 3
User created.
SQL> SQL>
Grant succeeded.
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.
b) Click the Top Consumers link in the Related Links section. Refresh the Top
Consumers Overview page several times. The names and number of services
listed in the Top Services Graph depends on the number and type of connections
to the database.
c) You can also see the detailed statistics by clicking the Top Services tab…
d) … and then by clicking the SERV1 link…
e) … and then by clicking the Statistics tab.
f) Make sure that you stop your running workload by pressing Ctrl + C in your
terminal window if necessary. ble
fe r a
SQL> SQL> select count(*) from
ans
dba_objects,dba_objects,dba_objects
n - t r
ERROR at line 1:
*
a no
a s
ORA-01013: user requested cancel of current operation
) h i d eฺ
m
co nt Gu
i
a del ฺ
g m tu
k i @
SQL> SQL> Disconnected from Oracle Database
i s S 11g Enterprise
M athresholds
6) Set alert l i c efor your SERV1 service by using Database Control. Specify the
y
nlevalues defined at the beginning of this practice.
Sta a) On the Database Control home page, click the Metric and Policy Settings link in
the Related Links section.
b) On the Metric and Policy Settings page, select View All Metrics. Find the metric
called Service Response Time (per user call) (microseconds).
c) Click the multiple-edit icon in the right column of the row.
d) On the Edit Advanced Settings: Service Response Time (per user call)
(microseconds) page, click Add. Enter SERV1 in the Service Name field,
40000000 in the Warning Threshold field, and 100000000 in the Critical
Threshold field. Click Continue.
e) Back on the Metric and Policy Settings page, click OK.
f) On the Confirmation page, click OK.
g) Back on the home page, click the All Metrics link in the Related Links section.
b) On the Service Response Time (per user call) (microseconds): Service Name
SERV1 page, monitor the Metric Value graph. The graph should show the Service
Response Time in the warning region.
8) Use Database Control to remove the thresholds that you specified during this practice.
a) On the Database Control home page, click the Metric and Policy Settings link in
the Related Links section.
b) On the Metrics and Policy Settings page, select View All Metrics. Find the metric
called “Service Response Time (per user call) (microseconds)”.
c) Click the multiple-edit icon button in the right column of the row.
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
1) Open a command-line window. Start a SQL*Plus session, connect as sys and disable
Flashback Database, and then exit SQL*Plus. Change to the $HOME/labs directory
under workshop directory. Then run the setup_perflab.sh script:
$ sqlplus sys/oracle as sysdba
SQL> ALTER DATABASE FLASHBACK OFF;
exit
$ cd $HOME/labs
$ ./setup_perflab.sh
Note: This script takes a few minutes to run. The script starts a number of user e
sessions to use up resources. If you run this script but for any reason do not complete r a bl
the workshop immediately, run the cleanup script cleanup_perflab.sh as s fe
instructed at the end of this workshop ($./cleanup_perflab.sh) to stop the- t r an
no n
sessions. When you complete the entire workshop as instructed, your machine returns
a
to optimum performance. But Oracle still recommends that you run the cleanup script
s
h a
at the end so that the other labs and workshops are not affected.
) eฺ
m u i d
2) Run the start_perflab.sh script to startlthe
i ฺ coworkload.
t G Do not wait for this
script to finish before moving on to the following
g den
ma tusteps.
$ ./start_perflab.sh
u k i@ is S
a s y e th
3) Open a browser andM
i ( t o us URL:
enter the following
y uk nse
https://<hostname>:1158/em
s
M
Specify
asys aslithe
c eusername and oracle as the password. Select SYSDBA from
y
nlethe Connect As drop-down list, and then click Login.
Sta 4) Click the Performance tab.
5) In the Performance window, view the Average Active Sessions graph. A chart
representing the current workload of your database is shown. (It may take a minute
for the chart to be populated with data.) To the side of the graph is the legend. Each
legend entry is coded to a different color. Wait at this step for about two minutes until
the active sessions graph starts to flatten out.
6) Below the legend and to the right of the Active Sessions graph, click Top Activity.
7) In the Top SQL area on the Top Activity page, there is one SQL statement causing
the majority of the database wait. Drill down to find the root cause. Click the SQL ID
for that SQL statement.
8) On the SQL Details page, the activity graph is displayed. Click the Statistics tab to
view the statistics. The statistical analysis chart for this SQL statement is displayed.
In the Execution Statistics area the statistic of interest for this statement is Buffer
Gets. Note the value of Buffer Gets per execution and CPU Time per execution.
______________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
______________________
9) Click the Plan tab and scroll down to determine the reason for the high value of
Buffer Gets. Look for Table Access Full in the Explain Plan Operations column.
10) From the displayed charts, it can be determined that CPU resource usage is the
primary resource bottleneck. Buffer Gets is the primary source of the CPU usage.
Sessions wait on the CPU resources. You are now ready to tune the SQL statement by
using the SQL Tuning Advisor.
ble
fe r a
t r a ns
n
15) On the Recommendations page, select the Index recommendation thatocreates -
an
indexes, and then click the Implement button to implement the tuning
s
recommendation.
) ha ideฺ
16) On the Implement Recommendation page, clickcOK. o m Gu
a ฺ t
il the Create
n
17) A confirmation message appears indicating
g that e
m tud indexes job was
@ istabSand then the Performance tab.
successfully submitted. Click the iDatabase
k
u
sy for
Reviewing SQL Execution Details th Statement
a SQL
a s e
i (M totheutuning
Now that you havekimplemented suggestion, review the SQL statement and its
y u
execution details. Perform s e
the following steps:
M as licen
l e y down to the Average Active sessions chart. Wait for about a minute and then
18) Scroll
Stan observe how the CPU Usage and Average Load behave. There may be an increase in
the graph corresponding the index creation.
19) The graph of CPU usage in the Average Active Session Graph may or may not
decrease depending on the machine type you use. Click Top Activity again.
20) Select the SQL statement with the highest activity. Click the SQL ID. This is the
same statement as before. There may be multiple entries for this statement but both
take you to the same detail page.
21) On the SQL Details page, click the Plan tab. Then check each Plan Hash Value in
turn until you find the plan that uses the index with name starting with IDX$$%.
Leave the plan hash value set to that value and click the Statistics tab to view the
statistics for that plan.
Note: While checking, some plan hash values may show that the plan is not available.
These are plans that have aged out or not captured by the ASH sampling.
22) Observe the Buffer Gets per execution and CPU Time per execution for this plan.
______________
______________
23) Reducing Buffer Gets is good, but this plan is not good enough. The CPU time has
not changed significantly. Click the Plan tab.
24) In the explain plan there is still a Table Access Full shown. Only one of the indexes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
35) Navigate to the SQL ID Detail page, click the Plan tab, and set each plan hash value ble
in turn until you find the one that does not have a Table Access Full operation and fe r a
does use both indexes, SALES_CUST_BIX and IDX$$%. If the plan does not ans
n - t r
appear in the list, wait for a few moments, refresh the page, and then check for a new
plan. a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
36) Leaving the plan hash value set to the one found in the previous step, click the
Statistics tab. Note that the statistics graph for this plan statistics may appear blank
because the values are so small. View the statistics. Note that the CPU Time per
execution and Buffer Gets per execution have decreased significantly.
37) To clean up your environment, execute the following command from your command-
line window. This script can take up to 15 minutes to finish.
$ cd $HOME/labs
$ ./cleanup_perflab.sh
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
AND as
yu enseIS NULL;
WHERE metrics_name='Tablespace Space Usage'
yM lic
object_name
l e
n WARNING_VALUE
Sta --------------------------------------------------------------------
CRITICAL_VALUE
--------------------------------------------------------------------
85
97
ble
fe r a
ans
e. Click Continue and then click OK to create the tablespace. n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
TablespaceSSpace Usage thresholds of the
u
TBSALERT tablespace. Setyits ki@
4. In Enterprise Manager, change the
warningt h is to 55 percent and its critical level to 70
level
percent.
s
a use
( M to
y u ki spage,
e
a. On the
a s cen
Tablespaces select TBSALERT, click Edit, and then click
M li
y Thresholds.
n l e
Sta b. Select Specify Thresholds, and enter 55 as Warning (%) and 70 as Critical (%)
under the Space Used section.
55
s y uk n70se
--------------- ---------------
M a lice
y
n6. leQuery the reason and resolution columns from DBA_ALERT_HISTORY for
Sta the TBSALERT tablespace.
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
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;
END LOOP;
u k i@ is S
END;
a sy se th
(M to u
/
k i
insert into employees1 select * from employees1;
a syu cense
insert into employees2 select * from employees2;
insert into employees3 select * from employees3;
yM
commit; li
t a nle
S 8. Check the fullness level of the TBSALERT tablespace by using Database Control or
SQL*Plus. The current level should be around 60%. Wait a few minutes and check
that the warning level is reached for the TBSALERT tablespace.
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.
c. In SQL*Plus, enter:
SQL> select sum(bytes) *100 /125829120
from dba_extents
where tablespace_name='TBSALERT';
SUM(BYTES)*100/125829120
------------------------
60
d. Enter the following query. Your results should be similar to the following: ble
fe r a
SQL> select reason
ans
from dba_outstanding_alerts
n - t r
where object_name='TBSALERT';
a no
a s
REASON
) h i d eฺ
m
co nt Gu
--------------------------------------------------------------
Tablespace [TBSALERT] is [60 percent] ฺfull
i
a del
9. Execute the inserts below to add more g m
data to S tu Wait a few moments and
k i @ i s
TBSALERT.
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:
SUM(BYTES)*100/125829120
------------------------
75
REASON MESSAGE_LEVEL
-------------------------------------------- -------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
d. Navigate to the Database home page. You should see the new alert in the Space
Summary region. It will take several minutes for the change in status to take
effect. Note the red flag instead of the yellow one.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l
a rowsฺ
10. Execute the following delete statements m to delete efrom tables in TBSALERT.
These statements will take severali@ g
minutes to S tud
complete.
s y uk this
SQL> delete employees1;
SQL> commit; (Ma u se
i
SQL> deletekemployees2;
u e to
y
as employees3;
SQL> commit;
en s
M
SQL> deletelic
l y commit;
eSQL>
ta n
S 11. Now, run the Segment Advisor for the TBSALERT tablespace by using Database
Control. Make sure that you run the Advisor in Comprehensive mode without time
limitation. Accept and implement its recommendations. After the recommendations
have been implemented, check whether the fullness level of TBSALERT is below
55%.
a. From the Database home page, select Advisor Central under Related Links and
then click Segment Advisor.
b. On the Scope page, select Tablespaces and click Next. On the Objects page, click
Add, select TBSALERT, and click OK.
c. Click Next when returned to the Objects page. When returned to the Objects page,
click the Show Advanced Options link. Then click the Limited option button and
enter 30 for Time Limit (mins) and click Next.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
syuandcclick
d. On the Schedule e make sure Immediately is selected. Select the proper
page,
nsNext.
a
timezone
li e
l e yM
n e. On the Segment Advisor: Review page, click the Submit button.
Sta
f. This takes you back to the Advisor Central page, where you can see the progress
of your task. Click the Refresh button until your job is completed.
g. Select your Segment Advisor task and click the View Result button.
h. On the Segment Advisor Task page, click the Recommendation Details button.
ble
j. On the Shrink Segment: Options page, make sure that you click the “Compact
fe r a
Segments and Release Space” option button. Click Implement.
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
sySchedule
k. On the Shrink Segment:
a e th click the Submit button.
page,
i ( M to us
s y uk nse
M a lice
y
nle
Sta
l. On the Scheduler Jobs page, click Refresh until you see your job in the Running
table. Continue to click Refresh until you no longer see your job in the Running
table. It should take approximately two minutes to complete.
ble
fe r a
an s
n - t r
a no
a s
h
) outstanding
i d eฺ
c o m
12. Wait a few minutes and check that there are no longer any
G u alerts for the
TBSALERT tablespace. ฺ
ail den t
m tu see Problem Tablespaces: 0.
g YouSshould
i
a. Navigate to the Database home @ page.
s y uk this
( M a use
y u ki se to
M as licen
y
nle
Sta
13. Retrieve the history of the TBSALERT Tablespace Space Usage metric for the last 24
hours.
a. On the Database home page, select All Metrics in the Related Links region.
b. Expand the Tablespaces Full category, and click the Tablespace Space Used (%)
link.
c. Make sure that you select Real Time: Manual Refresh from the View Data drop-
down list. Then click the TBSALERT link.
14. Reset the databasewide default thresholds from the Tablespace Space Usage metric
for the TBSALERT tablespace.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
a. From the context of the Tablespace Space Used (%): Tablespace Name
TBSALERT page, click the Edit Tablespace link at the bottom of the page.
b. This opens the Edit Tablespace: TBSALERT page. Click the Thresholds tab.
c. Select the Use Database Default Thresholds option in the Space Used (%) section.
Click the Apply button.
15. Note: This is your mandatory cleanup step. Because you have finished with your test
case, execute the seg_advsr_cleanup.sh script from the labs directory to e
drop your TBSALERT tablespace. r a bl
s fe
$ ./seg_advsr_cleanup.sh
- t r an
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 9 no n
08:44:31 2007 s a
) h a eฺ
m i d
Copyright (c) 1982, 2007, Oracle. All
i l ฺ co nt Gu
rights reserved.
SQL> Connected.
g ma tude
SQL>
u k i@ is S
System altered.
a sy se th
M to u
SQL> Databasei (closed.
k
u nse
Database ydismounted.
ORACLEas c e shut down.
y M i
instance
l
n l e
SQL> ORACLE instance started.
Tablespace dropped.
You received complaints that certain batch jobs are using too many system resources and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
that a specific user is known to start data warehouse processes during regular business
hours. You decide to use the Database Resource Manager for better system-resource
utilization and control.
Your first effort to balance the situation includes creating an APPUSER consumer group
and assigning it to the default DEFAULT_PLAN resource plan. You then map a couple of
Oracle users and your major OS user to resource groups. Activate the resource plan and
test your assignments. Regularly click Show SQL to review all statements that are new to
you.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Log in as the SYS user (with oracle password, connect as SYSDBA) and perform the
necessary tasks through Enterprise Manager Database Control or through SQL*Plus. All
scripts for this practice are in the /home/oracle/labs directory.
Whenever you open a new terminal window, execute the oraenv script to set
environment variables for the orcl database.
1) Using Enterprise Manager Database Control, create a resource group called
APPUSER. At this point, do not add users to the group.
a) In Enterprise Manager, select Server > Consumer Groups (in the Resource
ble
Manager section).
fe r a
b) On the Consumer Groups page, click the Create button. ans
n - t r
no
c) Enter APPUSER as Consumer Group and click Show SQL.
a
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta d) Review the statements.
Question 1: What does the ROUND-ROBIN parameter value mean?
Possible Answer: ROUND-ROBIN indicates that CPU resources are fairly allocated to
the APPUSER consumer group, according to the active resource plan directives.
e) Click Return, and then click OK to create the consumer group.
f) A confirmation message appears and the new consumer group is displayed. After
confirming its creation, click the “Database Instance:orcl.us.oracle.com” link.
ble
fe r a
ans
n - t r
a
2) Add the APPUSER and LOW_GROUP consumer groups to the DEFAULT_PLAN no
a s
) i d eฺ
resource plan. Change the level 3 CPU resource allocation percentages: 60% for the
h
m
o t Gu
APPUSER consumer group and 40% for the LOW_GROUP consumer group.
c
i l ฺ
ma tuden
a) In Enterprise Manager, select Server > Plans.
g
k i s S
i@ DEFAULT_PLAN
b) On the Resource Plans page, select and click the Edit button.
c) Click Modify.
u
sy se t h
a
(M to u page, move APPUSER and LOW_GROUP to the
k
d) On the Select i Groups/Subplans
“Resource
a e se
syuAllocations.”
n
yM lic
n l e
Sta
e) Click OK.
f) Enter 60 for APPUSER Level 3 and 40 for LOW_GROUP Level 3.
g) Click Show SQL, review the statements, and then click Return.
ble
k) Confirm that “Oracle User” has a higher priority than “Client OS User.”
fe r a
l) Click Apply to assign the SCOTT user to the LOW_GROUP consumer group. ans
n - t r
a no
4) Configure Consumer Group Mappings so that the oracle a
h s user belongs
OS
ฺ to the
SYS_GROUP consumer group. ) id e
o m G u
ilฺc eGroup
a) In Enterprise Manager, select Server > Consumer
a n t Mappings.
b) Select Client OS User and click the
m Rule
g“Add t d Selected Type” button.
ufor
@
kiSelected S
isConsumer Group drop-down list, move
c) Select SYS_GROUP from s y uthe t h
oracle into the( M a Client
Selected u seOS User area, and click OK.
u ki se SQL, to review the statements, and click Return.
a y
d) (Optional)
s cenClick Show
M li to assign the oracle OS user to the SYS_GROUP consumer group.
e)y Click Apply
n l e
Sta
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
o t Gu
5) Assign the PM Oracle user to the following a ilฺc egroups:
consumer n APPUSER,
LOW_GROUP, and SYS_GROUP. m
g Stu d
i @
a) In Enterprise Manager, y
s uk Serverth>isUsers (in the Security section).
select
(
b) Select the PM user M a utheseEdit button.
and click
ki seGroups
uConsumer to
c) Clicks
a y
the
e n Privileges tab. If you see an error regarding the
M
y password licthe PM user, enter pm in both the password fields.
for
l e
n d) Click the Edit List button.
Sta e) Move the APPUSER, LOW_GROUP, and SYS_GROUP consumer groups to
Selected Consumer Groups and click OK.
ble
fe r a
an s
n - t r
a no
a s
g) Review the statements and click Return. ) h i d eฺ
m Gu
co ngroups.
h) Click Apply to assign the PM user to these i l ฺ
consumer t
g ma tude
u k i@ is S
6) Execute the unlock_accts.sh
a sy sscripte thto unlock the HR, SCOTT, OE, and PM
(Min the torcl
Oracle user accounts
i o u database. The script sets the passwords in
lowercase to u k
y matchethe e
susername.
a s n
a) As lic user in a terminal window, execute the oraenv script to set
Mthe oracle
y environment
n l e variables for the orcl database.
Sta $ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, OLAP, Data Mining and Real Application
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Testing options
SQL> SQL>
User altered.
SQL>
User altered.
SQL>
User altered.
ble
SQL>
User altered. fe r a
t r a ns
SQL> SQL> Disconnected from Oracle Database 11g Enterprise
o n -
Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and s Reala nApplication
Testing options
) ha ideฺ
[oracle@edt3r10p1 labs]$
c o m Gu
a ฺ
il altered.
n t not, resolve any problems
c) You should see that the four users have
gm Studbeen e If
that might have occurred. @
u i
kresource is
7) Activate the DEFAULT_PLAN s y t h
plan.
( Ma tselect u se
a) In Enterprise iManager,
u k e o Server > Plans.
b) On a y enPlans
sResource
the s page, select DEFAULT_PLAN, select Activate from the
M drop-down
y Actions lic list, and click Go.
n l e
Sta c) Click Yes to confirm your activation.
You should see a success message.
8) Test the consumer group mappings. Start two SQL*Plus sessions: the first with the
system/oracle@orcl connect string and the second with the
scott/scott@orcl connect string.
a) As the oracle user in a terminal window, execute the oraenv script to set
environment variables for the orcl database.
$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
$
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
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
FIRST>@query_rsc_groups.sql
SCHEMANAME RESOURCE_CONSUMER_GROUP
------------------------------ ------------------------------
SCOTT LOW_GROUP
DBSNMP OTHER_GROUPS
DBSNMP OTHER_GROUPS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
FIRST>
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>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
m) Question: When testing your OE Oracle user, you notice that OE is in the
OTHER_GROUPS consumer group. Why is that?
Possible Answer: The OE user is not explicitly assigned to another consumer
resource group.
y M
nleCopyright (c) 1982, 2007, Oracle. All rights reserved.
Sta
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
SQL> SQL>
User altered.
SQL>
User altered.
SQL>
User altered.
SQL>
User altered.
SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.
SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
1. While logged in to the database as the HR user in Database Control, create a simple
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
d. On the Create Job - General page, enter and confirm the following values:
Name: CREATE_LOG_TABLE_JOB
Schema: HR
Enabled: Yes
Description: Create the SESSION_HISTORY table
Logging Level: Log job runs only (RUNS)
Command Type: PL/SQL
PL/SQL Block:
BEGIN
execute immediate
('create table session_history(
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
c m
o t Gu
i l ฺ n
g ma tuthedefollowing
e. On the Schedule folder tab, enter and confirm values:
u k i@ is S
Timezone: Your_local_timezone
Repeating: Do noty Repeat th
a s se
M
Start: Immediately
( u
y u ki se to
f. Clicks
M a ShowliSQL
c enif you want to view the SQL statement defining your job.
y
nleg. Review the statements and click Return.
Sta h. Click Apply to create the job.
i. If the job does not appear on the Scheduler Jobs page, click the Refresh button
until it succeeds.
2. Create a program called LOG_SESS_COUNT_PRGM that logs the current number of
database sessions into a table. Use the following code:
DECLARE
sess_count NUMBER;
BEGIN
SELECT COUNT(*) INTO sess_count FROM V$SESSION;
INSERT INTO session_history VALUES (systimestamp,
sess_count);
COMMIT;
END;
Schema: HR
Enabled: Yes
Type: PLSQL_BLOCK
Source:
DECLARE
sess_count NUMBER;
BEGIN
SELECT COUNT(*) INTO sess_count FROM V$SESSION;
INSERT INTO session_history VALUES (systimestamp,
ble
sess_count);
fe r a
COMMIT;
an s
END;
n - t r
d. Click Show SQL.
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
ble
3. Create a schedule named SESS_UPDATE_SCHED owned by HR that executes every fe r a
n s
three seconds. Use SQL*Plus and the DBMS_SCHEDULER.CREATE_SCHEDULE
n - t ra
procedure to create the schedule.
a no
BEGIN
a s
DBMS_SCHEDULER.CREATE_SCHEDULE ( ) h i d eฺ
schedule_name => 'SESS_UPDATE_SCHED', m
co nt Gu
start_date => SYSTIMESTAMP, ailฺ
g m tude
repeat_interval => 'FREQ=SECONDLY;INTERVAL=3',
comments => 'Every three
k i S
i@ seconds');
s
END; u
sy se t h
/ a
(M to u
k i
u nManager
Return to Enterprise e Database Control and verify that the
a s y e s schedule was created.
M lic
SESS_UPDATE_SCHED
y
nleHint: You may have to refresh the page for the Schedule to appear.
Sta
a. In a terminal window, enter:
$ sqlplus hr/hr
ble
fe r a
an s
n - t r
a no
g. Review the statements and then click Return. a s
) h i d eฺ
h. Click OK to create the job. m
co nt Gu
i l ฺ
g ma tude
5. In your SQL*Plus session, check the HR.SESSION_HISTORY table for rows.
i @ S
a. Enter: s y uk this
se
Ma SESSION_HISTORY
u
SQL> SELECT *i (FROM to
u k s e
ORDER BY snap_time;
YourM asylooks
result lic e n
different but the second values should be three seconds apart:
y
nleSNAP_TIME
Sta --------------------------------------------------------------
-----
NUM_SESSIONS
------------
30-Jul-07 08.05.24.113274 AM
24
30-Jul-07 08.05.27.112987 AM
24
Question: If there are rows in the table, are the time stamps three seconds apart?
Answer: Yes, there are rows. Yes, the time stamps are three seconds apart.
f. Change the value in the Repeat drop-down list from By Seconds to By Minutes.
Your result looks different (but the minute values should be three minutes apart):
SNAP_TIME
------------------------------------------------------------------
---
NUM_SESSIONS
--------------
30-Jul-07 08.15.30.024307 PM
23
30-Jul-07 08.18.00.113159 PM
23
7. This is your mandatory cleanup task. Use Enterprise Manager to drop the
LOG_SESSIONS_JOB and CREATE_LOG_TABLE_JOB jobs, the
Note: Make sure that you do not delete the wrong schedule.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
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.
d. Click the Database Instance breadcrumb at the upper-left corner of the page to
return to the Server page. Then click Programs.
ble
f. With the LOG_SESS_COUNT_PRGM program selected, click the Delete button.
fe r a
Click Yes to confirm.
t r a ns
g. Click the Database Instance breadcrumb at the upper-left corner ofothen -page to
return to the Server page. Click Schedules.
s an
) h a eฺ
h. With the SESS_UPDATE_SCHED schedule selected,
o m clicku idDelete button.
the
Make sure that you do not delete the wrong c nt
ilฺschedule. G
a
m tude
i. Select “If there are dependenti@
g S not be dropped,” and then click Yes
objects, it will
u k h i s
to confirm.
a sy se t
j. i
In your SQL*Plus (Msession
t o u
as the HR user, delete the SESSION_HISTORY table,
k se Enter:
u thensession.
a syexit
and then
e
y M lic
n l e
SQL> DROP TABLE session_history PURGE;
BEGIN ble
fe r a
ans
-- This will produce an error the first
n - t r
n o
-- time it is run since PROG_1 does not exists a
) ha ideฺ
DBMS_SCHEDULER.DROP_PROGRAM (
c o m Gu
program_name il ฺ n t
=> '"SYSTEM"."PROG_1"');
a
gm Stud e
END; @
ki this
s y u
/
( M a u se
y u ki se to
BEGIN as en
y M l i c
DBMS_SCHEDULER.CREATE_PROGRAM(
l e
n program_name=>'"SYSTEM"."PROG_1"'
Sta ,program_action=>'DECLARE
time_now DATE;
BEGIN
END;'
, program_type=>'PLSQL_BLOCK'
, number_of_arguments=>0,
comments=>'Insert a timestamp into the test_log'
,enabled=>TRUE);
END;
/
$
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.5.0 -
Beta
With the Partitioning, OLAP, Data Mining and Real Application
Testing options
SQL> @cr_test_log.sql
SQL> create table system.test_log
(job_type VARCHAR2(10)
ble
,
fe r a
timemark VARCHAR2(10)
ans
,
act_time TIMESTAMP with TIME ZONE) n - t r
a no
/
a s
2 3 4 5 6 7 SQL> ) h i d eฺ
Table created. m
co nt Gu
i l ฺ
ma tude
PL/SQL procedure successfully completed.
g
SQL> @prog_1.sql
u k i@ is S
SQL> BEGIN
a sy se th
k i (M to u
2 DBMS_SCHEDULER.CREATE_PROGRAM(
3 program_name=>'"SYSTEM"."PROG_1"'
s yu ense
4 ,program_action=>'DECLARE
a
y lic DATE;
5M time_now
nle 7
6 BEGIN
$ cat $HOME/labs/my_lwt_job.sql
set echo on
BEGIN
-- the drop procedure will give and error the first time
-- this script is run
sys.DBMS_SCHEDULER.DROP_JOB('my_lwt_job');
END;
/
DECLARE
jobname VARCHAR2(30); ble
fe r a
BEGIN
an s
-- Create the Job
n - t r
jobname := 'my_lwt_job';
a no
a s
sys.dbms_scheduler.create_job(
) h i d eฺ
job_name => '"SYSTEM"."MY_LWT_JOB"', m
co nt Gu
i
program_name => '"SYSTEM"."PROG_1"',
a del ฺ
g m
job_class => '"DEFAULT_JOB_CLASS"',
tu
i @
job_style => 'LIGHTWEIGHT',
repeat_interval =>uk is S
s y t h
'FREQ=DAILY;INTERVAL=2',
enabled =>(M
a
comments => 'Lightweight
TRUE);o u
se job',
y u ki se t
END; as e n
/y M l i c
l
n $e
Sta b) Execute the my_lwt_job.sql script as the system user.
$ sqlplus system/oracle
SQL> @my_lwt_job.sql
SQL> BEGIN
2 -- the drop procedure will give and error the first
time
3 -- this script is run
4
5 sys.DBMS_SCHEDULER.DROP_JOB('my_lwt_job');
6 END;
7 /
BEGIN
*
ERROR at line 1:
ORA-27475: "SYSTEM.MY_LWT_JOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 182
SQL>
SQL> DECLARE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
2 jobname VARCHAR2(30);
3
4 BEGIN
5 -- Create the Job
6 jobname := 'my_lwt_job';
7
8 sys.dbms_scheduler.create_job(
9 job_name => '"SYSTEM"."MY_LWT_JOB"',
10 program_name => '"SYSTEM"."PROG_1"',
11 job_class => '"DEFAULT_JOB_CLASS"',
12 job_style => 'LIGHTWEIGHT',
ble
13
14
repeat_interval => 'FREQ=DAILY;INTERVAL=2',
comments => 'Lightweight job', fe r a
15 enabled => TRUE); ans
16 n - t r
17 END;
a no
18 /
a s
) h i d eฺ
PL/SQL procedure successfully completed. m
co nt Gu
i l ฺ
SQL>
g ma tude
u k i@ is S
a s y e th
3) Check the SchedulerM
i ( t o us USER_SCHEDULER_JOBS, _PROGRAMS,
metadata views
DBA_JOBS. uk
a s y ense
a) Select
y M JOB_NAME,
l ic JOB_STYLE, and PROGRAM_NAME from
nle USER_SCHEDULER_JOBS.
Sta SQL> SELECT job_name, job_style, program_name FROM
USER_SCHEDULER_JOBS;
JOB_NAME JOB_STYLE
------------------------------ -----------
PROGRAM_NAME
----------------------------------------------------------
MY_LWT_JOB LIGHTWEIGHT
PROG_1
4) Check the Enterprise Manager Scheduler Jobs page, find the MY_LWT_JOB, and
view the attributes.
a) Navigate to the Scheduler Jobs page. Then click the History tab.
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
le
5) Drop the job from the EM Scheduler Jobs page.
n
Sta a) Navigate to the Scheduler jobs page, select MY_LWT_JOB, and click Delete.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
In this practice, you use Enterprise Manager Database Control to define and monitor the
Scheduler and automate tasks. Click Show SQL regularly to review all statements that are
new to you.
Log in as the SYS user (with oracle password, connect as SYSDBA) or as HR user
(with HR password, connect as Normal), as indicated. Perform the necessary tasks either
through Enterprise Manager Database Control or through SQL*Plus. All scripts for this
practice are in the /home/oracle/labs directory.
1) Log in to Enterprise Manager Database Control as the SYS user and grant the
following roles to the HR user: e
r a bl
• CONNECT role
sfe
• RESOURCE role
- t r an
• DBA role
no n
a
Because you are going to use the HR user to administer jobs through Database
s
h a eฺ
Control, you need to make sure that HR is registered as a possible administrator.
)
m i d
a. In Enterprise Manager, select Server > Users.i l ฺ co nt Gu
g ma tude
k @user and
b. On the Users page, select the iHR
i s Sclick Edit.
y u
sclick t h
c. On the Edit UserM a
page, s
theeRoles tab. Then click the Edit List button on the
i
right side ofkthe(page. to u
a syu cense
M the Modify
d. On
y roles li Roles page, make sure that the DBA, CONNECT, and RESOURCE
n l e are selected. Click Apply.
Sta
f. Click the Administrators link. On the Administrators page, click the Create
button.
ble
fe r a
an s
n - t r
a no
a s
j. Click the Logout link at the upper-right corner of the ) h
page.
i d eฺ
m
casothe HR G uOn the Server tabbed
2) Log in to Enterprise Manager Database Control
i l ฺ tuser.
page, click the Jobs link in the Databasem
g
a dregion.
Scheduler
u en Are there any jobs?
k i @ i s St
a. Click the Login button to u
sy se th
log in as the HR user.
b. For the username
a u enter HR, accept Connect As Normal, and click
(Mand password,
k i t o
s cense
Login. yu
a
MEnterprise
c.y In li Manager, select Server > Jobs in the Database Scheduler region.
n l e
Sta Question: Are there any jobs?
3) Review the Programs page in Enterprise Manager. Are there any existing programs?
(Hint: Use the browser’s Back button).
ble
fe r a
an s
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
4) Review the Scheduler Schedules k i s S Manager. Are there any existing
@ in Enterprise
ipage
schedules? u
sy se t h
a
(M tselect u
k
a. In Enterprise i
u nseManager, o Server > Schedules.
s y
a Are lthere e any existing schedules?
M
Question:
y i c
nle
Sta Answer: There are two schedules, DAILY_PURGE_SCHEDULE and
BSLN_MAINTAIN_STATS_SCHED.
5) Review the Scheduler Windows page in Enterprise Manager. Are there any existing
windows? Which resource plan is associated with each window?
Answer: There are several windows. All are enabled except WEEKNIGHT_WINDOW
and WEEKEND_WINDOW.
Answer: DEFAULT_MAINTENANCE_PLAN.
c. Click OK.
ble
6) Review the Scheduler Job Classes page in Enterprise Manager. Are there any existing
fe r a
n s
job classes? If so, which resource consumer group is associated with each job class?
n - tra
a. In Enterprise Manager, select Server > Job Classes.
a no
a s
Question 1: Are there any existing job classes?
) h i d eฺ
m
co nt Gu
Answer: There are many job classes. i l ฺ
g ma tude
b. Click the DEFAULT_JOB_CLASS
k i@ link. i s S
u
syconsumer t h
a
Question 2: Which resource s e
M to u group is associated with the job class?
i (
y
Answer: None.
s uk nse
M a lice
y
nlec. Click OK, and then click the ORA$AT_JCURG_OS link.
Sta Question 3: Which resource consumer group is associated with the job class?
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Your company has bought another company that has a large user community speaking
French. In general, you are not supposed to change the database itself, but you are
supposed to use a lower granularity to accommodate their needs. So you decide to use
primarily session-specific settings for changing the language, changing the date and time
formats, and addressing a sorting issue. Use system/oracle@orcl as your database
login and /home/oracle/labs as your working directory.
1) Start SQL Developer binaries. Log in as SYS as SYSDBA.
a) Change to the sqldeveloper directory.
$ cd $ORACLE_HOME/sqldeveloper/sqldeveloper/bin
ble
fe r a
b) Start the sqldeveloper executable.
ans
$ ./sqldeveloper n - t r
n o
a
c) If asked whether you would like to migrate settings from asprevious release, click
No.
) ha ideฺ
c o
d) Right-click Connections and select New Connection.
m Enter
G uthe following
i l ฺ t
information for the connection:
g ma tuden
Connection Name: SYSTEM
u k i@ is S
Username:
a y
ssystem e th
Password:
i ( M oracle
t o us
s y uk nseCheck the checkbox
Save Password:
a lice default
Role:
M
y SID:
nle
orcl
Sta e) Click Save, and then click Connect. Enter any subsequent queries in the area at
the top of the window where you see “Enter SQL Statement:”.
2) Determine the database and the national character set.
SELECT * FROM NLS_DATABASE_PARAMETERS
WHERE parameter LIKE '%CHARACTER%';
3) Familiarize yourself with NLS settings and modify the current date format.
b. The year is not displayed using a four-digit year. Change your session to display a
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
c. Let your session speak French. Display the current system date and time.
ble
alter session set nls_language=FRENCH;
select sysdate from dual; fe r a
ans
n - t r
a no
a s
4) Import the WORDS table (which is in the words.dmp m
h
) Runuithe
file). deฺ
o
load_words.sh script to do this. a ilฺc ent G
@ gm Stud
ki this
$ cd $HOME/labs
$ ./load_words.sh
s y u
( M a u se
ki creates
Note that the script ato
table named WORDS that has four rows.
y u s e
as licendisplay the content of the WORDS table.
5) In sqldeveloper,
M
y
nleSELECT * FROM words;
Sta
6) Set NLS_SORT to BINARY for your session. Select the table contents and order the
results by the FR_WORD column. In what order are the numbers in the NUM column
displayed?
ALTER SESSION SET NLS_SORT=BINARY;
SELECT * FROM words
ORDER BY fr_word;
7) Set NLS_SORT to FRENCH. Select the table contents and order the results by the
FR_WORD column. In what order are the numbers in the NUM column displayed?
ALTER SESSION SET NLS_SORT=FRENCH;
SELECT * FROM words
ORDER BY fr_word;
ble
fe r a
an s
n - t r
a no
a s
8) Set NLS_SORT to FRENCH_M. Select the table contents
h
) and order
i d eฺ results by the
the
m
coin thenNUM u displayed?
Gcolumn
l
FR_WORD column. In what order are the numbers
i ฺ t
g ma tude
i@ is S
ALTER SESSION SET NLS_SORT=FRENCH_M;
SELECT * FROM wordsyuk th
a s e
i ( M to us
ORDER BY fr_word;
s y uk nse
M a lice
y
nle
Sta
9) Set NLS_SORT to BINARY. Now retrieve the table contents in the same order as the
last query, without using another ALTER SESSION command.
ALTER SESSION SET NLS_SORT=BINARY;
SELECT * FROM words
ORDER BY NLSSORT(fr_word,'NLS_SORT=FRENCH_M');
10) Drop the table and also remove it from the recycle bin.
DROP TABLE words PURGE;
11) Exit SQL Developer by selecting File > Exit on the menu. If you are prompted with a
Save Files alert window, click No.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Index
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
A
Active session pool 17-5, 17-17, 17-18, 17-19, 17-28
ADDM 15-20, 15-27, 17-26
Advanced Security Option 5-28
Alert 1-12, 1-13, 1-26, 2-28, 6-6, 6-39, 10-9, 10-32, 13-3, 13-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
13-6, 13-8, 13-11, 13-33, 13-34, 13-38, 15-9, 16-10, 16-11, 16-25, 16-41
Application Server 15-17
Archive 1-12, 1-21, 2-2, 2-10, 2-12, 2-15, 2-16, 2-17, 2-18,
2-23, 2-25, 2-26, 2-30, 2-34, 3-16, 5-22, 6-28, 6-29, 6-30, 6-31,
6-33, 6-34, 6-40, 6-41, 6-42, 7-7, 10-3, 11-3, 11-7, 11-29, 12-2,
12-12, 12-25, 12-26, 12-27, 12-28, 12-29, 12-30, 12-31, 12-32, 13-38, 15-9
archivelog 2-2, 2-11, 2-12, 2-13, 2-14, 2-30, 2-34, 2-35, 3-18,
ble
3-27, 4-3, 4-5, 4-12, 4-13, 5-4, 5-6, 5-15, 5-17, 6-22, 6-25,
fe r a
6-26, 7-5, 7-6, 7-14, 8-16, 12-11, 12-12, 12-20, 13-37
t r a ns
Archiver 1-11, 2-11, 2-12, 2-25 o n -
ARCn 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 2-11, 2-12, 14-13 s an
ASM 1-1, 1-2, 1-11, 1-20, 1-21, 1-22, 1-23, 1-24, 1-25, 1-26,) ha ideฺ
c o m Gu
a il
1-27, 1-28, 1-29, 1-30, 1-31, 1-32, 1-33, 1-34,ฺ 1-35,
n t 1-37,
1-36,
gm 1-45,
1-38, 1-39, 1-40, 1-41, 1-42, 1-43, 1-44,
e
d 1-47, 1-48,
u1-46,
@ S t
8-17, 10-29, 13-4, 16-36
y u ki this
a s se
+ASM 1-24, 1-25
( M u
o 1-25, 1-26, 1-27, 1-28, 1-29,
ASM Instance 1-20,y u ki 1-23,
1-22, s e t1-24,
M as1-38,lic1-39,
1-35, 1-37, en 1-48, 13-4
n l ey
ASM_DISKGROUPS 1-24, 1-25
t a
SASM_DISKSTRING 1-24
ASM_POWER_LIMIT 1-24, 1-34, 1-42
ASMM 14-21, 14-22, 14-23, 14-25, 14-28, 14-34, 14-36
ASSM 16-14
Audit 11-20, 12-25, 13-43
autobackup 3-27, 4-2, 4-3, 4-7, 4-8, 4-9, 4-15, 4-16, 5-6,
5-15, 5-20, 7-17, 7-18, 7-19, 7-22, 7-24, 7-25, 7-27, 7-28
Automatic PGA Memory Management 14-2, 14-32, 14-40
Automatic Segment Space Management 16-3, 16-4, 16-7
Automatic Shared Memory Management 1-8, 10-32, 14-21, 14-22, 14-23,
14-24, 14-28
A
Automatic Storage Management 1-2, 1-20, 1-21, 1-23, 1-47, 13-4,
16-36
Automatic Workload Repository 15-18, 15-20, 15-21, 16-3, 16-9, 16-15
Auxiliary database 8-6, 8-7, 8-11, 9-15, 9-17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
AWR 15-18, 15-20, 15-21, 15-23, 15-27, 15-28, 15-30, 16-3, 16-9, 16-15,
16-16
B
BACKGROUND_DUMP_DEST 13-4
Backup piece 3-18, 5-14, 10-8, 10-14, 10-20, 10-27, 10-29
Backup set 3-3, 4-3, 4-6, 4-10, 5-2, 5-3, 5-5, 5-6, 5-8,
5-9, 5-14, 5-15, 5-24, 5-39, 10-4, 10-7, 10-14, 10-15, 10-25, 10-27,
a ble
10-29
e r
BACKUP_TAPE_IO_SLAVES 10-16, 10-17, 10-18, 10-19, 10-32 a n sf
Block 1-14, 1-15, 1-16, 1-18, 1-19, 1-30, 1-37, 1-44, 2-6, 2-9, o n -tr
2-10, 3-24, 4-3, 4-6, 4-12, 5-4, 5-8, 5-9, 5-10, 5-11, 5-12, s an
5-13, 5-25, 5-26, 5-40, 6-23, 7-11, 7-14, 7-15, 7-25, ) ha 8-8,ideฺ
8-6,
c o m Gu
8-11, 10-10, 10-23, 10-26, 11-6, 12-8, 12-9,a ฺ t 13-32, 13-33,
il 13-28,en13-29,
gm S
13-35, 13-36, 13-37, 13-38, 13-39, 13-42,
@ t ud 14-4, 14-5, 14-6, 14-7,
13-45,
y
14-25, 14-36, 15-9, 16-7, 16-8,u ki17-6,th17-21,
is 18-4, 18-6, 18-8, 18-11,
s
a use
18-12, 18-15 ( M to
y u
Block change tracking
ki4-6, s5-11,
e 5-12, 5-13, 5-40
as e n
y M 13-32,
Block corruption lic 13-33, 13-36, 13-38, 13-45
l e
tanMedia Recovery 2-6, 13-36, 13-37, 13-38
SBlock
Buffer cache 1-8, 1-19, 12-9, 12-25, 14-4, 14-5, 14-6, 14-7, 14-8,
14-11, 14-12, 14-13, 14-19, 14-21, 14-25, 14-34, 14-36, 14-37, 15-14
C
chains 18-22, 18-23, 18-25, 18-26, 18-28, 18-29, 19-2, 19-16, 19-18
Change tracking file 5-11, 5-12, 5-13, 12-12
Channel 2-9, 2-10, 3-15, 3-24, 4-5, 4-12, 4-13, 5-3, 5-17,
5-24, 5-30, 5-31, 5-32, 7-11, 8-11, 8-12, 9-12, 9-17, 10-3, 10-5,
10-6, 10-9, 10-10, 10-11, 10-12, 10-14, 10-15, 10-16, 10-25, 10-26, 10-27,
10-28, 10-29, 10-31, 10-32
Checkpoint 1-11, 2-21, 6-8, 6-9, 6-34, 14-6, 14-7
CKPT 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22, 6-9
C
Cluster 1-15, 1-20, 1-21, 1-23, 1-31, 3-8, 13-4, 14-9, 15-12,
15-19, 16-5
COMPATIBLE 1-31, 1-38, 1-39, 1-41, 5-24, 5-26, 12-20, 15-21, 16-28,
16-30, 16-34, 16-37, 16-38
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
D
DB_CACHE_SIZE 14-6, 14-7, 14-8, 14-15, 14-26, 14-28
DB_CREATE_FILE_DEST 2-25, 5-12, 8-8
DB_CREATE_ONLINE_LOG_DEST_n 2-25
DB_FILE_NAME_CONVERT 8-7, 8-8, 9-17, 9-19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
DB_FLASHBACK_RETENTION_TARGET 12-10
DB_KEEP_CACHE_SIZE 14-6, 14-8, 14-15, 14-25, 14-27
DB_NAME 3-33, 3-35, 7-17, 8-6, 8-12
DB_nK_CACHE_SIZE 14-7, 14-15, 14-25
DB_RECOVERY_FILE_DEST 2-26, 2-28, 2-30, 4-13, 8-8, 12-12, 12-23
DB_RECOVERY_FILE_DEST_SIZE 2-26, 2-28, 2-30, 12-23
DB_RECYCLE_CACHE_SIZE 14-6, 14-8, 14-15, 14-25
ble
DB_UNIQUE_NAME 1-24
fe r a
DBA 1-26, 1-34, 1-45, 2-29, 3-34, 5-26, 6-26, 10-10, 11-9, 11-10,
t r a ns
11-11, 11-12, 11-13, 11-15, 11-16, 11-37, 12-14, 12-29, 13-3, 13-28,
o n - 13-32,
14-8, 15-19, 15-42, 16-4, 16-13, 16-23, 16-25, 17-17, 17-25,
n 18-11,
a 18-9,
s
ha ideฺ
18-14, 18-18, 18-29, 19-14, 19-16, 19-17, 20-4 )
m Gu
ฺ c o t
DBCA 1-23, 14-32
a il e n
DBV 13-36
@ gm Stud
DBVERIFY 6-35, 13-38
y u ki this
a s 1-19,s14-6,
e 14-7, 14-13
DBWn 1-4, 1-6, 1-9, 1-10,M
( 1-11,
i 10-19, u
to 10-31, 10-32
DBWR_IO_SLAVES y u k10-14, s e
DDL 11-16,M as 11-25,
11-22, l i c en11-28, 12-7, 12-26, 12-30, 14-13, 15-39, 15-43,
n l ey 16-26, 20-30
16-22,
ta
SDedicated server 1-9, 14-30
disk group 1-21, 1-22, 1-27, 1-29, 1-30, 1-31, 1-32, 1-33, 1-34,
1-35, 1-36, 1-37, 1-38, 1-39, 1-40, 1-41, 1-42, 1-44, 1-45, 1-46,
1-48
DML 6-23, 9-7, 11-4, 11-16, 11-28, 11-36, 12-7, 12-18, 12-25, 14-13,
15-26, 15-39, 15-43, 16-12, 16-13, 16-22, 16-26, 17-5, 20-29
Dynamic Performance Views 5-36, 14-33, 15-16
E
Encoded character set 20-5, 20-7
Enterprise Manager 1-8, 1-17, 1-28, 1-41, 2-13, 2-21, 2-27, 2-32,
3-8, 3-12, 3-13, 3-14, 3-17, 4-2, 4-6, 4-7, 4-13, 4-14, 4-15,
5-21, 5-33, 5-37, 7-4, 7-5, 8-15, 9-14, 11-5, 11-13, 11-21, 11-24,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
11-26, 11-28, 11-30, 11-31, 12-4, 12-5, 12-6, 12-11, 13-3, 13-5, 13-8,
13-9, 13-10, 13-11, 13-12, 13-28, 13-29, 14-18, 14-37, 15-7, 15-8, 15-15,
15-17, 15-18, 15-21, 15-28, 15-43, 15-44, 15-45, 16-6, 16-9, 16-33, 16-34,
16-35, 16-41, 17-7, 17-13, 17-18, 17-24, 18-3, 18-6, 18-7, 18-8, 18-17,
18-26, 18-28, 18-31, 19-6, 19-9
Enterprise Manager Database Control 2-32, 3-17, 17-7, 18-31, 19-6
Environment variable 3-9, 7-23, 13-4, 13-7, 20-16, 20-22, 20-30,
ble
20-31
fe r a
EVENT 2-24, 3-3, 5-34, 13-7, 15-12, 15-13, 15-16, 15-17, 15-18, 16-21,
t r a ns
16-25, 18-2, 18-3, 18-5, 18-8, 18-10, 18-16, 18-17, 18-18, 18-19,
o n -
18-20,
n
18-22, 18-23, 18-25, 18-26, 18-30, 19-3 sa
ha ideฺ
F )
m Gu
ฺ c o t
Factor 1-31, 1-45, 14-20 a il e n
Flash recovery area 2-2, 2-11, 2-19, 2-20,
@ gm2-24,S t
2-25,ud2-26,
2-27, 2-28, 2-29, 2-30, 2-31,y u ki this2-34, 2-35, 3-18, 4-4,
2-32, 2-33,
4-8, 5-6, 5-14, 5-20,(M
as us7-18,
5-29, 7-17,
e 12-8, 12-10, 12-12, 12-18,
u ki 12-23
e to
12-19, 12-20,
a y 12-22,
s cen s
Flashback
l e y buffer 12-9li
M
tan Database 2-11, 2-19, 2-25, 4-4, 11-3, 11-39, 12-2, 12-8,
SFlashback
12-9, 12-10, 12-11, 12-12, 12-13, 12-14, 12-15, 12-16, 12-17, 12-18, 12-19,
12-20, 12-21, 12-22, 12-23, 12-24, 12-31, 12-32, 13-37
Flashback Drop 11-3, 11-8, 11-12, 11-13
Flashback Logging 12-12, 12-19, 12-20, 12-21, 13-37
Flashback Query 9-9, 11-2, 11-17, 11-18, 11-19, 11-20, 11-38, 11-39,
12-30
Flashback Table 11-8, 11-11, 12-2, 12-3, 12-4, 12-6, 12-7, 12-31
Flashback Transaction Query 9-9, 11-2, 11-17, 11-20, 11-23, 11-24,
11-25, 11-38, 12-3, 12-4, 12-30
Flashback Versions Query 12-3, 12-4
G
Globalization support 20-2, 20-3, 20-8, 20-21, 20-26, 20-28, 20-30,
20-31, 20-33, 20-34, 20-35, 20-36
Growth trend report 16-3
I
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Image copy 3-3, 4-3, 4-10, 5-4, 5-5, 5-6, 5-9, 5-10, 5-14,
6-27, 7-7, 7-10, 9-17, 10-13
Incarnation 9-9
Index 1-15, 1-21, 1-34, 6-5, 6-7, 6-11, 6-12, 6-13, 11-13, 11-16,
13-28, 13-35, 13-38, 14-9, 15-9, 15-19, 15-26, 15-32, 15-35, 16-5, 16-13,
16-14, 16-20, 16-26, 18-3, 20-24, 20-26
Index-organized tables 16-14, 16-20
a ble
Initialization parameters 1-8, 1-24, 2-15, 2-25, 2-26, 8-6,
fe r
8-7, 8-8, 9-12, 9-17, 10-18, 11-6, 14-15, 14-32, 15-10, 15-11, 20-15, rans
20-16, 20-17, 20-18 o n -t
initorcl.ora 7-24 s an
INSTANCE_TYPE 1-24, 1-25, 1-39 ) ha ideฺ
c o m Gu
iot 16-13, 16-14, 16-20 ail ฺ nt
g m tude
J
u k i@ is S
y 14-21,
Java pool 1-7, 1-8, 14-4, 14-5,s14-12,
a e th 14-25
JAVA_POOL_SIZE 14-12, i ( M14-15,
t o us 14-28
14-26,
k se
job 1-11, 2-9, a syu5-21,
2-10,
c en5-24, 5-25, 5-37, 6-41, 7-5, 7-6,
M l i
n l ey 9-7, 10-5, 10-6, 10-7, 10-8, 10-9, 10-20, 10-33, 11-24, 14-3,
8-19,
Sta 14-21, 15-23, 15-37, 16-15, 16-16, 16-17, 16-18, 16-19, 16-35, 17-20, 18-2,
18-3, 18-4, 18-5, 18-6, 18-7, 18-8, 18-9, 18-10, 18-11, 18-12, 18-13,
18-14, 18-15, 18-16, 18-17, 18-18, 18-19, 18-20, 18-22, 18-23, 18-24, 18-25,
18-26, 18-27, 18-28, 18-29, 18-30, 18-31, 19-2, 19-3, 19-4, 19-5, 19-6,
19-7, 19-10, 19-11, 19-12, 19-13, 19-14, 19-15, 19-16, 19-17, 19-18, 20-32
job classes 19-2, 19-4, 19-5, 19-7, 19-10, 19-16, 19-18
K
Keep buffer cache 14-4, 14-5
L
Language and Character Set File Scanner 20-33
Large pool 1-7, 1-8, 10-16, 10-31, 10-32, 14-4, 14-5, 14-10, 14-11,
14-12, 14-21, 14-25, 14-30, 15-35
L
LARGE_POOL_SIZE 10-16, 10-31, 10-32, 14-11, 14-15, 14-26, 14-28
LCSSCAN 20-33
Library cache 1-7, 10-16, 14-10, 14-11, 14-12, 14-13, 14-38, 14-39,
15-31
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
N
NLS_LANG 7-14, 9-13, 20-9, 20-10, 20-11, 20-16, 20-22, 20-30, 20-31,
20-32
NLS_LANGUAGE 20-16, 20-17, 20-18, 20-24, 20-26
NLS_SORT 20-22, 20-23, 20-24, 20-25, 20-26, 20-36
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
P
Performance 1-3, 1-10, 1-20, 1-31, 1-45, 1-46, 5-24, 5-36, 9-17,
10-2, 10-3, 10-12, 10-13, 10-14, 10-17, 10-20, 10-23, 10-25, 10-27, 10-29,
10-31, 10-33, 10-34, 10-35, 11-4, 11-28, 12-8, 12-20, 12-30, 13-35, 14-3,
14-6, 14-8, 14-20, 14-21, 14-31, 14-32, 14-33, 15-1, 15-2, 15-3, 15-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
15-5, 15-6, 15-7, 15-8, 15-9, 15-10, 15-12, 15-13, 15-14, 15-15, 15-16,
15-17, 15-18, 15-19, 15-20, 15-22, 15-23, 15-26, 15-27, 15-31, 15-32, 15-37,
15-38, 15-39, 15-42, 15-44, 15-45, 15-46, 15-47, 16-3, 16-4, 16-8, 16-13,
17-3, 18-14, 19-11, 20-12, 20-26, 20-31, 20-33
PGA 1-4, 1-7, 1-8, 1-9, 1-19, 10-14, 10-16, 14-2, 14-4, 14-5,
14-14, 14-15, 14-16, 14-17, 14-18, 14-19, 14-20, 14-30, 14-31, 14-32, 14-33,
14-35, 14-40
ble
PGA_AGGREGATE_TARGET 14-15, 14-16, 14-17, 14-32, 14-33
fe r a
PMON 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22, 17-21
t r a ns
Private SQL area 14-5, 14-30 o n -
Privilege 1-27, 1-35, 3-30, 6-14, 6-15, 11-13, 12-4, 15-28, 16-23, s an
17-12, 18-6, 19-6 ) ha ideฺ
c o m Gu
Proactive Tablespace Monitoring 16-9
a il ฺ n t
Procedure 3-8, 3-35, 5-31, 7-17, 7-19, 7-21, gm7-28, e
ud 11-31,
11-28,
@ S t
11-35, 11-36, 13-30, 14-23, u
y ki 15-10,
14-39, t h is 15-20, 15-39, 15-40, 15-42, 15-43,
s
a 16-38, se17-11, 17-12, 17-21, 18-3, 18-5, 18-6,
15-44, 16-25, 16-30,M
( 16-37,
to u
u
18-7, 18-8, 18-11,
y ki 18-12,
s e 18-13, 18-14, 18-15, 18-16, 18-17, 18-18, 18-19,
18-21,M as 18-23,
18-22, l i c en18-28, 19-6, 19-9, 19-11, 19-12, 19-15, 20-19, 20-29
l y
e15-25,
t a n
Profile 15-26, 15-28
SProgram Global Area 1-8, 1-19, 10-16, 14-4, 14-5, 14-30, 14-31
R
Recovery catalog 2-7, 2-22, 3-1, 3-2, 3-3, 3-4, 3-5, 3-6,
3-7, 3-8, 3-9, 3-10, 3-11, 3-12, 3-13, 3-14, 3-15, 3-16, 3-17,
3-18, 3-20, 3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27, 3-28, 3-29,
3-30, 3-31, 3-32, 3-34, 3-36, 3-37, 4-5, 4-8, 5-19, 5-34, 5-36,
5-38, 7-16, 7-18, 7-19, 7-21, 7-22, 7-23, 7-27, 8-11, 9-9, 9-20,
10-9, 10-10, 13-41
Recovery Manager 2-6, 2-7, 2-8, 5-6, 5-31, 12-12, 13-42
Recycle bin 11-2, 11-3, 11-8, 11-9, 11-10, 11-11, 11-12, 11-13, 11-14,
11-15, 11-16, 11-38, 11-39
R
Recycle buffer cache 14-4, 14-5
recyclebin 11-8, 11-10, 11-12, 11-13, 11-15
RECYCLEBIN 11-8, 11-10, 11-12, 11-13, 11-15
Redo 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-12, 1-19, 2-5, 2-11,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
2-12, 2-13, 2-15, 2-17, 2-18, 2-24, 2-25, 2-26, 2-30, 3-4, 3-7,
3-16, 3-18, 3-20, 3-21, 4-3, 5-4, 5-5, 5-6, 5-11, 5-15, 5-23,
5-38, 6-2, 6-3, 6-5, 6-7, 6-8, 6-9, 6-10, 6-12, 6-18, 6-19,
6-20, 6-23, 6-26, 6-28, 6-33, 6-36, 6-37, 6-38, 6-39, 6-40, 6-42,
6-43, 6-46, 6-47, 6-48, 6-49, 6-50, 7-3, 7-20, 7-25, 7-27, 8-3,
8-5, 8-7, 8-8, 8-9, 8-10, 8-13, 8-14, 9-5, 9-14, 10-4, 11-28,
12-7, 12-9, 12-12, 12-13, 12-20, 12-22, 12-23, 13-28, 13-36, 13-37, 13-41,
ble
14-4, 14-11, 14-12, 14-13, 15-14, 16-39, 18-13, 18-14
fe r a
Redo log buffer 1-7, 1-8, 14-4, 14-13, 15-14
t r a ns
redo log groups 6-8 o n -
REMOTE_LOGIN_PASSWORDFILE 6-15 s an
Resource Manager 17-2, 17-3, 17-4, 17-5, 17-6, 17-8, 17-10, ) ha 17-14,
i d eฺ
m
co 17-28,G u
a l ฺ
17-17, 17-20, 17-22, 17-24, 17-25, 17-26, i17-27, n t 17-29, 17-30, 19-4,
19-6 gm Stud e
RESOURCE_MANAGER_PLAN u
@
ki 17-24
17-8, is
s y t h
restore point 5-20, 5-21, 5-22,
( M se 7-13, 7-14, 12-13,
a 5-23,u6-20,
12-19, 12-20,y u ki se to
12-21
ResumableM as allocation
space l i c en 16-2, 16-21, 16-22, 16-23, 16-40
n l ey
RESUMABLE_TIMEOUT 16-22
t a
SRetention Policy 2-2, 2-21, 2-22, 2-23, 2-29, 2-30, 2-34, 3-5,
3-27, 4-5, 4-13, 5-18, 5-19, 5-21, 5-22, 5-23, 5-35
R
RMAN 1-21, 2-2, 2-6, 2-7, 2-8, 2-9, 2-10, 2-19, 2-20, 2-21,
2-22, 2-23, 2-25, 2-28, 2-29, 2-30, 2-34, 2-35, 3-1, 3-2, 3-3,
3-4, 3-5, 3-7, 3-9, 3-11, 3-12, 3-15, 3-17, 3-18, 3-19, 3-20,
3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27, 3-28, 3-29, 3-30, 3-31,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
3-32, 3-33, 3-34, 3-35, 3-36, 3-37, 4-3, 4-5, 4-6, 4-7, 4-8,
4-9, 4-10, 4-12, 4-13, 4-16, 5-1, 5-3, 5-4, 5-6, 5-7, 5-8,
5-9, 5-10, 5-11, 5-13, 5-14, 5-15, 5-16, 5-17, 5-18, 5-19, 5-20,
5-22, 5-23, 5-24, 5-25, 5-26, 5-27, 5-28, 5-29, 5-30, 5-31, 5-32,
5-34, 5-38, 6-20, 6-21, 6-23, 7-1, 7-2, 7-3, 7-4, 7-5, 7-6,
7-7, 7-8, 7-14, 7-16, 7-17, 7-18, 7-19, 7-20, 7-21, 7-22, 7-23,
7-24, 7-25, 7-26, 7-29, 7-30, 8-1, 8-2, 8-3, 8-6, 8-7, 8-9,
ble
8-10, 8-11, 8-12, 8-13, 8-14, 8-21, 8-22, 9-3, 9-5, 9-6, 9-7,
fe r a
9-12, 9-13, 9-15, 9-16, 9-17, 9-18, 9-19, 9-20, 10-1, 10-2, 10-3,
t r a ns
n
10-4, 10-5, 10-6, 10-7, 10-8, 10-9, 10-10, 10-11, 10-12, 10-13, 10-14,
o -
10-16, 10-17, 10-18, 10-20, 10-23, 10-26, 10-27, 10-29, s a n 10-32, 10-33,
10-31,
)
10-34, 10-35, 10-36, 12-12, 12-13, 13-36, 13-37, 13-38, ha 13-39,
i d eฺ13-40, 13-41,
m
co 18-11, G u
l ฺ
13-42, 13-43, 13-44, 13-45, 16-30, 16-37, i16-38, n t 18-18
RMAN Repository 3-2, 3-3, 3-17, 3-27, 3-28,g ma3-36,tu4-5,
de4-7,
5-34, 5-38, 7-22 u k i@ is S
a s y e th
Role 1-26, 1-28, 3-8, 17-12,
i ( M 19-17
t o us
Rule 10-23, 18-16,y k 18-25,
u18-23, se 18-27, 18-29
a s e n
M
Rule set 18-29
y lic
le
S tan
SScheduler 15-10, 15-12, 15-37, 16-18, 17-8, 17-10, 18-1, 18-2, 18-3,
18-4, 18-5, 18-6, 18-7, 18-8, 18-9, 18-10, 18-11, 18-12, 18-13, 18-15,
18-16, 18-17, 18-18, 18-19, 18-20, 18-22, 18-25, 18-26, 18-27, 18-28, 18-29,
18-30, 18-31, 19-1, 19-2, 19-3, 19-4, 19-6, 19-7, 19-8, 19-9, 19-12,
19-13, 19-14, 19-15, 19-16, 19-17, 19-18
Schema 1-14, 1-15, 1-19, 3-5, 3-7, 3-20, 3-29, 3-30, 3-31, 5-36,
6-15, 7-22, 9-7, 11-11, 11-13, 11-17, 11-27, 11-30, 12-5, 12-6, 15-21,
15-32, 15-34, 15-36, 16-15, 16-19, 16-25, 18-6, 18-11, 18-22, 18-26, 19-6
SCN 3-5, 5-20, 6-20, 6-28, 6-33, 6-34, 6-36, 6-37, 6-39, 7-3,
7-7, 7-13, 7-14, 7-15, 7-26, 9-4, 9-9, 11-18, 11-24, 12-6, 12-13,
12-16, 12-18, 12-19, 12-22, 12-24, 12-30, 15-43
S
Segment 1-14, 1-15, 1-18, 1-19, 1-30, 5-8, 9-4, 11-4, 11-22,
13-28, 14-9, 15-18, 16-2, 16-3, 16-4, 16-5, 16-6, 16-7, 16-8, 16-12,
16-13, 16-14, 16-15, 16-16, 16-17, 16-18, 16-19, 16-20, 16-25, 16-40, 16-41,
17-8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Segment Advisor 16-2, 16-6, 16-8, 16-15, 16-16, 16-17, 16-18, 16-19,
16-40, 16-41, 17-8
Separation of Duties 3-32
Sequence 3-8, 4-8, 6-39, 6-42, 6-43, 7-14, 12-13, 12-16, 14-38,
14-39, 15-20, 20-20, 20-26
Server sessions 10-3, 10-4, 10-5
Session memory 14-5, 14-11, 14-31
ble
SESSIONS 1-5, 10-3, 10-4, 10-5, 10-6, 13-44, 14-7, 14-10, 14-32,
fe r a
15-2, 15-4, 15-8, 15-12, 15-13, 15-14, 15-15, 15-16, 15-17, 15-39, 15-42,
t r a ns
15-46, 15-47, 16-11, 16-23, 17-3, 17-4, 17-5, 17-6, 17-9, 17-11,o17-13, n -
17-14, 17-15, 17-17, 17-18, 17-21, 17-22, 17-26, 17-27, s a n 18-4, 20-2,
17-28,
20-16, 20-35 ) ha ideฺ
c o m Gu
il
SGA 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-19, 5-11, 10-16,
a ฺ t
10-31,
n
12-9, 14-2, 14-4, 14-6, 14-8, 14-11,g m 14-14,
14-12,
e
ud 14-15, 14-16, 14-17,
@ S t
14-18, 14-19, 14-20, 14-21, u
y ki 14-23,
14-22, t h is 14-24, 14-25, 14-26, 14-27, 14-28,
s
a 14-36, se14-37, 14-40, 15-14, 15-20
14-29, 14-30, 14-33,M
( 14-34, u
o 14-23, 14-27
SGA_MAX_SIZE y14-15, u ki 14-16,
s e t14-17,
SGA_TARGET M as1-8, 14-15,
l i c en 14-16, 14-17, 14-21, 14-23, 14-24, 14-25, 14-26,
n l ey 14-28, 14-29
14-27,
ta
SShared pool 1-4, 1-6, 1-7, 1-8, 1-9, 1-10, 1-45, 10-16, 10-31,
10-32, 14-4, 14-5, 14-10, 14-11, 14-12, 14-13, 14-19, 14-21, 14-24, 14-25,
14-28, 14-29, 14-30, 14-34, 14-38, 15-14
Shared server 1-5, 1-9, 14-4, 14-5, 14-10, 14-11, 14-30, 14-31,
15-43
SHARED_POOL_SIZE 14-10, 14-15, 14-24, 14-26, 14-28, 14-29
Shrink Advisor 16-15
SID 1-22, 1-25, 1-43, 3-9, 3-13, 7-23, 10-5, 10-6, 10-7, 13-4,
15-16, 17-10
SMON 1-4, 1-6, 1-9, 1-10, 1-11, 1-19, 1-22
Snapshot 3-20, 5-20, 12-25, 14-7, 15-20, 15-21, 15-42
S
SORT_AREA_SIZE 14-32
SPFILE 1-24, 4-3, 4-6, 5-6, 7-17, 7-19, 7-24, 8-9, 14-21, 14-22,
14-23, 14-32
SQL Access Advisor 15-2, 15-23, 15-26, 15-27, 15-32, 15-33, 15-34, 15-37,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
15-46, 15-47
SQL Tuning Advisor 15-2, 15-23, 15-26, 15-27, 15-28, 15-29, 15-30, 15-31,
15-46, 15-47
SQL*Loader 6-12, 15-43, 16-22, 20-19, 20-30, 20-31
SQL*Plus 1-5, 1-8, 1-9, 3-35, 6-21, 6-33, 6-39, 8-9, 10-6,
11-15, 11-27, 13-5, 15-8, 16-41, 17-30, 18-31, 20-19
Statistics 1-22, 10-7, 12-7, 12-24, 13-28, 14-22, 14-33, 15-7, 15-8,
ble
15-9, 15-10, 15-11, 15-12, 15-13, 15-14, 15-16, 15-17, 15-18, 15-19, 15-20,
fe r a
15-22, 15-23, 15-26, 15-28, 15-32, 15-37, 16-15, 16-18, 17-6, 17-8, 17-20,
t r a ns
17-26, 17-27, 18-3, 18-6 o n -
STATISTICS_LEVEL 10-7, 15-9, 15-11, 15-14 s an
Statspack 15-21 ) ha ideฺ
m u
Streams pool 1-7, 1-8, 14-4, 14-5, 14-21, 14-25ilฺco nt G
STREAMS_POOL_SIZE 14-15, 14-26, 14-28 g ma tude
k i@ i s S
SYSAUX 1-17, 6-7, 6-24, 6-26, 7-26,u 12-17,
t h
sy1-35,se3-33,
15-20
SYSDBA 1-12, 1-26, 1-27,
( a
M to u
1-28, 3-34, 3-35, 6-14, 6-15,
i
uk 11-29,
6-16, 11-13, y11-27,
a s e n se 12-29
SYSOPER M lic1-28, 3-33, 3-35, 6-14, 6-15, 6-16
y 1-12, 1-27,
l e
n privilege 6-14, 11-13, 12-4, 15-28, 16-23
System
t a
SSystem statistics 15-9, 15-10, 15-11, 15-13, 15-14
SYSTEM tablespace 1-17, 6-29, 7-6, 8-14, 9-4, 13-35, 14-7, 16-36
T
Tablespace 1-14, 1-15, 1-16, 1-17, 1-18, 1-19, 1-30, 1-43, 3-7,
3-8, 3-9, 3-29, 3-31, 4-3, 4-5, 5-3, 5-14, 5-18, 6-2, 6-5,
6-6, 6-7, 6-13, 6-22, 6-23, 6-26, 6-28, 6-29, 6-30, 6-33, 6-34,
6-45, 6-49, 7-3, 7-5, 7-6, 7-11, 8-14, 9-1, 9-2, 9-3, 9-4,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
9-5, 9-6, 9-7, 9-9, 9-10, 9-11, 9-13, 9-14, 9-18, 9-19, 9-20,
9-21, 11-5, 11-6, 11-7, 11-10, 11-12, 11-13, 11-14, 11-15, 12-4, 12-17,
12-18, 12-19, 12-27, 12-28, 13-35, 13-42, 13-45, 13-46, 14-7, 15-7, 15-20,
15-36, 16-2, 16-3, 16-4, 16-5, 16-6, 16-9, 16-10, 16-11, 16-15, 16-16,
16-27, 16-28, 16-29, 16-30, 16-33, 16-36, 16-40
Target database 2-7, 2-35, 3-3, 3-4, 3-5, 3-10, 3-11, 3-12,
3-13, 3-15, 3-17, 3-20, 3-21, 3-22, 3-23, 3-24, 3-25, 3-26, 3-27,
ble
3-28, 3-30, 3-31, 3-32, 3-33, 3-34, 3-35, 4-5, 4-9, 5-31, 5-36,
fe r a
7-21, 7-22, 7-27, 7-28, 8-3, 8-4, 8-5, 8-6, 8-7, 8-10, 8-11,
t r a ns
8-12, 8-14, 9-5, 9-6, 9-16, 9-17, 10-5, 13-37, 13-42, 16-28, 16-29,
o n -
16-36, 20-30, 20-32 s an
temporary tablespace 1-14, 1-15, 3-8, 6-5, 6-7, 9-4, 9-19, ) ha ideฺ
c o m Gu
16-11
a il ฺ n t
Temporary tablespace 1-14, 1-15, 3-8, 6-5,gm6-7,S9-4, e
ud9-19,
@ t
16-11
y u ki this
a s 12-13,se15-12
THREAD 1-6, 6-42, 10-5,M
( 10-22,
to u
u
Threshold 11-6, 16-10,
y ki 16-11,
s e 16-18, 16-41, 17-5, 17-13, 17-20, 18-19
M as lic15-14
TIMED_STATISTICS en
Tracen l ey 1-12, 1-13, 13-5, 13-6, 13-7, 13-22, 13-24, 13-38
Files
ta
STRANSACTIONS 1-15, 2-4, 2-13, 6-8, 6-17, 6-18, 6-19, 6-20, 6-34,
7-14, 11-3, 11-4, 11-5, 11-17, 11-20, 11-21, 11-23, 11-26, 11-29, 11-31,
11-32, 11-35, 11-36, 11-37, 12-32, 14-11, 15-4, 15-6, 15-43, 16-5, 16-25
Trigger 1-44, 3-8, 14-15, 16-10, 16-23, 16-24, 16-25, 18-17
U
Undo 1-15, 6-7, 6-18, 6-19, 6-20, 7-5, 7-6, 8-14, 9-4, 9-7,
9-19, 9-20, 11-3, 11-4, 11-5, 11-6, 11-7, 11-8, 11-23, 11-25, 11-33,
11-34, 12-4, 12-7, 12-8, 12-18, 12-27, 12-32, 13-28, 16-5, 16-10, 16-11,
17-5, 17-13, 17-19
Undo data 6-18, 6-20, 7-6, 11-3, 11-5, 11-6, 11-7, 11-25
UNDO_MANAGEMENT 11-6
U
UNDO_RETENTION 11-6, 11-7, 16-10
UNDO_TABLESPACE 11-6
User Global Area 14-10
USER_DUMP_DEST 10-9, 13-4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
UTC 20-34
V
V$BACKUP 5-13, 5-25, 5-36, 10-20, 10-21, 10-22
V$BACKUP_ASYNC_IO 10-20, 10-21
V$BACKUP_DATAFILE 5-13, 5-25
V$BACKUP_FILES 5-36
V$BACKUP_PIECE 5-36
a ble
V$BACKUP_SET 5-25, 5-36
e r
V$BACKUP_SYNC_IO 10-20, 10-22 a n sf
V$BGPROCESS 1-11, 15-18 o n -tr
V$BLOCK_CHANGE_TRACKING 5-13 s an
V$BUFFER_POOL 15-18 ) ha ideฺ
c o m Gu
V$BUFFER_POOL_STATISTICS 15-18 a il ฺ n t
gm Stud e
V$CONTROLFILE 6-24
@
ki this 13-38, 15-18, 16-31
V$DATABASE 3-15, 7-23, 12-10,
s y u12-22, 13-36,
( M a
V$DATABASE_BLOCK_CORRUPTION u se 13-36, 13-38
u ki 6-30,e to
say
V$DATAFILE 5-36, 6-24,
e s
n 6-32, 7-25, 15-18
yM
V$DATAFILE_COPY lic5-36
l e
tan 15-18
SV$DBFILE
V$EVENT_NAME 15-12, 15-13, 15-16
V$FILESTAT 15-18
V$FLASHBACK_DATABASE_LOG 12-22
V$FLASHBACK_DATABASE_STAT 12-22
V$INSTANCE 15-18
V$LATCH 15-18
V$LIBRARYCACHE 15-18
V$LOCK 15-18
V$LOG 6-10, 6-43, 15-18
V$LOG_HISTORY 6-43, 15-18
V$MYSTAT 15-16
V
V$PARAMETER 14-26, 15-18
V$PGA_TARGET_ADVICE 14-33
V$PGA_TARGET_ADVICE_HISTOGRAM 14-33
V$PGASTAT 14-33, 15-18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
V
V$SYSTEM_EVENT 15-13, 15-18
V$SYSTEM_PARAMETER 15-18
V$SYSTEM_WAIT_CLASS 15-13, 15-14
V$TABLESPACE 6-30, 12-17
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
V$TEMPFILE 15-18
V$TEMPSEG_USAGE 15-18
V$TRANSACTION 11-4
V$TRANSPORTABLE_PLATFORM 16-31, 16-36
V$UNDOSTAT 11-7, 15-18
V$WAITSTAT 15-18
W
ble
Wait event 15-12
fe r a
window groups 19-2, 19-17, 19-18 ans
n - t r
Work area 1-15, 1-31, 14-31, 14-33 o
an
Workload repository 15-18, 15-20, 15-21, 16-3, 16-9, 16-15as
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
le y
n
Sta