Tải bản đầy đủ (.pdf) (10 trang)

OCA/OCP Oracle Database 11g All-in-One Exam Guide- P3 doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (229.33 KB, 10 trang )

OCA/OCP Oracle Database 11g All-in-One Exam Guide
xiv
Create a Simple Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Create and Use Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . 304
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Chapter 8 DML and Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Data Manipulation Language (DML) Statements . . . . . . . . . . . . . . . . . 316
INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
TRUNCATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
MERGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
DML Statement Failures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Control Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Database Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Executing SQL Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Transaction Control: COMMIT, ROLLBACK, SAVEPOINT,
SELECT FOR UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Identify and Administer PL/SQL Objects . . . . . . . . . . . . . . . . . . . . . . . . 340
Stored and Anonymous PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . 340
PL/SQL Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Monitor and Resolve Locking Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . 346
Shared and Exclusive Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
The Enqueue Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347


Lock Contention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Overview of Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Transactions and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Managing Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Error Conditions Related to Undo . . . . . . . . . . . . . . . . . . . . . . . . 354
Parameters for Undo Management, and Retention Guarantee . 355
Sizing and Monitoring the Undo Tablespace . . . . . . . . . . . . . . . 356
Creating and Managing Undo Tablespaces . . . . . . . . . . . . . . . . . 358
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Describe Each Data Manipulation Language (DML) Statement 359
Control Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Manage Data Using DML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Identify and Administer PL/SQL Objects . . . . . . . . . . . . . . . . . . 360
Monitor and Resolve Locking Conflicts . . . . . . . . . . . . . . . . . . . . 360
Overview of Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Contents
xv
Transactions and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Managing Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Chapter 9 Retrieving, Restricting, and Sorting Data Using SQL . . . . . . . . . . . . 367
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
List the Capabilities of SQL SELECT Statements . . . . . . . . . . . . . . . . . . 368
Introducing the SQL SELECT Statement . . . . . . . . . . . . . . . . . . . 368
The DESCRIBE Table Command . . . . . . . . . . . . . . . . . . . . . . . . . 369
Capabilities of the SELECT Statement . . . . . . . . . . . . . . . . . . . . . 370
Data Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Create the Demonstration Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

The HR and WEBSTORE Schemas . . . . . . . . . . . . . . . . . . . . . . . . 375
Demonstration Schema Creation . . . . . . . . . . . . . . . . . . . . . . . . 379
Execute a Basic SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Syntax of the Primitive SELECT Statement . . . . . . . . . . . . . . . . . 382
Rules Are Meant to Be Followed . . . . . . . . . . . . . . . . . . . . . . . . . . 383
SQL Expressions and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 386
NULL Is Nothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Limit the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
The WHERE Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Sort the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
The ORDER BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Ampersand Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Substitution Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Define and Verify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
List the Capabilities of SQL SELECT Statements . . . . . . . . . . . . . 412
Execute a Basic SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . 412
Limit the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . 413
Sort the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . 413
Ampersand Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Chapter 10 Single-Row and Conversion Functions . . . . . . . . . . . . . . . . . . . . . . 419
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
Describe and Use Character, Number, and Date Functions in SQL . . . 420
Defining a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Types of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

Using Case Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . 421
Using Character Manipulations Functions . . . . . . . . . . . . . . . . . 423
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xvi
Using Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Working with Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Describe Various Types of Conversion Functions Available in SQL . . . 434
Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Use the TO_CHAR, TO_NUMBER, and TO_DATE Conversion
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Using the Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . 436
Apply Conditional Expressions in a SELECT Statement . . . . . . . . . . . . 444
Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Conditional Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Describe Various Types of Functions Available in SQL . . . . . . . . 453
Use Character, Number, and Date Functions in SELECT
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Describe Various Types of Conversion Functions Available
in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Use the TO_CHAR, TO_NUMBER, and TO_DATE Conversion
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Apply Conditional Expressions in a SELECT Statement . . . . . . . 454
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Chapter 11 Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
The Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Definition of Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Using Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461

Group Data Using the GROUP BY Clause . . . . . . . . . . . . . . . . . . . . . . . 465
Creating Groups of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
The GROUP BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Grouping by Multiple Columns . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Nested Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Include or Exclude Grouped Rows Using the HAVING Clause . . . . . . 471
Restricting Group Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
The HAVING Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Describe the Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Identify the Available Group Functions . . . . . . . . . . . . . . . . . . . . 475
Group Data Using the GROUP BY Clause . . . . . . . . . . . . . . . . . . 475
Include or Exclude Grouped Rows Using the HAVING Clause . . 476
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Chapter 12 SQL Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Write SELECT Statements to Access Data from More Than One Table
Using Equijoins and Nonequijoins . . . . . . . . . . . . . . . . . . . . . . . . . 482
Types of Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Contents
xvii
Joining Tables Using SQL:1999 Syntax . . . . . . . . . . . . . . . . . . . . 487
Qualifying Ambiguous Column Names . . . . . . . . . . . . . . . . . . . 487
The NATURAL JOIN Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
The Natural JOIN USING Clause . . . . . . . . . . . . . . . . . . . . . . . . . 492
The Natural JOIN ON Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
N-Way Joins and Additional Join Conditions . . . . . . . . . . . . . . . 495
Nonequijoins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Join a Table to Itself Using a Self-Join . . . . . . . . . . . . . . . . . . . . . . . . . . 498

Joining a Table to Itself Using the JOIN . . . ON Clause . . . . . . . 498
View Data That Does Not Meet a Join Condition by Using
Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Inner Versus Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Left Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
Right Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Full Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Generate a Cartesian Product of Two or More Tables . . . . . . . . . . . . . . 505
Creating Cartesian Products Using Cross Joins . . . . . . . . . . . . . . 506
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Write SELECT Statements to Access Data from More Than
One Table Using Equijoins and Nonequijoins . . . . . . . . . . . 508
Join a Table to Itself Using a Self-Join . . . . . . . . . . . . . . . . . . . . . 509
View Data That Does Not Meet a Join Condition Using
Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Generate a Cartesian Product of Two or More Tables . . . . . . . . . 509
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Chapter 13 Subqueries and Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Define Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Describe the Types of Problems That the Subqueries Can Solve . . . . . 517
Use of a Subquery Result Set for Comparison Purposes . . . . . . 517
Generate a Table from Which to SELECT . . . . . . . . . . . . . . . . . . 518
Generate Values for Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Generate Rows to Be Passed to a DML Statement . . . . . . . . . . . . 519
List the Types of Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Single- and Multiple-Row Subqueries . . . . . . . . . . . . . . . . . . . . . 520
Correlated Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Write Single-Row and Multiple-Row Subqueries . . . . . . . . . . . . . . . . . . 524

Describe the Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Sets and Venn Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Set Operator General Principles . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Use a Set Operator to Combine Multiple Queries into
a Single Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
The UNION ALL Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
The UNION Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xviii
The INTERSECT Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
The MINUS Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
More Complex Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Control the Order of Rows Returned . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Define Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Describe the Types of Problems That the Subqueries Can Solve . 533
List the Types of Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Write Single-Row and Multiple-Row Subqueries . . . . . . . . . . . . 534
Describe the Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Use a Set Operator to Combine Multiple Queries into
a Single Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Control the Order of Rows Returned . . . . . . . . . . . . . . . . . . . . . . 534
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
PART III Advanced Database Administration
Chapter 14 Configuring the Database for Backup and Recovery . . . . . . . . . . . 543
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Backup and Recovery Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Categories of Failures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Statement Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546

User Process Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Network Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
User Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Media Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
Instance Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Instance Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
The Mechanics of Instance Recovery . . . . . . . . . . . . . . . . . . . . . . 553
The Impossibility of Database Corruption . . . . . . . . . . . . . . . . . 554
Tuning Instance Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
The MTTR Advisor and Checkpoint Auto-Tuning . . . . . . . . . . . . 555
Checkpointing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Preparing the Database for Recoverability . . . . . . . . . . . . . . . . . . . . . . . 558
Protecting the Controlfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Protecting the Online Redo Log Files . . . . . . . . . . . . . . . . . . . . . 560
Archivelog Mode and the Archiver Process . . . . . . . . . . . . . . . . . 563
Protecting the Archive Redo Log Files . . . . . . . . . . . . . . . . . . . . . 566
The Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Recovery Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Configure the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . 568
Flash Recovery Area Space Usage . . . . . . . . . . . . . . . . . . . . . . . . . 569
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Identify the Types of Failure That Can Occur in
an Oracle Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Describe Ways to Tune Instance Recovery . . . . . . . . . . . . . . . . . . 571
Contents
xix
Identify the Importance of Checkpoints, Redo Log Files,
and Archived Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Configure ARCHIVELOG Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Configure Multiple Archive Log File Destinations to Increase

Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Overview of the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . 572
Configure the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . 572
Use the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Chapter 15 Back Up with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Backup Concepts and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Using the RMAN BACKUP Command to Create Backups . . . . . . . . . . 580
Server-Managed Consistent Backups . . . . . . . . . . . . . . . . . . . . . . 580
Server-Managed Open Backups . . . . . . . . . . . . . . . . . . . . . . . . . . 582
Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Image Copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
Protect Your Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
Parallelizing Backup Operations . . . . . . . . . . . . . . . . . . . . . . . . . 590
Encrypting Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Configuring RMAN Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
Managing and Monitoring RMAN Backups . . . . . . . . . . . . . . . . . . . . . . 594
The LIST, REPORT, and DELETE Commands . . . . . . . . . . . . . . . 594
Archival Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
The Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . 597
Crosschecking Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Create Consistent Database Backups . . . . . . . . . . . . . . . . . . . . . . 599
Back Up Your Database Without Shutting It Down . . . . . . . . . . 599
Create Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Automate Database Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
Manage Backups, View Backup Reports, and Monitor the Flash
Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

Define, Apply, and Use a Retention Policy . . . . . . . . . . . . . . . . . 600
Create Image File Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
Create a Whole Database Backup . . . . . . . . . . . . . . . . . . . . . . . . 600
Enable Fast Incremental Backup . . . . . . . . . . . . . . . . . . . . . . . . . 600
Create Duplex Backups and Back Up Backup Sets . . . . . . . . . . . 600
Create an Archival Backup for Long-Term Retention . . . . . . . . . 601
Create a Multisection, Compressed, and Encrypted Backup . . . 601
Report On and Maintain Backups . . . . . . . . . . . . . . . . . . . . . . . . 601
Configure Backup Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Allocate Channels to Use in Backing Up . . . . . . . . . . . . . . . . . . . 601
Configure Backup Optimization . . . . . . . . . . . . . . . . . . . . . . . . . 601
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xx
Chapter 16 Restore and Recover with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . 607
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
The Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
The Health Monitor and the ADR . . . . . . . . . . . . . . . . . . . . . . . . 608
The Capabilities and Limitations of the DRA . . . . . . . . . . . . . . . 609
Using the Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . 610
Database Restore and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Complete Recovery from Data File Loss Using RMAN . . . . . . . . . . . . . 614
Recovery of Datafiles in Noarchivelog Mode . . . . . . . . . . . . . . . 614
Recovery of a Noncritical File in Archivelog Mode . . . . . . . . . . . 616
Recovering from Loss of a Critical Datafile . . . . . . . . . . . . . . . . . 619
Incomplete Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
Autobackup and Restore of the Controlfile . . . . . . . . . . . . . . . . . . . . . . 623
Using Image Copies for Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Block Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629

Detection of Corrupt Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Block Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
The BLOCK RECOVER Command . . . . . . . . . . . . . . . . . . . . . . . . 630
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Describe the Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . 631
Use the Data Recovery Advisor to Perform Recovery
(Controlfile, Redo Log File, and Datafile) . . . . . . . . . . . . . . . 631
Perform Complete Recovery from a Critical or Noncritical
Data File Loss Using RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Perform Incomplete Recovery Using RMAN . . . . . . . . . . . . . . . . 632
Recover Using Incrementally Updated Backups . . . . . . . . . . . . . 632
Switch to Image Copies for Fast Recovery . . . . . . . . . . . . . . . . . . 632
Recover Using a Backup Control File . . . . . . . . . . . . . . . . . . . . . . 632
Perform Block Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Chapter 17 Advanced RMAN Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
The Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
The Need for a Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . 642
Creating and Connecting to the Catalog . . . . . . . . . . . . . . . . . . . 643
The Virtual Private Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
Protecting and Rebuilding the Catalog . . . . . . . . . . . . . . . . . . . . 646
Stored Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
Using RMAN to Create Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
Tablespace Point-in-Time Recovery (TSPITR) . . . . . . . . . . . . . . . . . . . . 654
The TSPITR Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
Perform Automated TSPITR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
RMAN Performance and Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . 658
Monitoring RMAN Sessions and Jobs . . . . . . . . . . . . . . . . . . . . . 658

Contents
xxi
Tuning RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
Tuning the BACKUP Command . . . . . . . . . . . . . . . . . . . . . . . . . 665
Configure RMAN for Asynchronous I/O . . . . . . . . . . . . . . . . . . . 665
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
Identify Situations That Require an RMAN Recovery Catalog . . . 667
Create and Configure a Recovery Catalog . . . . . . . . . . . . . . . . . . 667
Synchronize the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . 667
Create and Use RMAN Stored Scripts . . . . . . . . . . . . . . . . . . . . . 668
Back Up the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
Create and Use a Virtual Private Catalog . . . . . . . . . . . . . . . . . . . 668
Create a Duplicate Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
Use a Duplicate Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Restore a Database onto a New Host . . . . . . . . . . . . . . . . . . . . . . 669
Perform Disaster Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Identify the Situations That Require TSPITR . . . . . . . . . . . . . . . . 669
Perform Automated TSPITR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Monitor RMAN Sessions and Jobs . . . . . . . . . . . . . . . . . . . . . . . . 670
Tune RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Configure RMAN for Asynchronous I/O . . . . . . . . . . . . . . . . . . . 671
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
Chapter 18 User-Managed Backup, Restore, and Recovery . . . . . . . . . . . . . . . . 677
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
Backup and Recovery in One Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
User-Managed Database Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
Backup in Noarchivelog Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
Backup in Archivelog Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Backup of the Password and Parameter Files . . . . . . . . . . . . . . . . . . . . . 682

Media Failure That Does Not Affect Datafiles . . . . . . . . . . . . . . . . . . . . 683
Recovery from Loss of a Multiplexed Controlfile . . . . . . . . . . . . 683
Recovery from Loss of a Multiplexed Online Redo Log File . . . . 685
Recovery from Loss of a Tempfile . . . . . . . . . . . . . . . . . . . . . . . . . 688
Recovery from Loss of Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
Recovery of Datafiles in Noarchivelog Mode . . . . . . . . . . . . . . . 688
Recovery of a Noncritical Datafile in Archivelog Mode . . . . . . . 689
Recovering a Critical Datafile in Archivelog Mode . . . . . . . . . . . 690
User-Managed Incomplete Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
Recover from a Lost TEMP File . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
Recover from a Lost Redo Log Group . . . . . . . . . . . . . . . . . . . . . 693
Recover from the Loss of a Password File . . . . . . . . . . . . . . . . . . 694
Perform User-Managed Complete Database Recovery . . . . . . . . 694
Perform User-Managed Incomplete Database Recovery . . . . . . . 694
Perform User-Managed Backups . . . . . . . . . . . . . . . . . . . . . . . . . 694
Identify the Need for Backup Mode . . . . . . . . . . . . . . . . . . . . . . . 695
Back Up and Recover a Controlfile . . . . . . . . . . . . . . . . . . . . . . . 695
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xxii
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
Chapter 19 Flashback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
The Different Flashback Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Flashback Query, Transaction, and Table . . . . . . . . . . . . . . . . . . 701
Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
Flashback Data Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702
When to Use Flashback Technology . . . . . . . . . . . . . . . . . . . . . . 702

Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Flashback Database Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 704
Configuring Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . 705
Monitoring Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Using Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Limiting the Amount of Flashback Data Generated . . . . . . . . . . 713
Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
The Implementation of Flashback Drop . . . . . . . . . . . . . . . . . . . 715
Using Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
Managing the Recycle Bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
Basic Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
Flashback Table Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
Flashback Versions Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
Flashback Transaction Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
Flashback and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
The Flashback Data Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Restore Dropped Tables from the Recycle Bin . . . . . . . . . . . . . . . 739
Perform Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Use Flashback Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Perform Flashback Table Operations . . . . . . . . . . . . . . . . . . . . . . 740
Configure and Monitor Flashback Database and Perform
Flashback Database Operations . . . . . . . . . . . . . . . . . . . . . . . 740
Set Up and Use a Flashback Data Archive . . . . . . . . . . . . . . . . . . 740
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
Chapter 20 Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
The Purpose of a Logical Volume Manager . . . . . . . . . . . . . . . . . . . . . . 748

RAID Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748
Volume Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
Choice of RAID Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750
ASM Compared with Third-Party LVMs . . . . . . . . . . . . . . . . . . . . 750
Contents
xxiii
The ASM Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
The Cluster Synchronization Service . . . . . . . . . . . . . . . . . . . . . . 751
The ASM Disks and Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . 751
The ASM Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753
The RDBMS Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754
The ASM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755
Creating Raw Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756
Creating, Starting, and Stopping an ASM Instance . . . . . . . . . . . . . . . . 757
Creating ASM Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760
Creating and Using ASM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 762
ASM and RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
The ASMCMD Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
Describe Automatic Storage Management (ASM) . . . . . . . . . . . . 766
Set Up Initialization Parameter Files for ASM and Database
Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767
Start Up and Shut Down ASM Instances . . . . . . . . . . . . . . . . . . . 767
Administer ASM Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 767
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771
Chapter 21 The Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773
Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773
The Need for Resource Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 774
The Resource Manager Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775

Consumer Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775
Resource Manager Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776
Resource Manager Configuration Tools . . . . . . . . . . . . . . . . . . . . 778
Managing Users and Consumer Groups . . . . . . . . . . . . . . . . . . . . . . . . 781
Resource Manager Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 781
CPU Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 782
Use of the Ratio CPU Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 786
The Active Session Pool Method . . . . . . . . . . . . . . . . . . . . . . . . . 787
Limiting the Degree of Parallelism . . . . . . . . . . . . . . . . . . . . . . . 789
Controlling Jobs by Execution Time . . . . . . . . . . . . . . . . . . . . . . 790
Terminating Sessions by Idle Time . . . . . . . . . . . . . . . . . . . . . . . 791
Restricting Generation of Undo Data . . . . . . . . . . . . . . . . . . . . . 793
Automatic Consumer Group Switching . . . . . . . . . . . . . . . . . . . . . . . . . 794
Adaptive Consumer Group Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 795
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799
Understand the Database Resource Manager . . . . . . . . . . . . . . . 799
Create and Use Database Resource Manager Components . . . . 800
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 800
Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803

×