CONTENTS AT A GLANCE
Part I Oracle Database 11g Administration
Chapter 1 Architectural Overview of Oracle Database 11g . . . . . . . . . . . . . . 3
Chapter 2 Installing and Creating a Database . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Chapter 3 Instance Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Chapter 4 Oracle Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Chapter 5 Oracle Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Chapter 6 Oracle Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Part II SQL
Chapter 7 DDL and Schema Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Chapter 8 DML and Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Chapter 9 Retrieving, Restricting, and Sorting Data Using SQL . . . . . . . . . . . . 367
Chapter 10 Single-Row and Conversion Functions . . . . . . . . . . . . . . . . . . . . . . 419
Chapter 11 Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Chapter 12 SQL Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Chapter 13 Subqueries and Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 918-1 / FM
vii
FM.indd viiFM.indd vii 7/16/2009 2:08:15 PM7/16/2009 2:08:15 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
viii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Part III Advanced Database Administration
Chapter 14 Configuring the Database for Backup and Recovery . . . . . . . . . . . 543
Chapter 15 Back Up with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Chapter 16 Restore and Recover with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . 607
Chapter 17 Advanced RMAN Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
Chapter 18 User-Managed Backup, Restore, and Recovery . . . . . . . . . . . . . . . . 677
Chapter 19 Flashback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
Chapter 20 Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Chapter 21 The Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773
Chapter 22 The Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805
Chapter 23 Moving and Reorganizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
Chapter 24 The AWR and the Alert System . . . . . . . . . . . . . . . . . . . . . . . . . . . 865
Chapter 25 Performance Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891
Chapter 26 Globalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937
Chapter 27 The Intelligent Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 965
Appendix About the CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
FM.indd viiiFM.indd viii 7/16/2009 2:08:15 PM7/16/2009 2:08:15 PM
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
CONTENTS
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Part I Oracle Database 11g Administration
Chapter 1 Architectural Overview of Oracle Database 11g . . . . . . . . . . . . . . 3Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Oracle Product Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Oracle Server Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Oracle Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Oracle Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Prerequisite Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Oracle Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11SQL Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Operating System Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Single-Instance Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Single-Instance Database Architecture . . . . . . . . . . . . . . . . . . . . . 13Distributed Systems Architectures . . . . . . . . . . . . . . . . . . . . . . . . 16
Instance Memory Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19The Database Buffer Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20The Log Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21The Shared Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23The Large Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26The Java Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26The Streams Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Instance Process Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28SMON, the System Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29PMON, the Process Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30DBWn, the Database Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30LGWR, the Log Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32CKPT, the Checkpoint Process . . . . . . . . . . . . . . . . . . . . . . . . . . . 33MMON, the Manageability Monitor . . . . . . . . . . . . . . . . . . . . . . 34
ix
FM.indd ixFM.indd ix 7/16/2009 2:08:16 PM7/16/2009 2:08:16 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
x
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
MMNL, the Manageability Monitor Light . . . . . . . . . . . . . . . . . . 35MMAN, the Memory Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . 35ARCn, the Archiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35RECO, the Recoverer Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Some Other Background Processes . . . . . . . . . . . . . . . . . . . . . . . 37
Database Storage Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40The Physical Database Structures . . . . . . . . . . . . . . . . . . . . . . . . . 41The Logical Database Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 45The Data Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Single-Instance Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Instance Memory Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Instance Process Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Database Storage Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Chapter 2 Installing and Creating a Database . . . . . . . . . . . . . . . . . . . . . . . . . . 55Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Identify the Tools for Administering an Oracle Database . . . . . . . . . . . 56
The Oracle Universal Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Database Creation and Upgrade Tools . . . . . . . . . . . . . . . . . . . . 60Tools for Issuing Ad Hoc SQL: SQL*Plus and SQL Developer . 61Oracle Enterprise Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Other Administration Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Plan an Oracle Database Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Choice of Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Hardware and Operating System Resources . . . . . . . . . . . . . . . . 69Optimal Flexible Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Install the Oracle Software by Using the Oracle Universal Installer (OUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Create a Database by Using the Database Configuration Assistant . . . 77The Instance, the Database, and the Data Dictionary . . . . . . . . . 78Using the DBCA to Create a Database . . . . . . . . . . . . . . . . . . . . . 79The Scripts and Other Files Created by the DBCA . . . . . . . . . . . 84The DBCA’s Other Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91Identify the Tools for Administering an Oracle Database . . . . . 91Plan an Oracle Database Installation . . . . . . . . . . . . . . . . . . . . . 92Install the Oracle Software by Using the Oracle Universal
Installer (OUI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Create a Database by Using the Database Configuration
Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
FM.indd xFM.indd x 7/16/2009 2:08:16 PM7/16/2009 2:08:16 PM
Contents
xi
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Chapter 3 Instance Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Set Database Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 101
Static and Dynamic Parameters and the Initialization Parameter File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
The Basic Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Describe the Stages of Database Startup and Shutdown . . . . . . . . . . . . 108
Starting and Connecting to Database Control . . . . . . . . . . . . . . 108Starting the Database Listener . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Starting SQL*Plus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112Database Startup and Shutdown . . . . . . . . . . . . . . . . . . . . . . . . . 112
Use the Alert Log and Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Use Data Dictionary and Dynamic Performance Views . . . . . . . . . . . . 123
The Data Dictionary Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123The Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . 124
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126Describe the Stages of Database Startup and Shutdown . . . . . . 126Set Database Initialization Parameters . . . . . . . . . . . . . . . . . . . . 126Use the Alert Log and Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . 127Use Data Dictionary and Dynamic Performance Views . . . . . . . 127
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Chapter 4 Oracle Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Configure and Manage the Oracle Network . . . . . . . . . . . . . . . . . . . . . 134
Oracle Net and the Client-Server Paradigm . . . . . . . . . . . . . . . . . 134A Word on Oracle Net and Communication Protocols . . . . . . . 136Establishing a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136Creating a Listener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139Database Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140Techniques for Name Resolution . . . . . . . . . . . . . . . . . . . . . . . . . 143The Listener Control Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145Configuring Service Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Filenames and the TNSADMIN Environment Variable . . . . . . . 151Database Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Use the Oracle Shared Server Architecture . . . . . . . . . . . . . . . . . . . . . . . 157The Limitations of Dedicated Server Architecture . . . . . . . . . . . . 157The Shared Server Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Configuring Shared Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161When to Use the Shared Server . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165Configure and Manage the Oracle Network . . . . . . . . . . . . . . . . 165Use the Oracle Shared Server Architecture . . . . . . . . . . . . . . . . . 165
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
FM.indd xiFM.indd xi 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Chapter 5 Oracle Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171Overview of Tablespaces and Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . 172
The Oracle Data Storage Model . . . . . . . . . . . . . . . . . . . . . . . . . . 172Segments, Extents, Blocks, and Rows . . . . . . . . . . . . . . . . . . . . . . 174File Storage Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Create and Manage Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180Tablespace Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180Altering Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Dropping Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191Oracle-Managed Files (OMF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Space Management in Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194Extent Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194Segment Space Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197Overview of Tablespaces and Datafiles . . . . . . . . . . . . . . . . . . . . 197Create and Manage Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . 198Space Management in Tablespaces . . . . . . . . . . . . . . . . . . . . . . . 198
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Chapter 6 Oracle Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203Create and Manage Database User Accounts . . . . . . . . . . . . . . . . . . . . . 204
User Account Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205Authentication Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Creating Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Grant and Revoke Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216System Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216Object Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Create and Manage Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Creating and Granting Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Predefined Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Enabling Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Create and Manage Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Password Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Resource Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230Creating and Assigning Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Database Security and Principle of Least Privilege . . . . . . . . . . . . . . . . 234Public Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234Security-Critical Instance Parameters . . . . . . . . . . . . . . . . . . . . . . 235
Work with Standard Database Auditing . . . . . . . . . . . . . . . . . . . . . . . . . 240Auditing SYSDBA Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Database Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Value-Based Auditing with Triggers . . . . . . . . . . . . . . . . . . . . . . . 244Fine-Grained Auditing (FGA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
FM.indd xiiFM.indd xii 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
Contents
xiii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248Create and Manage Database User Accounts . . . . . . . . . . . . . . . 248Grant and Revoke Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248Create and Manage Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Create and Manage Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Database Security and Principle of Least Privilege . . . . . . . . . . . 249Work with Standard Database Auditing . . . . . . . . . . . . . . . . . . . 249
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Part II SQL
Chapter 7 DDL and Schema Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Categorize the Main Database Objects . . . . . . . . . . . . . . . . . . . . . . . . . 260
Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260Naming Schema Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Object Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
List the Data Types That Are Available for Columns . . . . . . . . . . . . . . . 263Create a Simple Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Creating Tables with Column Specifications . . . . . . . . . . . . . . . . 267Creating Tables from Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . 268Altering Table Definitions after Creation . . . . . . . . . . . . . . . . . . 269Dropping and Truncating Tables . . . . . . . . . . . . . . . . . . . . . . . . . 270
Create and Use Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Why Indexes Are Needed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275Types of Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276Creating and Using Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Modifying and Dropping Indexes . . . . . . . . . . . . . . . . . . . . . . . . 282
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283The Types of Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283Defining Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286Constraint State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Constraint Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Why Use Views at All? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291Simple and Complex Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293CREATE VIEW, ALTER VIEW, and DROP VIEW . . . . . . . . . . . . . . 294
Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Creating Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298Using Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303Categorize the Main Database Objects . . . . . . . . . . . . . . . . . . . . 303List the Data Types That Are Available for Columns . . . . . . . . . . 303
FM.indd xiiiFM.indd xiii 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xiv
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Create a Simple Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Create and Use Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . 304Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Chapter 8 DML and Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315Data Manipulation Language (DML) Statements . . . . . . . . . . . . . . . . . 316
INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323TRUNCATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325MERGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326DML Statement Failures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Control Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330Database Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330Executing SQL Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331Transaction Control: COMMIT, ROLLBACK, SAVEPOINT,
SELECT FOR UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335Identify and Administer PL/SQL Objects . . . . . . . . . . . . . . . . . . . . . . . . 340
Stored and Anonymous PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . 340PL/SQL Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Monitor and Resolve Locking Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . 346Shared and Exclusive Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346The Enqueue Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347Lock Contention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Overview of Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351Transactions and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Managing Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Error Conditions Related to Undo . . . . . . . . . . . . . . . . . . . . . . . . 354Parameters for Undo Management, and Retention Guarantee . 355Sizing and Monitoring the Undo Tablespace . . . . . . . . . . . . . . . 356Creating and Managing Undo Tablespaces . . . . . . . . . . . . . . . . . 358
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359Describe Each Data Manipulation Language (DML) Statement 359Control Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360Manage Data Using DML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360Identify and Administer PL/SQL Objects . . . . . . . . . . . . . . . . . . 360Monitor and Resolve Locking Conflicts . . . . . . . . . . . . . . . . . . . . 360Overview of Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
FM.indd xivFM.indd xiv 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
Contents
xv
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Transactions and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361Managing Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Chapter 9 Retrieving, Restricting, and Sorting Data Using SQL . . . . . . . . . . . . 367Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367List the Capabilities of SQL SELECT Statements . . . . . . . . . . . . . . . . . . 368
Introducing the SQL SELECT Statement . . . . . . . . . . . . . . . . . . . 368The DESCRIBE Table Command . . . . . . . . . . . . . . . . . . . . . . . . . 369Capabilities of the SELECT Statement . . . . . . . . . . . . . . . . . . . . . 370Data Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Create the Demonstration Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375The HR and WEBSTORE Schemas . . . . . . . . . . . . . . . . . . . . . . . . 375Demonstration Schema Creation . . . . . . . . . . . . . . . . . . . . . . . . 379
Execute a Basic SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381Syntax of the Primitive SELECT Statement . . . . . . . . . . . . . . . . . 382Rules Are Meant to Be Followed . . . . . . . . . . . . . . . . . . . . . . . . . . 383SQL Expressions and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 386NULL Is Nothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Limit the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . 392The WHERE Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Sort the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403The ORDER BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Ampersand Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405Substitution Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406Define and Verify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412List the Capabilities of SQL SELECT Statements . . . . . . . . . . . . . 412Execute a Basic SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . 412Limit the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . 413Sort the Rows Retrieved by a Query . . . . . . . . . . . . . . . . . . . . . . . 413Ampersand Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Chapter 10 Single-Row and Conversion Functions . . . . . . . . . . . . . . . . . . . . . . 419Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419Describe and Use Character, Number, and Date Functions in SQL . . . 420
Defining a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420Types of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420Using Case Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . 421Using Character Manipulations Functions . . . . . . . . . . . . . . . . . 423
FM.indd xvFM.indd xv 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xvi
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Using Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427Working with Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Describe Various Types of Conversion Functions Available in SQL . . . 434Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Use the TO_CHAR, TO_NUMBER, and TO_DATE Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Using the Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . 436Apply Conditional Expressions in a SELECT Statement . . . . . . . . . . . . 444
Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444Conditional Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453Describe Various Types of Functions Available in SQL . . . . . . . . 453Use Character, Number, and Date Functions in SELECT
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453Describe Various Types of Conversion Functions Available
in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Use the TO_CHAR, TO_NUMBER, and TO_DATE Conversion
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Apply Conditional Expressions in a SELECT Statement . . . . . . . 454
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Chapter 11 Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459The Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Definition of Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 460Using Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Group Data Using the GROUP BY Clause . . . . . . . . . . . . . . . . . . . . . . . 465Creating Groups of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465The GROUP BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466Grouping by Multiple Columns . . . . . . . . . . . . . . . . . . . . . . . . . . 468Nested Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Include or Exclude Grouped Rows Using the HAVING Clause . . . . . . 471Restricting Group Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472The HAVING Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Describe the Group Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Identify the Available Group Functions . . . . . . . . . . . . . . . . . . . . 475Group Data Using the GROUP BY Clause . . . . . . . . . . . . . . . . . . 475Include or Exclude Grouped Rows Using the HAVING Clause . . 476
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Chapter 12 SQL Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481Write SELECT Statements to Access Data from More Than One Table
Using Equijoins and Nonequijoins . . . . . . . . . . . . . . . . . . . . . . . . . 482Types of Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
FM.indd xviFM.indd xvi 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
Contents
xvii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Joining Tables Using SQL:1999 Syntax . . . . . . . . . . . . . . . . . . . . 487Qualifying Ambiguous Column Names . . . . . . . . . . . . . . . . . . . 487The NATURAL JOIN Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489The Natural JOIN USING Clause . . . . . . . . . . . . . . . . . . . . . . . . . 492The Natural JOIN ON Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492N-Way Joins and Additional Join Conditions . . . . . . . . . . . . . . . 495Nonequijoins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Join a Table to Itself Using a Self-Join . . . . . . . . . . . . . . . . . . . . . . . . . . 498Joining 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500Left Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501Right Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503Full Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Generate a Cartesian Product of Two or More Tables . . . . . . . . . . . . . . 505Creating Cartesian Products Using Cross Joins . . . . . . . . . . . . . . 506
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508Write SELECT Statements to Access Data from More Than
One Table Using Equijoins and Nonequijoins . . . . . . . . . . . 508Join a Table to Itself Using a Self-Join . . . . . . . . . . . . . . . . . . . . . 509View Data That Does Not Meet a Join Condition Using
Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509Generate a Cartesian Product of Two or More Tables . . . . . . . . . 509
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Chapter 13 Subqueries and Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Define Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516Describe the Types of Problems That the Subqueries Can Solve . . . . . 517
Use of a Subquery Result Set for Comparison Purposes . . . . . . 517Generate a Table from Which to SELECT . . . . . . . . . . . . . . . . . . 518Generate Values for Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . 518Generate Rows to Be Passed to a DML Statement . . . . . . . . . . . . 519
List the Types of Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520Single- and Multiple-Row Subqueries . . . . . . . . . . . . . . . . . . . . . 520Correlated Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Write Single-Row and Multiple-Row Subqueries . . . . . . . . . . . . . . . . . . 524Describe the Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Sets and Venn Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525Set Operator General Principles . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Use a Set Operator to Combine Multiple Queries into a Single Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
The UNION ALL Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529The UNION Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
FM.indd xviiFM.indd xvii 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xviii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
The INTERSECT Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530The MINUS Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531More Complex Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Control the Order of Rows Returned . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Define Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Describe the Types of Problems That the Subqueries Can Solve . 533List the Types of Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534Write Single-Row and Multiple-Row Subqueries . . . . . . . . . . . . 534Describe the Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534Use a Set Operator to Combine Multiple Queries into
a Single Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534Control the Order of Rows Returned . . . . . . . . . . . . . . . . . . . . . . 534
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
PART III Advanced Database Administration
Chapter 14 Configuring the Database for Backup and Recovery . . . . . . . . . . . 543Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Backup and Recovery Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544Categories of Failures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Statement Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546User Process Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547Network Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548User Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549Media Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551Instance Failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Instance Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552The Mechanics of Instance Recovery . . . . . . . . . . . . . . . . . . . . . . 553The Impossibility of Database Corruption . . . . . . . . . . . . . . . . . 554Tuning Instance Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555The MTTR Advisor and Checkpoint Auto-Tuning . . . . . . . . . . . . 555Checkpointing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Preparing the Database for Recoverability . . . . . . . . . . . . . . . . . . . . . . . 558Protecting the Controlfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558Protecting the Online Redo Log Files . . . . . . . . . . . . . . . . . . . . . 560Archivelog Mode and the Archiver Process . . . . . . . . . . . . . . . . . 563Protecting the Archive Redo Log Files . . . . . . . . . . . . . . . . . . . . . 566
The Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567Recovery Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567Configure the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . 568Flash Recovery Area Space Usage . . . . . . . . . . . . . . . . . . . . . . . . . 569
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Identify the Types of Failure That Can Occur in
an Oracle Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Describe Ways to Tune Instance Recovery . . . . . . . . . . . . . . . . . . 571
FM.indd xviiiFM.indd xviii 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
Contents
xix
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Identify the Importance of Checkpoints, Redo Log Files, and Archived Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Configure ARCHIVELOG Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 571Configure Multiple Archive Log File Destinations to Increase
Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571Overview of the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . 572Configure the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . 572Use the Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Chapter 15 Back Up with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577Backup Concepts and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578Using the RMAN BACKUP Command to Create Backups . . . . . . . . . . 580
Server-Managed Consistent Backups . . . . . . . . . . . . . . . . . . . . . . 580Server-Managed Open Backups . . . . . . . . . . . . . . . . . . . . . . . . . . 582Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583Image Copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588Protect Your Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588Parallelizing Backup Operations . . . . . . . . . . . . . . . . . . . . . . . . . 590Encrypting Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Configuring RMAN Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592Managing and Monitoring RMAN Backups . . . . . . . . . . . . . . . . . . . . . . 594
The LIST, REPORT, and DELETE Commands . . . . . . . . . . . . . . . 594Archival Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596The Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . 597Crosschecking Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599Create Consistent Database Backups . . . . . . . . . . . . . . . . . . . . . . 599Back Up Your Database Without Shutting It Down . . . . . . . . . . 599Create Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599Automate Database Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600Manage Backups, View Backup Reports, and Monitor the Flash
Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600Define, Apply, and Use a Retention Policy . . . . . . . . . . . . . . . . . 600Create Image File Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600Create a Whole Database Backup . . . . . . . . . . . . . . . . . . . . . . . . 600Enable Fast Incremental Backup . . . . . . . . . . . . . . . . . . . . . . . . . 600Create Duplex Backups and Back Up Backup Sets . . . . . . . . . . . 600Create an Archival Backup for Long-Term Retention . . . . . . . . . 601Create a Multisection, Compressed, and Encrypted Backup . . . 601Report On and Maintain Backups . . . . . . . . . . . . . . . . . . . . . . . . 601Configure Backup Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601Allocate Channels to Use in Backing Up . . . . . . . . . . . . . . . . . . . 601Configure Backup Optimization . . . . . . . . . . . . . . . . . . . . . . . . . 601
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
FM.indd xixFM.indd xix 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xx
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Chapter 16 Restore and Recover with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . 607Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607The Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
The Health Monitor and the ADR . . . . . . . . . . . . . . . . . . . . . . . . 608The Capabilities and Limitations of the DRA . . . . . . . . . . . . . . . 609Using the Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . 610
Database Restore and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613Complete Recovery from Data File Loss Using RMAN . . . . . . . . . . . . . 614
Recovery of Datafiles in Noarchivelog Mode . . . . . . . . . . . . . . . 614Recovery of a Noncritical File in Archivelog Mode . . . . . . . . . . . 616Recovering from Loss of a Critical Datafile . . . . . . . . . . . . . . . . . 619
Incomplete Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620Autobackup and Restore of the Controlfile . . . . . . . . . . . . . . . . . . . . . . 623Using Image Copies for Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627Block Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
Detection of Corrupt Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629Block Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630The BLOCK RECOVER Command . . . . . . . . . . . . . . . . . . . . . . . . 630
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631Describe the Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . 631Use the Data Recovery Advisor to Perform Recovery
(Controlfile, Redo Log File, and Datafile) . . . . . . . . . . . . . . . 631Perform Complete Recovery from a Critical or Noncritical
Data File Loss Using RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . 631Perform Incomplete Recovery Using RMAN . . . . . . . . . . . . . . . . 632Recover Using Incrementally Updated Backups . . . . . . . . . . . . . 632Switch to Image Copies for Fast Recovery . . . . . . . . . . . . . . . . . . 632Recover Using a Backup Control File . . . . . . . . . . . . . . . . . . . . . . 632Perform Block Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Chapter 17 Advanced RMAN Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641The Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
The Need for a Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . 642Creating and Connecting to the Catalog . . . . . . . . . . . . . . . . . . . 643The Virtual Private Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645Protecting and Rebuilding the Catalog . . . . . . . . . . . . . . . . . . . . 646
Stored Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649Using RMAN to Create Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651Tablespace Point-in-Time Recovery (TSPITR) . . . . . . . . . . . . . . . . . . . . 654
The TSPITR Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654Perform Automated TSPITR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
RMAN Performance and Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . 658Monitoring RMAN Sessions and Jobs . . . . . . . . . . . . . . . . . . . . . 658
FM.indd xxFM.indd xx 7/16/2009 2:08:17 PM7/16/2009 2:08:17 PM
Contents
xxi
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Tuning RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662Tuning the BACKUP Command . . . . . . . . . . . . . . . . . . . . . . . . . 665Configure RMAN for Asynchronous I/O . . . . . . . . . . . . . . . . . . . 665
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667Identify Situations That Require an RMAN Recovery Catalog . . . 667Create and Configure a Recovery Catalog . . . . . . . . . . . . . . . . . . 667Synchronize the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . 667Create and Use RMAN Stored Scripts . . . . . . . . . . . . . . . . . . . . . 668Back Up the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . 668Create and Use a Virtual Private Catalog . . . . . . . . . . . . . . . . . . . 668Create a Duplicate Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668Use a Duplicate Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669Restore a Database onto a New Host . . . . . . . . . . . . . . . . . . . . . . 669Perform Disaster Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669Identify the Situations That Require TSPITR . . . . . . . . . . . . . . . . 669Perform Automated TSPITR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670Monitor RMAN Sessions and Jobs . . . . . . . . . . . . . . . . . . . . . . . . 670Tune RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670Configure RMAN for Asynchronous I/O . . . . . . . . . . . . . . . . . . . 671
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
Chapter 18 User-Managed Backup, Restore, and Recovery . . . . . . . . . . . . . . . . 677Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677Backup and Recovery in One Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678User-Managed Database Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
Backup in Noarchivelog Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 678Backup in Archivelog Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Backup of the Password and Parameter Files . . . . . . . . . . . . . . . . . . . . . 682Media Failure That Does Not Affect Datafiles . . . . . . . . . . . . . . . . . . . . 683
Recovery from Loss of a Multiplexed Controlfile . . . . . . . . . . . . 683Recovery from Loss of a Multiplexed Online Redo Log File . . . . 685Recovery from Loss of a Tempfile . . . . . . . . . . . . . . . . . . . . . . . . . 688
Recovery from Loss of Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688Recovery of Datafiles in Noarchivelog Mode . . . . . . . . . . . . . . . 688Recovery of a Noncritical Datafile in Archivelog Mode . . . . . . . 689Recovering a Critical Datafile in Archivelog Mode . . . . . . . . . . . 690
User-Managed Incomplete Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 691Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
Recover from a Lost TEMP File . . . . . . . . . . . . . . . . . . . . . . . . . . . 693Recover from a Lost Redo Log Group . . . . . . . . . . . . . . . . . . . . . 693Recover from the Loss of a Password File . . . . . . . . . . . . . . . . . . 694Perform User-Managed Complete Database Recovery . . . . . . . . 694Perform User-Managed Incomplete Database Recovery . . . . . . . 694Perform User-Managed Backups . . . . . . . . . . . . . . . . . . . . . . . . . 694Identify the Need for Backup Mode . . . . . . . . . . . . . . . . . . . . . . . 695Back Up and Recover a Controlfile . . . . . . . . . . . . . . . . . . . . . . . 695
FM.indd xxiFM.indd xxi 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xxii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
Chapter 19 Flashback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699The Different Flashback Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700Flashback Query, Transaction, and Table . . . . . . . . . . . . . . . . . . 701Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701Flashback Data Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702When to Use Flashback Technology . . . . . . . . . . . . . . . . . . . . . . 702
Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704Flashback Database Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 704Configuring Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . 705Monitoring Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . 707Using Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709Limiting the Amount of Flashback Data Generated . . . . . . . . . . 713
Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715The Implementation of Flashback Drop . . . . . . . . . . . . . . . . . . . 715Using Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717Managing the Recycle Bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723Basic Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724Flashback Table Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725Flashback Versions Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728Flashback Transaction Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729Flashback and Undo Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
The Flashback Data Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Restore Dropped Tables from the Recycle Bin . . . . . . . . . . . . . . . 739Perform Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739Use Flashback Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739Perform Flashback Table Operations . . . . . . . . . . . . . . . . . . . . . . 740Configure and Monitor Flashback Database and Perform
Flashback Database Operations . . . . . . . . . . . . . . . . . . . . . . . 740Set Up and Use a Flashback Data Archive . . . . . . . . . . . . . . . . . . 740
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
Chapter 20 Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 747Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747The Purpose of a Logical Volume Manager . . . . . . . . . . . . . . . . . . . . . . 748
RAID Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748Volume Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749Choice of RAID Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750ASM Compared with Third-Party LVMs . . . . . . . . . . . . . . . . . . . . 750
FM.indd xxiiFM.indd xxii 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
Contents
xxiii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
The ASM Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751The Cluster Synchronization Service . . . . . . . . . . . . . . . . . . . . . . 751The ASM Disks and Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . 751The ASM Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753The RDBMS Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754The ASM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755
Creating Raw Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756Creating, Starting, and Stopping an ASM Instance . . . . . . . . . . . . . . . . 757Creating ASM Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760Creating and Using ASM Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 762ASM and RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763The ASMCMD Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
Describe Automatic Storage Management (ASM) . . . . . . . . . . . . 766Set Up Initialization Parameter Files for ASM and Database
Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767Start Up and Shut Down ASM Instances . . . . . . . . . . . . . . . . . . . 767Administer ASM Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 767
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771
Chapter 21 The Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773The Need for Resource Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 774The Resource Manager Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775
Consumer Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775Resource Manager Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776Resource Manager Configuration Tools . . . . . . . . . . . . . . . . . . . . 778
Managing Users and Consumer Groups . . . . . . . . . . . . . . . . . . . . . . . . 781Resource Manager Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 781
CPU Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 782Use of the Ratio CPU Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 786The Active Session Pool Method . . . . . . . . . . . . . . . . . . . . . . . . . 787Limiting the Degree of Parallelism . . . . . . . . . . . . . . . . . . . . . . . 789Controlling Jobs by Execution Time . . . . . . . . . . . . . . . . . . . . . . 790Terminating Sessions by Idle Time . . . . . . . . . . . . . . . . . . . . . . . 791Restricting Generation of Undo Data . . . . . . . . . . . . . . . . . . . . . 793
Automatic Consumer Group Switching . . . . . . . . . . . . . . . . . . . . . . . . . 794Adaptive Consumer Group Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 795Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799
Understand the Database Resource Manager . . . . . . . . . . . . . . . 799Create and Use Database Resource Manager Components . . . . 800
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 800Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
FM.indd xxiiiFM.indd xxiii 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xxiv
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Chapter 22 The Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805The Scheduler Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806Scheduler Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807
Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809Schedules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809Job Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 812
Creating and Scheduling Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813A Self-Contained Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813Using Programs and Schedules . . . . . . . . . . . . . . . . . . . . . . . . . . 814Event-Driven Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 817Job Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819Lightweight Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819
Using Classes, Windows, and the Resource Manager . . . . . . . . . . . . . . 822Using Job Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823Using Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826Create a Job, Program, and Schedule . . . . . . . . . . . . . . . . . . . . . . 826Use a Time-Based or Event-Based Schedule for Executing
Scheduler Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826Create Lightweight Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826Use Job Chains to Perform a Series of Related Tasks . . . . . . . . . 826Create Windows and Job Classes . . . . . . . . . . . . . . . . . . . . . . . . . 827Use Advanced Scheduler Concepts to Prioritize Jobs . . . . . . . . . 827
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829
Chapter 23 Moving and Reorganizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831SQL*Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 832External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834
Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835Using External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
Data Pump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838Data Pump Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839Directories and File Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . 840Direct Path or External Table Path? . . . . . . . . . . . . . . . . . . . . . . . 840
Using Data Pump Export and Import . . . . . . . . . . . . . . . . . . . . . . . . . . 841Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 841Using Data Pump with the Command-Line Utilities . . . . . . . . . 842Using Data Pump with Database Control . . . . . . . . . . . . . . . . . . 843Tablespace Export and Import . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
Resumable Space Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
FM.indd xxivFM.indd xxiv 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
Contents
xxv
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Segment Reorganization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852Row Chaining and Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853Segment Shrink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859Describe and Use Methods to Move Data (Directory Objects,
SQL*Loader, External Tables) . . . . . . . . . . . . . . . . . . . . . . . . . 859Explain the General Architecture of Oracle Data Pump . . . . . . . 860Use Data Pump Export and Import to Move Data Between
Oracle Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860Describe the Concepts of Transportable Tablespaces
and Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860Manage Resumable Space Allocation . . . . . . . . . . . . . . . . . . . . . 860Reclaim Wasted Space from Tables and Indexes by Using
the Segment Shrink Functionality . . . . . . . . . . . . . . . . . . . . . . 861Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863
Chapter 24 The AWR and the Alert System . . . . . . . . . . . . . . . . . . . . . . . . . . . 865Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865The Automatic Workload Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . 866
Gathering AWR Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866Managing the AWR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867Statistics, Metrics, and Baselines . . . . . . . . . . . . . . . . . . . . . . . . . 869The DBMS_WORKLOAD_REPOSITORY Package . . . . . . . . . . . . 869
The Database Advisory Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871The Automatic Database Diagnostic Monitor . . . . . . . . . . . . . . . 871The Advisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874Automatic Maintenance Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875
Using the Server-Generated Alert System . . . . . . . . . . . . . . . . . . . . . . . . 880Alert Condition Monitoring and Notifications . . . . . . . . . . . . . . 880Setting Thresholds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881The Notification System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886Use and Manage the Automatic Workload Repository . . . . . . . . 886Use the Advisory Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886Manage Alerts and Thresholds . . . . . . . . . . . . . . . . . . . . . . . . . . . 887
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
Chapter 25 Performance Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891Managing Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 892
PGA Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 892SGA Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 894Automatic Memory Management . . . . . . . . . . . . . . . . . . . . . . . . 896The Memory Advisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897
FM.indd xxvFM.indd xxv 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
OCA/OCP Oracle Database 11g All-in-One Exam Guide
xxvi
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
The SQL Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 900The Capabilities of the SQL Tuning Advisor . . . . . . . . . . . . . . . . 901Using the SQL Tuning Advisor with Enterprise Manager . . . . . . 901The SQL Tuning Advisor API: the DBMS_SQLTUNE Package . . . 908
The SQL Access Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 910Using the SQL Access Advisor with Database Control . . . . . . . . 910Using the SQL Access Advisor with DBMS_ADVISOR . . . . . . . . 913
Identifying and Fixing Invalid and Unusable Objects . . . . . . . . . . . . . 916Invalid Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916Unusable Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
Database Replay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 921Database Replay Workload Capture . . . . . . . . . . . . . . . . . . . . . . 921Database Replay Workload Preprocessing . . . . . . . . . . . . . . . . . . 922Launch the Replay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 923Database Replay Analysis and Reporting . . . . . . . . . . . . . . . . . . . 924
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927Use Automatic Memory Management . . . . . . . . . . . . . . . . . . . . . 927Use Memory Advisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928Troubleshoot Invalid and Unusable Objects . . . . . . . . . . . . . . . 928Implement Automatic Memory Management . . . . . . . . . . . . . . . 928Manually Configure SGA Parameters . . . . . . . . . . . . . . . . . . . . . 928Configure Automatic PGA Memory Management . . . . . . . . . . . 929Use the SQL Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929Use the SQL Access Advisor to Tune a Workload . . . . . . . . . . . . 929Understand Database Replay . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933
Chapter 26 Globalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937Globalization Requirements and Capabilities . . . . . . . . . . . . . . . . . . . 938
Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938Language Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940Territory Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942Other NLS Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 944
Using Globalization Support Features . . . . . . . . . . . . . . . . . . . . . . . . . . 944Choosing a Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945Changing Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 946Globalization Within the Database . . . . . . . . . . . . . . . . . . . . . . . 947Globalization at the Instance Level . . . . . . . . . . . . . . . . . . . . . . . 948Client-Side Environment Settings . . . . . . . . . . . . . . . . . . . . . . . . 948Session-Level Globalization Settings . . . . . . . . . . . . . . . . . . . . . . 950Statement Globalization Settings . . . . . . . . . . . . . . . . . . . . . . . . . 951
Languages and Time Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 952Linguistic Sorting and Selection . . . . . . . . . . . . . . . . . . . . . . . . . . 953The Locale Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954Using Time Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954
FM.indd xxviFM.indd xxvi 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM
Contents
xxvii
All-in-1 / OCA/OCP Oracle Database 11g All-in-One / Watson, Ramklass / 162-918-1
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957Customize Language-Dependent Behavior for the Database
and Individual Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957Work with Database and NLS Character Sets . . . . . . . . . . . . . . . 958
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 961
Chapter 27 The Intelligent Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 965Exam Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 965The Enterprise Manager Support Workbench . . . . . . . . . . . . . . . . . . . . 966
The Automatic Diagnostic Repository (ADR) . . . . . . . . . . . . . . . 966Problems and Incidents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 967The ADR Command-Line Interface (ADRCI) . . . . . . . . . . . . . . . 967The Support Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968
Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 971Types of Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 971Integration with MetaLink and the Patch Advisor . . . . . . . . . . . 971Applying Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 972
Two-Minute Drill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978Use the Enterprise Manager Support Workbench . . . . . . . . . . . . 978Manage Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978Set Up the Automatic Diagnostic Repository . . . . . . . . . . . . . . . 979
Self Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979Self Test Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 980
Appendix About the CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984Installing and Running MasterExam . . . . . . . . . . . . . . . . . . . . . . . . . . . 984
MasterExam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984Electronic Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984Removing Installation(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985
LearnKey Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
FM.indd xxviiFM.indd xxvii 7/16/2009 2:08:18 PM7/16/2009 2:08:18 PM