Upload
dokiet
View
234
Download
2
Embed Size (px)
Citation preview
Pro Oracle Database 12c Administration
Second Edition
Darl Kuhn
Pro Oracle Database 12c Administration
Copyright © 2013 by Darl Kuhn
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
ISBN-13 (pbk): 978-1-4302-5728-8
ISBN-13 (electronic): 978-1-4302-5729-5
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
President and Publisher: Paul ManningLead Editor: Jonathan GennickTechnical Reviewers: Bernard Lopuz, Fuad Arshad, Bill PadfieldEditorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan Ertel,
Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh
Coordinating Editor: Kevin SheaCopy Editor: Lisa VecchioneCompositor: SPi GlobalIndexer: SPi GlobalArtist: SPi GlobalCover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text are available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code.
To Brandi, Lisa, and Heidi.
—Darl Kuhn
v
Contents at a Glance
About the Author ����������������������������������������������������������������������������������������������������������� xxxiii
About the Technical Reviewers �������������������������������������������������������������������������������������� xxxv
Acknowledgments �������������������������������������������������������������������������������������������������������� xxxvii
Introduction ������������������������������������������������������������������������������������������������������������������� xxxix
Chapter 1: Installing the Oracle Binaries ■ ���������������������������������������������������������������������������1
Chapter 2: Implementing a Database ■ ������������������������������������������������������������������������������25
Chapter 3: Configuring an Efficient Environment ■ ������������������������������������������������������������55
Chapter 4: Tablespaces and Data Files ■ ����������������������������������������������������������������������������77
Chapter 5: Managing Control Files, Online Redo Logs, and Archiving ■ �����������������������������99
Chapter 6: Users and Basic Security ■ �����������������������������������������������������������������������������127
Chapter 7: Tables and Constraints ■ ���������������������������������������������������������������������������������153
Chapter 8: Indexes ■ ���������������������������������������������������������������������������������������������������������205
Chapter 9: Views, Synonyms, and Sequences ■ ���������������������������������������������������������������237
Chapter 10: Data Dictionary Fundamentals ■ �������������������������������������������������������������������259
Chapter 11: Large Objects ■ ���������������������������������������������������������������������������������������������277
Chapter 12: Partitioning: Divide and Conquer ■ ���������������������������������������������������������������303
Chapter 13: Data Pump ■ ��������������������������������������������������������������������������������������������������343
Chapter 14: External Tables ■ �������������������������������������������������������������������������������������������387
Chapter 15: Materialized Views ■ �������������������������������������������������������������������������������������403
Chapter 16: User-Managed Backup and Recovery ■ ��������������������������������������������������������451
■ Contents at a GlanCe
vi
Chapter 17: Configuring RMAN ■ ��������������������������������������������������������������������������������������483
Chapter 18: RMAN Backups and Reporting ■ �������������������������������������������������������������������511
Chapter 19: RMAN Restore and Recovery ■ ���������������������������������������������������������������������539
Chapter 20: Oracle Secure Backup ■ ��������������������������������������������������������������������������������585
Chapter 21: Automating Jobs ■ ����������������������������������������������������������������������������������������613
Chapter 22: Database Troubleshooting ■ ��������������������������������������������������������������������������637
Chapter 23: Pluggable Databases ■ ���������������������������������������������������������������������������������667
Index ���������������������������������������������������������������������������������������������������������������������������������699
vii
Contents
About the Author ����������������������������������������������������������������������������������������������������������� xxxiii
About the Technical Reviewers �������������������������������������������������������������������������������������� xxxv
Acknowledgments �������������������������������������������������������������������������������������������������������� xxxvii
Introduction ������������������������������������������������������������������������������������������������������������������� xxxix
Chapter 1: Installing the Oracle Binaries ■ ���������������������������������������������������������������������������1
Understanding the OFA ������������������������������������������������������������������������������������������������������������������1
Oracle Inventory Directory ������������������������������������������������������������������������������������������������������������������������������������� 3
Oracle Base Directory �������������������������������������������������������������������������������������������������������������������������������������������� 3
Oracle Home Directory ������������������������������������������������������������������������������������������������������������������������������������������ 3
Oracle Network Files Directory ������������������������������������������������������������������������������������������������������������������������������ 4
Automatic Diagnostic Repository �������������������������������������������������������������������������������������������������������������������������� 4
Installing Oracle ����������������������������������������������������������������������������������������������������������������������������5
Step 1� Create the OS Groups and User ����������������������������������������������������������������������������������������������������������������� 5
Step 2� Ensure That the OS Is Adequately Configured ������������������������������������������������������������������������������������������� 7
Step 3� Obtain the Oracle Installation Software ����������������������������������������������������������������������������������������������������� 8
Step 4� Unzip the Files ������������������������������������������������������������������������������������������������������������������������������������������� 8
Step 5: Creating oraInst�loc File ����������������������������������������������������������������������������������������������������������������������������� 9
Step 6� Configure the Response File, and Run the Installer ��������������������������������������������������������������������������������� 10
Step 7� Troubleshoot Any Issues �������������������������������������������������������������������������������������������������������������������������� 13
Installing with a Copy of an Existing Installation �������������������������������������������������������������������������14
Step 1� Copy the Binaries, Using an OS Utility ����������������������������������������������������������������������������������������������������� 15
Step 2� Attach the Oracle Home ��������������������������������������������������������������������������������������������������������������������������� 16
■ Contents
viii
Upgrading Oracle Software ���������������������������������������������������������������������������������������������������������17
Reinstalling After Failed Installation ��������������������������������������������������������������������������������������������18
Applying Interim Patches ������������������������������������������������������������������������������������������������������������18
Installing Remotely with the Graphical Installer ��������������������������������������������������������������������������19
Step 1� Install X Software and Networking Utilities on the Local PC ������������������������������������������������������������������� 20
Step 2� Start an X Session on the Local Computer ���������������������������������������������������������������������������������������������� 21
Step 3� Copy the Oracle Installation Media to the Remote Server ����������������������������������������������������������������������� 21
Step 4� Run the xhost Command ������������������������������������������������������������������������������������������������������������������������� 22
Step 5� Log In to the Remote Computer from X ��������������������������������������������������������������������������������������������������� 22
Step 6� Ensure that the DISPLAY Variable Is Set Correctly on the Remote Computer ������������������������������������������ 22
Step 7� Execute the runInstaller Utility ���������������������������������������������������������������������������������������������������������������� 23
Step 8� Troubleshoot �������������������������������������������������������������������������������������������������������������������������������������������� 24
Summary �������������������������������������������������������������������������������������������������������������������������������������24
Chapter 2: Implementing a Database ■ ������������������������������������������������������������������������������25
Setting OS Variables ��������������������������������������������������������������������������������������������������������������������25
A Manually Intensive Approach ��������������������������������������������������������������������������������������������������������������������������� 26
Oracle’s Approach to Setting OS Variables ���������������������������������������������������������������������������������������������������������� 26
My Approach to Setting OS Variables ������������������������������������������������������������������������������������������������������������������ 28
Creating a Database ��������������������������������������������������������������������������������������������������������������������29
Step 1� Set the OS Variables �������������������������������������������������������������������������������������������������������������������������������� 30
Step 2: Configure the Initialization File ���������������������������������������������������������������������������������������������������������������� 30
Step 3: Create the Required Directories �������������������������������������������������������������������������������������������������������������� 32
Step 4: Create the Database �������������������������������������������������������������������������������������������������������������������������������� 32
Step 5� Create a Data Dictionary ������������������������������������������������������������������������������������������������������������������������� 36
Configuring and Implementing the Listener ��������������������������������������������������������������������������������37
Manually Configuring a Listener �������������������������������������������������������������������������������������������������������������������������� 37
Implementing a Listener with the Net Configuration Assistant ��������������������������������������������������������������������������� 39
Connecting to a Database through the Network �������������������������������������������������������������������������������������������������� 39
Creating a Password File �������������������������������������������������������������������������������������������������������������40
■ Contents
ix
Starting and Stopping the Database �������������������������������������������������������������������������������������������41
Understanding OS Authentication ������������������������������������������������������������������������������������������������������������������������ 42
Starting the Database ������������������������������������������������������������������������������������������������������������������������������������������ 42
Stopping the Database ���������������������������������������������������������������������������������������������������������������������������������������� 45
Using the dbca to Create a Database ������������������������������������������������������������������������������������������46
Dropping a Database �������������������������������������������������������������������������������������������������������������������48
How Many Databases on One Server? ����������������������������������������������������������������������������������������49
Understanding Oracle Architecture ���������������������������������������������������������������������������������������������52
Summary �������������������������������������������������������������������������������������������������������������������������������������53
Chapter 3: Configuring an Efficient Environment ■ ������������������������������������������������������������55
Customizing Your OS Command Prompt �������������������������������������������������������������������������������������56
Customizing Your SQL Prompt �����������������������������������������������������������������������������������������������������58
Creating Shortcuts for Frequently Used Commands �������������������������������������������������������������������59
Using Aliases ������������������������������������������������������������������������������������������������������������������������������������������������������� 59
Using a Function �������������������������������������������������������������������������������������������������������������������������������������������������� 60
Rerunning Commands Quickly ����������������������������������������������������������������������������������������������������62
Scrolling with the Up and Down Arrow Keys ������������������������������������������������������������������������������������������������������� 62
Using Ctrl+P and Ctrl+N �������������������������������������������������������������������������������������������������������������������������������������� 62
Listing the Command History ������������������������������������������������������������������������������������������������������������������������������ 63
Searching in Reverse ������������������������������������������������������������������������������������������������������������������������������������������� 63
Setting the Command Editor �������������������������������������������������������������������������������������������������������������������������������� 63
Developing Standard Scripts �������������������������������������������������������������������������������������������������������64
dba_setup ������������������������������������������������������������������������������������������������������������������������������������������������������������ 65
dba_fcns �������������������������������������������������������������������������������������������������������������������������������������������������������������� 65
tbsp_chk�bsh ������������������������������������������������������������������������������������������������������������������������������������������������������� 66
conn�bsh �������������������������������������������������������������������������������������������������������������������������������������������������������������� 68
filesp�bsh ������������������������������������������������������������������������������������������������������������������������������������������������������������� 69
login�sql ��������������������������������������������������������������������������������������������������������������������������������������������������������������� 71
top�sql ������������������������������������������������������������������������������������������������������������������������������������������������������������������ 71
lock�sql ���������������������������������������������������������������������������������������������������������������������������������������������������������������� 72
users�sql �������������������������������������������������������������������������������������������������������������������������������������������������������������� 74
■ Contents
x
Organizing Scripts �����������������������������������������������������������������������������������������������������������������������74
Step 1: Create Directories ����������������������������������������������������������������������������������������������������������������������������������� 75
Step 2: Copy Files to Directories �������������������������������������������������������������������������������������������������������������������������� 75
Step 3: Configure the Startup File������������������������������������������������������������������������������������������������������������������������ 75
Summary �������������������������������������������������������������������������������������������������������������������������������������76
Chapter 4: Tablespaces and Data Files ■ ����������������������������������������������������������������������������77
Understanding the First Five �������������������������������������������������������������������������������������������������������78
Understanding the Need for More �����������������������������������������������������������������������������������������������78
Creating Tablespaces ������������������������������������������������������������������������������������������������������������������79
Renaming a Tablespace ��������������������������������������������������������������������������������������������������������������82
Controlling the Generation of Redo ���������������������������������������������������������������������������������������������83
Changing a Tablespace’s Write Mode ������������������������������������������������������������������������������������������84
Dropping a Tablespace ����������������������������������������������������������������������������������������������������������������84
Using Oracle Managed Files ��������������������������������������������������������������������������������������������������������86
Creating a Bigfile Tablespace �����������������������������������������������������������������������������������������������������87
Enabling Default Table Compression within a Tablespace ����������������������������������������������������������88
Displaying Tablespace Size ���������������������������������������������������������������������������������������������������������89
Altering Tablespace Size �������������������������������������������������������������������������������������������������������������90
Toggling Data Files Offline and Online �����������������������������������������������������������������������������������������91
Renaming or Relocating a Data File ��������������������������������������������������������������������������������������������93
Performing Online Data File Operations �������������������������������������������������������������������������������������������������������������� 93
Performing Offline Data File Operations �������������������������������������������������������������������������������������������������������������� 94
Summary �������������������������������������������������������������������������������������������������������������������������������������98
Chapter 5: Managing Control Files, Online Redo Logs, and Archiving ■ �����������������������������99
Managing Control Files����������������������������������������������������������������������������������������������������������������99
Viewing Control File Names and Locations ������������������������������������������������������������������������������������������������������� 102
Adding a Control File ����������������������������������������������������������������������������������������������������������������������������������������� 102
Moving a Control File ����������������������������������������������������������������������������������������������������������������������������������������� 105
Removing a Control File ������������������������������������������������������������������������������������������������������������������������������������� 106
■ Contents
xi
Managing Online Redo Logs ������������������������������������������������������������������������������������������������������106
Displaying Online Redo Log Information ������������������������������������������������������������������������������������������������������������ 109
Determining the Optimal Size of Online Redo Log Groups �������������������������������������������������������������������������������� 110
Determining the Optimal Number of Redo Log Groups�������������������������������������������������������������������������������������� 112
Adding Online Redo Log Groups ������������������������������������������������������������������������������������������������������������������������ 113
Resizing and Dropping Online Redo Log Groups ����������������������������������������������������������������������������������������������� 114
Adding Online Redo Log Files to a Group ���������������������������������������������������������������������������������������������������������� 115
Removing Online Redo Log Files from a Group ������������������������������������������������������������������������������������������������� 115
Moving or Renaming Redo Log Files ����������������������������������������������������������������������������������������������������������������� 116
Implementing Archivelog Mode �������������������������������������������������������������������������������������������������117
Making Architectural Decisions ������������������������������������������������������������������������������������������������������������������������� 117
Setting the Archive Redo File Location �������������������������������������������������������������������������������������������������������������� 118
Thinking “Un-Oraclethodox” FRA Thoughts ������������������������������������������������������������������������������������������������������� 122
Enabling Archivelog Mode ��������������������������������������������������������������������������������������������������������������������������������� 123
Disabling Archivelog Mode �������������������������������������������������������������������������������������������������������������������������������� 123
Reacting to a Lack of Disk Space in Your Archive Log Destination �������������������������������������������������������������������� 124
Backing Up Archive Redo Log Files ������������������������������������������������������������������������������������������������������������������� 125
Summary �����������������������������������������������������������������������������������������������������������������������������������125
Chapter 6: Users and Basic Security ■ �����������������������������������������������������������������������������127
Managing Default Users ������������������������������������������������������������������������������������������������������������127
Locking Accounts and Expiring Passwords ������������������������������������������������������������������������������������������������������� 128
Identifying DBA-Created Accounts ��������������������������������������������������������������������������������������������������������������������� 130
Checking Default Passwords ����������������������������������������������������������������������������������������������������������������������������� 131
Creating Users ���������������������������������������������������������������������������������������������������������������������������132
Choosing a Username and Authentication Method �������������������������������������������������������������������������������������������� 132
Assigning Default Permanent and Temporary Tablespaces ������������������������������������������������������������������������������� 135
Modifying Passwords ����������������������������������������������������������������������������������������������������������������137
Logging In as a Different User ���������������������������������������������������������������������������������������������������138
Modifying Users ������������������������������������������������������������������������������������������������������������������������139
Dropping Users ��������������������������������������������������������������������������������������������������������������������������140
■ Contents
xii
Enforcing Password Security and Resource Limits �������������������������������������������������������������������141
Basic Password Security ����������������������������������������������������������������������������������������������������������������������������������� 142
Password Strength �������������������������������������������������������������������������������������������������������������������������������������������� 144
Limiting Database Resource Usage ������������������������������������������������������������������������������������������������������������������� 145
Managing Privileges ������������������������������������������������������������������������������������������������������������������147
Assigning Database System Privileges�������������������������������������������������������������������������������������������������������������� 147
Assigning Database Object Privileges ��������������������������������������������������������������������������������������������������������������� 148
Grouping and Assigning Privileges �������������������������������������������������������������������������������������������������������������������� 149
Summary �����������������������������������������������������������������������������������������������������������������������������������151
Chapter 7: Tables and Constraints ■ ���������������������������������������������������������������������������������153
Understanding Table Types ��������������������������������������������������������������������������������������������������������153
Understanding Data Types ���������������������������������������������������������������������������������������������������������154
Character ����������������������������������������������������������������������������������������������������������������������������������������������������������� 155
Numeric ������������������������������������������������������������������������������������������������������������������������������������������������������������� 156
Date/Time ���������������������������������������������������������������������������������������������������������������������������������������������������������� 157
RAW ������������������������������������������������������������������������������������������������������������������������������������������������������������������� 158
ROWID ���������������������������������������������������������������������������������������������������������������������������������������������������������������� 158
LOB �������������������������������������������������������������������������������������������������������������������������������������������������������������������� 159
Extended Character Types ��������������������������������������������������������������������������������������������������������������������������������� 159
Creating a Table �������������������������������������������������������������������������������������������������������������������������160
Creating a Heap-Organized Table ���������������������������������������������������������������������������������������������������������������������� 161
Implementing Virtual Columns ��������������������������������������������������������������������������������������������������������������������������� 164
Implementing Invisible Columns ����������������������������������������������������������������������������������������������������������������������� 166
Making Read-Only Tables ���������������������������������������������������������������������������������������������������������������������������������� 167
Understanding Deferred Segment Creation ������������������������������������������������������������������������������������������������������� 167
Creating a Table with an Autoincrementing (Identity) Column ��������������������������������������������������������������������������� 169
Allowing for Default Parallel SQL Execution ������������������������������������������������������������������������������������������������������ 171
Compressing Table Data ������������������������������������������������������������������������������������������������������������������������������������ 172
Avoiding Redo Creation ������������������������������������������������������������������������������������������������������������������������������������� 174
Creating a Table from a Query ��������������������������������������������������������������������������������������������������������������������������� 176
■ Contents
xiii
Modifying a Table ����������������������������������������������������������������������������������������������������������������������178
Obtaining the Needed Lock ������������������������������������������������������������������������������������������������������������������������������� 178
Renaming a Table ���������������������������������������������������������������������������������������������������������������������������������������������� 179
Adding a Column ����������������������������������������������������������������������������������������������������������������������������������������������� 179
Altering a Column ���������������������������������������������������������������������������������������������������������������������������������������������� 179
Renaming a Column ������������������������������������������������������������������������������������������������������������������������������������������ 181
Dropping a Column �������������������������������������������������������������������������������������������������������������������������������������������� 181
Displaying Table DDL �����������������������������������������������������������������������������������������������������������������182
Dropping a Table ������������������������������������������������������������������������������������������������������������������������183
Undropping a Table ��������������������������������������������������������������������������������������������������������������������184
Removing Data from a Table �����������������������������������������������������������������������������������������������������185
Using DELETE ���������������������������������������������������������������������������������������������������������������������������������������������������� 185
Using TRUNCATE ������������������������������������������������������������������������������������������������������������������������������������������������ 185
Viewing and Adjusting the High-Water Mark�����������������������������������������������������������������������������186
You need to be aware of a couple of performance-related issues regarding the high-water mark �������������������������������������������������������������������������������������������������������������������������186
Tracing to Detect Space Below the High-Water Mark ��������������������������������������������������������������������������������������� 187
Using DBMS_SPACE to Detect Space Below the High-Water Mark ������������������������������������������������������������������� 188
Selecting from Data Dictionary Extents View ���������������������������������������������������������������������������������������������������� 189
Lowering the High-Water Mark ������������������������������������������������������������������������������������������������������������������������� 190
Creating a Temporary Table �������������������������������������������������������������������������������������������������������192
Creating an Index-Organized Table �������������������������������������������������������������������������������������������193
Managing Constraints ���������������������������������������������������������������������������������������������������������������194
Creating Primary Key Constraints ���������������������������������������������������������������������������������������������������������������������� 194
Enforcing Unique Key Values ����������������������������������������������������������������������������������������������������������������������������� 196
Creating Foreign Key Constraints ���������������������������������������������������������������������������������������������������������������������� 197
Checking for Specific Data Conditions �������������������������������������������������������������������������������������������������������������� 199
Enforcing Not Null Conditions ���������������������������������������������������������������������������������������������������������������������������� 200
Disabling Constraints ����������������������������������������������������������������������������������������������������������������������������������������� 200
Enabling Constraints ������������������������������������������������������������������������������������������������������������������������������������������ 202
Summary �����������������������������������������������������������������������������������������������������������������������������������204
■ Contents
xiv
Chapter 8: Indexes ■ ���������������������������������������������������������������������������������������������������������205
Deciding When to Create an Index ��������������������������������������������������������������������������������������������206
Proactively Creating Indexes ����������������������������������������������������������������������������������������������������������������������������� 206
Reactively Creating Indexes ������������������������������������������������������������������������������������������������������������������������������ 206
Planning for Robustness �����������������������������������������������������������������������������������������������������������207
Determining Which Type of Index to Use ����������������������������������������������������������������������������������������������������������� 208
Estimating the Size of an Index Before Creation ����������������������������������������������������������������������������������������������� 209
Creating Separate Tablespaces for Indexes ������������������������������������������������������������������������������������������������������� 211
Creating Portable Scripts ����������������������������������������������������������������������������������������������������������������������������������� 213
Establishing Naming Standards������������������������������������������������������������������������������������������������������������������������� 213
Creating Indexes������������������������������������������������������������������������������������������������������������������������214
Creating B-tree Indexes ������������������������������������������������������������������������������������������������������������������������������������� 214
Creating Concatenated Indexes ������������������������������������������������������������������������������������������������������������������������� 217
Implementing Function-Based Indexes ������������������������������������������������������������������������������������������������������������� 218
Creating Unique Indexes ������������������������������������������������������������������������������������������������������������������������������������ 219
Implementing Bitmap Indexes ��������������������������������������������������������������������������������������������������������������������������� 220
Creating Bitmap Join Indexes ���������������������������������������������������������������������������������������������������������������������������� 221
Implementing Reverse-Key Indexes ������������������������������������������������������������������������������������������������������������������ 222
Creating Key-Compressed Indexes �������������������������������������������������������������������������������������������������������������������� 223
Parallelizing Index Creation ������������������������������������������������������������������������������������������������������������������������������� 223
Avoiding Redo Generation When Creating an Index ������������������������������������������������������������������������������������������� 224
Implementing Invisible Indexes ������������������������������������������������������������������������������������������������������������������������� 224
Maintaining Indexes ������������������������������������������������������������������������������������������������������������������226
Renaming an Index �������������������������������������������������������������������������������������������������������������������������������������������� 226
Displaying Code to Recreate an Index ��������������������������������������������������������������������������������������������������������������� 227
Rebuilding an Index ������������������������������������������������������������������������������������������������������������������������������������������� 227
Making Indexes Unusable ���������������������������������������������������������������������������������������������������������������������������������� 228
Monitoring Index Usage ������������������������������������������������������������������������������������������������������������������������������������� 229
Dropping an Index ��������������������������������������������������������������������������������������������������������������������������������������������� 230
■ Contents
xv
Indexing Foreign Key Columns ��������������������������������������������������������������������������������������������������230
Implementing an Index on a Foreign Key Column ��������������������������������������������������������������������������������������������� 231
Determining if Foreign Key Columns Are Indexed ��������������������������������������������������������������������������������������������� 232
Summary �����������������������������������������������������������������������������������������������������������������������������������234
Chapter 9: Views, Synonyms, and Sequences ■ ���������������������������������������������������������������237
Implementing Views ������������������������������������������������������������������������������������������������������������������237
Creating a View �������������������������������������������������������������������������������������������������������������������������������������������������� 237
Checking Updates ���������������������������������������������������������������������������������������������������������������������������������������������� 239
Creating Read-Only Views ��������������������������������������������������������������������������������������������������������������������������������� 240
Updatable Join Views ���������������������������������������������������������������������������������������������������������������������������������������� 240
Creating an INSTEAD OF Trigger ������������������������������������������������������������������������������������������������������������������������ 242
Implementing an Invisible Column �������������������������������������������������������������������������������������������������������������������� 243
Modifying a View Definition ������������������������������������������������������������������������������������������������������������������������������� 244
Displaying the SQL Used to Create a View ��������������������������������������������������������������������������������������������������������� 245
Renaming a View ����������������������������������������������������������������������������������������������������������������������������������������������� 246
Dropping a View ������������������������������������������������������������������������������������������������������������������������������������������������� 247
Managing Synonyms �����������������������������������������������������������������������������������������������������������������247
Creating a Synonym ������������������������������������������������������������������������������������������������������������������������������������������ 248
Creating Public Synonyms ��������������������������������������������������������������������������������������������������������������������������������� 248
Dynamically Generating Synonyms ������������������������������������������������������������������������������������������������������������������� 249
Displaying Synonym Metadata �������������������������������������������������������������������������������������������������������������������������� 250
Renaming a Synonym ���������������������������������������������������������������������������������������������������������������������������������������� 250
Dropping a Synonym ����������������������������������������������������������������������������������������������������������������������������������������� 251
Managing Sequences ����������������������������������������������������������������������������������������������������������������251
Creating a Sequence ����������������������������������������������������������������������������������������������������������������������������������������� 251
Using Sequence Pseudocolumns ���������������������������������������������������������������������������������������������������������������������� 252
Autoincrementing Columns ������������������������������������������������������������������������������������������������������������������������������� 253
Implementing Multiple Sequences That Generate Unique Values ��������������������������������������������������������������������� 254
Creating One Sequence or Many ����������������������������������������������������������������������������������������������������������������������� 255
Viewing Sequence Metadata ����������������������������������������������������������������������������������������������������������������������������� 255
Renaming a Sequence ��������������������������������������������������������������������������������������������������������������������������������������� 256
■ Contents
xvi
Dropping a Sequence ���������������������������������������������������������������������������������������������������������������������������������������� 256
Resetting a Sequence ���������������������������������������������������������������������������������������������������������������������������������������� 256
Summary �����������������������������������������������������������������������������������������������������������������������������������258
Chapter 10: Data Dictionary Fundamentals ■ �������������������������������������������������������������������259
Data Dictionary Architecture �����������������������������������������������������������������������������������������������������259
Static Views ������������������������������������������������������������������������������������������������������������������������������������������������������� 260
Dynamic Performance Views ����������������������������������������������������������������������������������������������������������������������������� 262
A Different View of Metadata�����������������������������������������������������������������������������������������������������263
A Few Creative Uses of the Data Dictionary ������������������������������������������������������������������������������266
Derivable Documentation ���������������������������������������������������������������������������������������������������������������������������������� 266
Displaying User Information ������������������������������������������������������������������������������������������������������������������������������ 267
Displaying Table Row Counts ����������������������������������������������������������������������������������������������������������������������������� 270
Showing Primary Key and Foreign Key Relationships ��������������������������������������������������������������������������������������� 272
Displaying Object Dependencies ����������������������������������������������������������������������������������������������������������������������� 273
Summary �����������������������������������������������������������������������������������������������������������������������������������275
Chapter 11: Large Objects ■ ���������������������������������������������������������������������������������������������277
Describing LOB Types ����������������������������������������������������������������������������������������������������������������277
Illustrating LOB Locators, Indexes, and Chunks ������������������������������������������������������������������������278
Distinguishing Between BasicFiles and SecureFiles �����������������������������������������������������������������280
BasicFiles ���������������������������������������������������������������������������������������������������������������������������������������������������������� 280
SecureFiles �������������������������������������������������������������������������������������������������������������������������������������������������������� 280
Creating a Table with a LOB Column �����������������������������������������������������������������������������������������281
Creating a BasicFiles LOB Column �������������������������������������������������������������������������������������������������������������������� 281
Implementing a LOB in a Specific Tablespace ��������������������������������������������������������������������������������������������������� 283
Creating a SecureFiles LOB Column ������������������������������������������������������������������������������������������������������������������ 284
Implementing a Partitioned LOB ������������������������������������������������������������������������������������������������������������������������ 285
Maintaining LOB Columns ���������������������������������������������������������������������������������������������������������286
Moving a LOB Column ��������������������������������������������������������������������������������������������������������������������������������������� 286
Adding a LOB Column ���������������������������������������������������������������������������������������������������������������������������������������� 287
Removing a LOB Column ����������������������������������������������������������������������������������������������������������������������������������� 287
■ Contents
xvii
Caching LOBs����������������������������������������������������������������������������������������������������������������������������������������������������� 287
Storing LOBs In- and Out of Line ����������������������������������������������������������������������������������������������������������������������� 288
Implementing SecureFiles Advanced Features �������������������������������������������������������������������������289
Compressing LOBs �������������������������������������������������������������������������������������������������������������������������������������������� 289
Deduplicating LOBs ������������������������������������������������������������������������������������������������������������������������������������������� 290
Encrypting LOBs ������������������������������������������������������������������������������������������������������������������������������������������������ 291
Migrating BasicFiles to SecureFiles ������������������������������������������������������������������������������������������������������������������ 293
Loading LOBs ����������������������������������������������������������������������������������������������������������������������������296
Loading a CLOB ������������������������������������������������������������������������������������������������������������������������������������������������� 296
Loading a BLOB ������������������������������������������������������������������������������������������������������������������������������������������������� 298
Measuring LOB Space Consumed ���������������������������������������������������������������������������������������������299
BasicFiles Space Used��������������������������������������������������������������������������������������������������������������������������������������� 299
SecureFiles Space Used ������������������������������������������������������������������������������������������������������������������������������������ 300
Reading BFILEs �������������������������������������������������������������������������������������������������������������������������301
Summary �����������������������������������������������������������������������������������������������������������������������������������302
Chapter 12: Partitioning: Divide and Conquer ■ ���������������������������������������������������������������303
What Tables Should Be Partitioned? ������������������������������������������������������������������������������������������304
Creating Partitioned Tables �������������������������������������������������������������������������������������������������������305
Partitioning by Range ���������������������������������������������������������������������������������������������������������������������������������������� 306
Placing Partitions in Tablespaces ���������������������������������������������������������������������������������������������������������������������� 309
Partitioning by List ��������������������������������������������������������������������������������������������������������������������������������������������� 313
Partitioning by Hash ������������������������������������������������������������������������������������������������������������������������������������������ 313
Blending Different Partitioning Methods ����������������������������������������������������������������������������������������������������������� 314
Creating Partitions on Demand �������������������������������������������������������������������������������������������������������������������������� 316
Partitioning to Match a Parent Table ������������������������������������������������������������������������������������������������������������������ 319
Partitioning on a Virtual Column ������������������������������������������������������������������������������������������������������������������������ 322
Giving an Application Control over Partitioning ������������������������������������������������������������������������������������������������� 322
Maintaining Partitions ���������������������������������������������������������������������������������������������������������������323
Viewing Partition Metadata ������������������������������������������������������������������������������������������������������������������������������� 323
Moving a Partition ���������������������������������������������������������������������������������������������������������������������������������������������� 324
Automatically Moving Updated Rows ���������������������������������������������������������������������������������������������������������������� 325
■ Contents
xviii
Partitioning an Existing Table ���������������������������������������������������������������������������������������������������������������������������� 326
Adding a Partition ���������������������������������������������������������������������������������������������������������������������������������������������� 327
Exchanging a Partition with an Existing Table ��������������������������������������������������������������������������������������������������� 329
Renaming a Partition ����������������������������������������������������������������������������������������������������������������������������������������� 330
Splitting a Partition �������������������������������������������������������������������������������������������������������������������������������������������� 331
Merging Partitions ��������������������������������������������������������������������������������������������������������������������������������������������� 331
Dropping a Partition ������������������������������������������������������������������������������������������������������������������������������������������� 332
Generating Statistics for a Partition ������������������������������������������������������������������������������������������������������������������� 333
Removing Rows from a Partition ����������������������������������������������������������������������������������������������������������������������� 334
Manipulating Data Within a Partition ����������������������������������������������������������������������������������������������������������������� 335
Partitioning Indexes �������������������������������������������������������������������������������������������������������������������335
Partitioning an Index to Follow Its Table ������������������������������������������������������������������������������������������������������������ 335
Partitioning an Index Differently from Its Table ������������������������������������������������������������������������������������������������� 338
Partial Indexes ��������������������������������������������������������������������������������������������������������������������������������������������������� 340
Partition Pruning �����������������������������������������������������������������������������������������������������������������������341
Summary �����������������������������������������������������������������������������������������������������������������������������������342
Chapter 13: Data Pump ■ ��������������������������������������������������������������������������������������������������343
Data Pump Architecture ������������������������������������������������������������������������������������������������������������344
Getting Started ��������������������������������������������������������������������������������������������������������������������������346
Taking an Export ������������������������������������������������������������������������������������������������������������������������������������������������ 347
Importing a Table ����������������������������������������������������������������������������������������������������������������������������������������������� 349
Using a Parameter File �������������������������������������������������������������������������������������������������������������������������������������� 349
Exporting and Importing with Granularity ���������������������������������������������������������������������������������350
Exporting and Importing an Entire Database ����������������������������������������������������������������������������������������������������� 350
Schema Level ���������������������������������������������������������������������������������������������������������������������������������������������������� 352
Table Level ��������������������������������������������������������������������������������������������������������������������������������������������������������� 353
Tablespace Level ����������������������������������������������������������������������������������������������������������������������������������������������� 353
Transferring Data �����������������������������������������������������������������������������������������������������������������������354
Exporting and Importing Directly Across the Network ��������������������������������������������������������������������������������������� 354
Copying Data Files ��������������������������������������������������������������������������������������������������������������������������������������������� 356
■ Contents
xix
Features for Manipulating Storage ��������������������������������������������������������������������������������������������358
Exporting Tablespace Metadata ������������������������������������������������������������������������������������������������������������������������� 358
Specifying Different Data File Paths and Names ����������������������������������������������������������������������������������������������� 358
Importing into a Tablespace Different from the Original ������������������������������������������������������������������������������������ 359
Changing the Size of Data Files ������������������������������������������������������������������������������������������������������������������������� 359
Changing Segment and Storage Attributes ������������������������������������������������������������������������������������������������������� 360
Filtering Data and Objects ���������������������������������������������������������������������������������������������������������360
Specifying a Query �������������������������������������������������������������������������������������������������������������������������������������������� 361
Exporting a Percentage of the Data ������������������������������������������������������������������������������������������������������������������� 362
Excluding Objects from the Export File �������������������������������������������������������������������������������������������������������������� 362
Excluding Statistics ������������������������������������������������������������������������������������������������������������������������������������������� 363
Including Only Specific Objects in an Export File ���������������������������������������������������������������������������������������������� 364
Exporting Table, Index, Constraint, and Trigger DDL ������������������������������������������������������������������������������������������ 364
Excluding Objects from Import �������������������������������������������������������������������������������������������������������������������������� 364
Including Objects in Import �������������������������������������������������������������������������������������������������������������������������������� 365
Common Data Pump Tasks ��������������������������������������������������������������������������������������������������������365
Estimating the Size of Export Jobs �������������������������������������������������������������������������������������������������������������������� 365
Listing the Contents of Dump Files �������������������������������������������������������������������������������������������������������������������� 366
Cloning a User ��������������������������������������������������������������������������������������������������������������������������������������������������� 366
Creating a Consistent Export ����������������������������������������������������������������������������������������������������������������������������� 367
Importing When Objects Already Exist ��������������������������������������������������������������������������������������������������������������� 368
Renaming a Table ���������������������������������������������������������������������������������������������������������������������������������������������� 369
Remapping Data ������������������������������������������������������������������������������������������������������������������������������������������������ 370
Suppressing a Log File �������������������������������������������������������������������������������������������������������������������������������������� 371
Using Parallelism ����������������������������������������������������������������������������������������������������������������������������������������������� 371
Specifying Additional Dump Files ���������������������������������������������������������������������������������������������������������������������� 372
Reusing Output File Names ������������������������������������������������������������������������������������������������������������������������������� 372
Creating a Daily DDL File ����������������������������������������������������������������������������������������������������������������������������������� 373
Compressing Output ������������������������������������������������������������������������������������������������������������������������������������������ 374
Changing Table Compression Characteristics on Import ����������������������������������������������������������������������������������� 374
Encrypting Data ������������������������������������������������������������������������������������������������������������������������������������������������� 375
■ Contents
xx
Exporting Views As Tables ��������������������������������������������������������������������������������������������������������������������������������� 375
Disabling Logging of Redo on Import ���������������������������������������������������������������������������������������������������������������� 376
Interactive Command Mode ������������������������������������������������������������������������������������������������������376
Entering Interactive Command Mode ���������������������������������������������������������������������������������������������������������������� 376
Attaching to a Running Job ������������������������������������������������������������������������������������������������������������������������������� 378
Stopping and Restarting a Job �������������������������������������������������������������������������������������������������������������������������� 379
Terminating a Data Pump Job ��������������������������������������������������������������������������������������������������������������������������� 379
Monitoring Data Pump Jobs ������������������������������������������������������������������������������������������������������380
Data Pump Log File�������������������������������������������������������������������������������������������������������������������������������������������� 380
Data Dictionary Views ���������������������������������������������������������������������������������������������������������������������������������������� 380
Database Alert Log �������������������������������������������������������������������������������������������������������������������������������������������� 381
Status Table ������������������������������������������������������������������������������������������������������������������������������������������������������� 381
Interactive Command Mode Status ������������������������������������������������������������������������������������������������������������������� 381
OS Utilities ��������������������������������������������������������������������������������������������������������������������������������������������������������� 382
Data Pump Legacy Mode �����������������������������������������������������������������������������������������������������������382
Data Pump Mapping to the exp Utility ��������������������������������������������������������������������������������������������������������������� 383
Data Pump Mapping to the imp Utility ��������������������������������������������������������������������������������������������������������������� 384
Summary �����������������������������������������������������������������������������������������������������������������������������������385
Chapter 14: External Tables ■ �������������������������������������������������������������������������������������������387
SQL*Loader vs� External Tables �������������������������������������������������������������������������������������������������387
Loading CSV Files into the Database �����������������������������������������������������������������������������������������388
Creating a Directory Object and Granting Access ���������������������������������������������������������������������������������������������� 389
Creating an External Table ��������������������������������������������������������������������������������������������������������������������������������� 390
Generating SQL to Create an External Table ������������������������������������������������������������������������������������������������������ 391
Viewing External Table Metadata����������������������������������������������������������������������������������������������������������������������� 392
Loading a Regular Table from the External Table ���������������������������������������������������������������������������������������������� 393
Performing Advanced Transformations �������������������������������������������������������������������������������������394
Viewing Text Files from SQL ������������������������������������������������������������������������������������������������������396
■ Contents
xxi
Unloading and Loading Data Using an External Table ���������������������������������������������������������������397
Enabling Parallelism to Reduce Elapsed Time ��������������������������������������������������������������������������������������������������� 400
Compressing a Dump File ���������������������������������������������������������������������������������������������������������������������������������� 400
Encrypting a Dump File ������������������������������������������������������������������������������������������������������������������������������������� 401
Summary �����������������������������������������������������������������������������������������������������������������������������������402
Chapter 15: Materialized Views ■ �������������������������������������������������������������������������������������403
Understanding MVs �������������������������������������������������������������������������������������������������������������������403
MV Terminology ������������������������������������������������������������������������������������������������������������������������������������������������� 405
Referencing Useful Views ���������������������������������������������������������������������������������������������������������������������������������� 405
Creating Basic Materialized Views ��������������������������������������������������������������������������������������������406
Creating a Complete Refreshable MV ���������������������������������������������������������������������������������������������������������������� 406
Creating a Fast Refreshable MV ������������������������������������������������������������������������������������������������������������������������ 410
Going Beyond the Basics �����������������������������������������������������������������������������������������������������������414
Creating MVs and Specifying Tablespace for MVs and Indexes ������������������������������������������������������������������������ 414
Creating Indexes on MVs ����������������������������������������������������������������������������������������������������������������������������������� 415
Partitioning MVs ������������������������������������������������������������������������������������������������������������������������������������������������ 416
Compressing an MV ������������������������������������������������������������������������������������������������������������������������������������������� 416
Encrypting MV Columns������������������������������������������������������������������������������������������������������������������������������������� 417
Building an MV on a Prebuilt Table �������������������������������������������������������������������������������������������������������������������� 418
Creating an Unpopulated MV ����������������������������������������������������������������������������������������������������������������������������� 419
Creating an MV Refreshed on Commit ��������������������������������������������������������������������������������������������������������������� 419
Creating a Never Refreshable MV ���������������������������������������������������������������������������������������������������������������������� 420
Creating MVs for Query Rewrite ������������������������������������������������������������������������������������������������������������������������ 420
Creating a Fast Refreshable MV Based on a Complex Query ���������������������������������������������������������������������������� 421
Viewing MV DDL ������������������������������������������������������������������������������������������������������������������������������������������������ 424
Dropping an MV ������������������������������������������������������������������������������������������������������������������������������������������������� 424
Modifying MVs ���������������������������������������������������������������������������������������������������������������������������425
Modifying Base Table DDL and Propagating to MVs ������������������������������������������������������������������������������������������ 425
Toggling Redo Logging on an MV ���������������������������������������������������������������������������������������������������������������������� 428
Altering Parallelism ������������������������������������������������������������������������������������������������������������������������������������������� 429
Moving an MV ���������������������������������������������������������������������������������������������������������������������������������������������������� 429
■ Contents
xxii
Managing MV Logs ��������������������������������������������������������������������������������������������������������������������430
Creating an MV Log ������������������������������������������������������������������������������������������������������������������������������������������� 430
Indexing MV Log Columns ��������������������������������������������������������������������������������������������������������������������������������� 432
Viewing Space Used by an MV Log �������������������������������������������������������������������������������������������������������������������� 432
Shrinking the Space in an MV Log ��������������������������������������������������������������������������������������������������������������������� 432
Checking the Row Count of an MV Log �������������������������������������������������������������������������������������������������������������� 433
Moving an MV Log ��������������������������������������������������������������������������������������������������������������������������������������������� 433
Dropping an MV Log ������������������������������������������������������������������������������������������������������������������������������������������ 434
Refreshing MVs �������������������������������������������������������������������������������������������������������������������������435
Manually Refreshing MVs from SQL*Plus ���������������������������������������������������������������������������������������������������������� 435
Automating Refreshes, Using a Shell Script and Scheduling Utility ������������������������������������������������������������������ 436
Creating an MV with a Refresh Interval ������������������������������������������������������������������������������������������������������������� 437
Efficiently Performing a Complete Refresh �������������������������������������������������������������������������������������������������������� 438
Handling the ORA-12034 Error �������������������������������������������������������������������������������������������������������������������������� 439
Monitoring MV Refreshes ����������������������������������������������������������������������������������������������������������439
Viewing MVs’ Last Refresh Times ���������������������������������������������������������������������������������������������������������������������� 440
Determining Whether a Refresh Is in Progress �������������������������������������������������������������������������������������������������� 440
Monitoring Real-Time Refresh Progress ������������������������������������������������������������������������������������������������������������ 440
Checking Whether MVs Are Refreshing Within a Time Period���������������������������������������������������������������������������� 441
Creating Remote MV Refreshes�������������������������������������������������������������������������������������������������442
Understanding Remote-Refresh Architectures �������������������������������������������������������������������������������������������������� 443
Viewing MV Base Table Information ������������������������������������������������������������������������������������������������������������������ 444
Determining How Many MVs Reference a Central MV Log �������������������������������������������������������������������������������� 444
Managing MVs in Groups ����������������������������������������������������������������������������������������������������������446
Creating an MV Group ���������������������������������������������������������������������������������������������������������������������������������������� 447
Altering an MV Refresh Group ��������������������������������������������������������������������������������������������������������������������������� 447
Refreshing an MV Group ������������������������������������������������������������������������������������������������������������������������������������ 448
DBMS_MVIEW vs� DBMS_REFRESH ������������������������������������������������������������������������������������������������������������������ 448
Determining MVs in a Group ������������������������������������������������������������������������������������������������������������������������������ 448
Adding an MV to a Refresh Group ���������������������������������������������������������������������������������������������������������������������� 449
■ Contents
xxiii
Removing MVs from a Refresh Group ���������������������������������������������������������������������������������������������������������������� 449
Dropping an MV Refresh Group ������������������������������������������������������������������������������������������������������������������������� 449
Summary �����������������������������������������������������������������������������������������������������������������������������������450
Chapter 16: User-Managed Backup and Recovery ■ ��������������������������������������������������������451
Implementing a Cold-Backup Strategy for a Noarchivelog Mode Database �����������������������������452
Making a Cold Backup of a Noarchivelog Mode Database �������������������������������������������������������������������������������� 452
Restoring a Cold Backup in Noarchivelog Mode with Online Redo Logs ����������������������������������������������������������� 454
Restoring a Cold Backup in Noarchivelog Mode Without Online Redo Logs ������������������������������������������������������ 455
Scripting a Cold Backup and Restore ���������������������������������������������������������������������������������������������������������������� 456
Making a Cold Backup of an Archivelog Mode Database ����������������������������������������������������������459
Implementing a Hot Backup Strategy ����������������������������������������������������������������������������������������460
Making a Hot Backup ���������������������������������������������������������������������������������������������������������������������������������������� 460
Scripting Hot Backups ��������������������������������������������������������������������������������������������������������������������������������������� 463
Understanding the Split-Block Issue ����������������������������������������������������������������������������������������������������������������� 466
Understanding the Need for Redo Generated During Backup ��������������������������������������������������������������������������� 468
Understanding that Data Files are Updated ������������������������������������������������������������������������������������������������������� 469
Performing a Complete Recovery of an Archivelog Mode Database �����������������������������������������470
Restoring and Recovering with the Database Offline ���������������������������������������������������������������������������������������� 471
Restoring and Recovering with a Database Online�������������������������������������������������������������������������������������������� 474
Restoring Control Files �������������������������������������������������������������������������������������������������������������������������������������� 475
Performing an Incomplete Recovery of an Archivelog Mode Database�������������������������������������479
Summary �����������������������������������������������������������������������������������������������������������������������������������481
Chapter 17: Configuring RMAN ■ ��������������������������������������������������������������������������������������483
Understanding RMAN ����������������������������������������������������������������������������������������������������������������484
Starting RMAN ���������������������������������������������������������������������������������������������������������������������������486
RMAN Architectural Decisions ���������������������������������������������������������������������������������������������������488
Running the RMAN Client Remotely or Locally �������������������������������������������������������������������������������������������������� 490
Specifying the Backup User������������������������������������������������������������������������������������������������������������������������������� 491
Using Online or Offline Backups ������������������������������������������������������������������������������������������������������������������������ 491
Setting the Archive Redo Log Destination and File Format ������������������������������������������������������������������������������� 491
■ Contents
xxiv
Configuring the RMAN Backup Location and File Format ���������������������������������������������������������������������������������� 492
Setting the Autobackup of the Control File �������������������������������������������������������������������������������������������������������� 494
Specifying the Location of the Autobackup of the Control File �������������������������������������������������������������������������� 495
Backing Up Archive Redo Logs �������������������������������������������������������������������������������������������������������������������������� 495
Determining the Location for the Snapshot Control File ������������������������������������������������������������������������������������ 496
Using a Recovery Catalog ���������������������������������������������������������������������������������������������������������������������������������� 497
Using a Media Manager ������������������������������������������������������������������������������������������������������������������������������������� 497
Setting the CONTROL_FILE_RECORD_KEEP_TIME Initialization Parameter ������������������������������������������������������ 498
Configuring RMAN’s Backup Retention Policy ��������������������������������������������������������������������������������������������������� 498
Configuring the Archive Redo Logs’ Deletion Policy ������������������������������������������������������������������������������������������ 500
Setting the Degree of Parallelism ���������������������������������������������������������������������������������������������������������������������� 500
Using Backup Sets or Image Copies ������������������������������������������������������������������������������������������������������������������ 501
Using Incremental Backups ������������������������������������������������������������������������������������������������������������������������������� 502
Using Incrementally Updated Backups �������������������������������������������������������������������������������������������������������������� 502
Using Block Change Tracking ���������������������������������������������������������������������������������������������������������������������������� 503
Configuring Binary Compression ����������������������������������������������������������������������������������������������������������������������� 503
Configuring Encryption �������������������������������������������������������������������������������������������������������������������������������������� 504
Configuring Miscellaneous Settings ������������������������������������������������������������������������������������������������������������������ 505
Configuring Informational Output ���������������������������������������������������������������������������������������������������������������������� 506
Segueing from Decision to Action ���������������������������������������������������������������������������������������������507
Summary �����������������������������������������������������������������������������������������������������������������������������������510
Chapter 18: RMAN Backups and Reporting ■ �������������������������������������������������������������������511
Preparing to Run RMAN Backup Commands �����������������������������������������������������������������������������512
Setting NLS_DATE_FORMAT ������������������������������������������������������������������������������������������������������������������������������ 512
Setting ECHO Setting ECHO ������������������������������������������������������������������������������������������������������������������������������� 513
Showing Variables ��������������������������������������������������������������������������������������������������������������������������������������������� 513
Running Backups ����������������������������������������������������������������������������������������������������������������������513
Backing Up the Entire Database ������������������������������������������������������������������������������������������������������������������������ 513
Backing Up Tablespaces ������������������������������������������������������������������������������������������������������������������������������������ 515
Backing Up Data Files ���������������������������������������������������������������������������������������������������������������������������������������� 515
Backing Up the Control File ������������������������������������������������������������������������������������������������������������������������������� 516
■ Contents
xxv
Backing up the spfile ����������������������������������������������������������������������������������������������������������������������������������������� 516
Backing Up Archive Redo Logs �������������������������������������������������������������������������������������������������������������������������� 516
Backing Up FRA ������������������������������������������������������������������������������������������������������������������������������������������������� 517
Excluding Tablespaces from Backups ��������������������������������������������������������������������������������������������������������������� 518
Backing Up Data Files Not Backed Up ��������������������������������������������������������������������������������������������������������������� 518
Skipping Read-Only Tablespaces ���������������������������������������������������������������������������������������������������������������������� 518
Skipping Offline or Inaccessible Files ���������������������������������������������������������������������������������������������������������������� 519
Backing Up Large Files in Parallel ��������������������������������������������������������������������������������������������������������������������� 520
Adding RMAN Backup Information to the Repository ���������������������������������������������������������������������������������������� 520
Taking Backups of Pluggable Databases ����������������������������������������������������������������������������������521
While Connected to the Root Container ������������������������������������������������������������������������������������������������������������� 521
While Connected to a Pluggable Database �������������������������������������������������������������������������������������������������������� 522
Creating Incremental Backups ��������������������������������������������������������������������������������������������������523
Taking Incremental-Level Backups�������������������������������������������������������������������������������������������������������������������� 523
Making Incrementally Updating Backups ���������������������������������������������������������������������������������������������������������� 524
Using Block Change Tracking ���������������������������������������������������������������������������������������������������������������������������� 525
Checking for Corruption in Data Files and Backups ������������������������������������������������������������������526
Using VALIDATE �������������������������������������������������������������������������������������������������������������������������������������������������� 526
Using BACKUP…VALIDATE �������������������������������������������������������������������������������������������������������������������������������� 527
Using RESTORE…VALIDATE ������������������������������������������������������������������������������������������������������������������������������� 527
Using a Recovery Catalog ����������������������������������������������������������������������������������������������������������528
Creating a Recovery Catalog ����������������������������������������������������������������������������������������������������������������������������� 528
Registering a Target Database ��������������������������������������������������������������������������������������������������������������������������� 529
Backing Up the Recovery Catalog���������������������������������������������������������������������������������������������������������������������� 530
Synchronizing the Recovery Catalog ����������������������������������������������������������������������������������������������������������������� 530
Recovery Catalog Versions �������������������������������������������������������������������������������������������������������������������������������� 530
Dropping a Recovery Catalog ���������������������������������������������������������������������������������������������������������������������������� 530
Logging RMAN Output ���������������������������������������������������������������������������������������������������������������531
Redirecting Output to a File ������������������������������������������������������������������������������������������������������������������������������� 531
Capturing Output with Linux/Unix Logging Commands ������������������������������������������������������������������������������������� 531
■ Contents
xxvi
Logging Output to a File ������������������������������������������������������������������������������������������������������������������������������������ 532
Querying for Output in the Data Dictionary �������������������������������������������������������������������������������������������������������� 533
RMAN Reporting ������������������������������������������������������������������������������������������������������������������������533
Using LIST ���������������������������������������������������������������������������������������������������������������������������������������������������������� 533
Using REPORT ���������������������������������������������������������������������������������������������������������������������������������������������������� 534
Using SQL ���������������������������������������������������������������������������������������������������������������������������������������������������������� 535
Summary �����������������������������������������������������������������������������������������������������������������������������������538
Chapter 19: RMAN Restore and Recovery ■ ���������������������������������������������������������������������539
Determining if Media Recovery Is Required ������������������������������������������������������������������������������540
Determining What to Restore ����������������������������������������������������������������������������������������������������541
How the Process Works ������������������������������������������������������������������������������������������������������������������������������������� 541
Using Data Recovery Advisor ����������������������������������������������������������������������������������������������������������������������������� 542
Using RMAN to Stop/Start Oracle ����������������������������������������������������������������������������������������������546
Shutting Down ��������������������������������������������������������������������������������������������������������������������������������������������������� 546
Starting Up ��������������������������������������������������������������������������������������������������������������������������������������������������������� 546
Complete Recovery �������������������������������������������������������������������������������������������������������������������547
Testing Restore and Recovery ��������������������������������������������������������������������������������������������������������������������������� 547
Restoring and Recovering the Entire Database ������������������������������������������������������������������������������������������������� 549
Restoring and Recovering Tablespaces ������������������������������������������������������������������������������������������������������������� 550
Restoring Read-Only Tablespaces ��������������������������������������������������������������������������������������������������������������������� 551
Restoring Temporary Tablespaces ��������������������������������������������������������������������������������������������������������������������� 552
Restoring and Recovering Data Files ����������������������������������������������������������������������������������������������������������������� 552
Restoring Data Files to Nondefault Locations ���������������������������������������������������������������������������������������������������� 554
Performing Block-Level Recovery ��������������������������������������������������������������������������������������������������������������������� 555
Restoring a Container Database and Its Associated Pluggable Databases ������������������������������������������������������� 556
Restoring Archive Redo Log Files ����������������������������������������������������������������������������������������������558
Restoring to the Default Location ���������������������������������������������������������������������������������������������������������������������� 558
Restoring to a Nondefault Location ������������������������������������������������������������������������������������������������������������������� 559
■ Contents
xxvii
Restoring a Control File �������������������������������������������������������������������������������������������������������������559
Using a Recovery Catalog ���������������������������������������������������������������������������������������������������������������������������������� 560
Using an Autobackup ����������������������������������������������������������������������������������������������������������������������������������������� 560
Specifying a Backup File Name ������������������������������������������������������������������������������������������������������������������������� 561
Restoring the spfile �������������������������������������������������������������������������������������������������������������������561
Incomplete Recovery �����������������������������������������������������������������������������������������������������������������562
Determining the Type of Incomplete Recovery �������������������������������������������������������������������������������������������������� 564
Performing Time-Based Recovery ��������������������������������������������������������������������������������������������������������������������� 565
Performing Log Sequence-Based Recovery ������������������������������������������������������������������������������������������������������ 565
Performing SCN-Based Recovery ���������������������������������������������������������������������������������������������������������������������� 566
Restoring to a Restore Point ������������������������������������������������������������������������������������������������������������������������������ 566
Restoring Tables to a Previous Point ����������������������������������������������������������������������������������������������������������������� 567
Flashing Back a Table ����������������������������������������������������������������������������������������������������������������568
FLASHBACK TABLE TO BEFORE DROP ���������������������������������������������������������������������������������������������������������������� 568
Flashing Back a Table to a Previous Point in Time ��������������������������������������������������������������������������������������������� 569
Flashing Back a Database ���������������������������������������������������������������������������������������������������������571
Restoring and Recovering to Different Server ���������������������������������������������������������������������������572
Step 1� Create an RMAN Backup on the Originating Database �������������������������������������������������������������������������� 574
Step 2� Copy the RMAN Backup to the Destination Server �������������������������������������������������������������������������������� 574
Step 3� Ensure That Oracle Is Installed �������������������������������������������������������������������������������������������������������������� 575
Step 4� Source the Required OS Variables ��������������������������������������������������������������������������������������������������������� 575
Step 5� Create an init�ora File for the Database to Be Restored ������������������������������������������������������������������������ 575
Step 6� Create Any Required Directories for Data Files, Control Files, and Dump/Trace Files ��������������������������� 576
Step 7� Start Up the Database in Nomount Mode ���������������������������������������������������������������������������������������������� 576
Step 8� Restore the Control File from the RMAN Backup����������������������������������������������������������������������������������� 576
Step 9� Start Up the Database in Mount Mode �������������������������������������������������������������������������������������������������� 576
Step 10� Make the Control File Aware of the Location of the RMAN Backups ��������������������������������������������������� 577
Step 11� Rename and Restore the Data Files to Reflect New Directory Locations �������������������������������������������� 577
Step 12� Recover the Database ������������������������������������������������������������������������������������������������������������������������� 579
Step 13� Set the New Location for the Online Redo Logs ���������������������������������������������������������������������������������� 580
Step 14� Open the Database ������������������������������������������������������������������������������������������������������������������������������ 581
■ Contents
xxviii
Step 15� Add the Temp File �������������������������������������������������������������������������������������������������������������������������������� 581
Step 16� Rename the Database ������������������������������������������������������������������������������������������������������������������������� 582
Summary �����������������������������������������������������������������������������������������������������������������������������������584
Chapter 20: Oracle Secure Backup ■ ��������������������������������������������������������������������������������585
OSB Editions and Features ��������������������������������������������������������������������������������������������������������585
OSB Terminology �����������������������������������������������������������������������������������������������������������������������586
OSB Administrative Domain and Servers����������������������������������������������������������������������������������������������������������� 586
OSB Interfaces ��������������������������������������������������������������������������������������������������������������������������������������������������� 587
OSB Users and Classes �������������������������������������������������������������������������������������������������������������������������������������� 588
OSB Daemons ���������������������������������������������������������������������������������������������������������������������������������������������������� 588
Download and Installation ���������������������������������������������������������������������������������������������������������588
Command-Line Access to OSB ��������������������������������������������������������������������������������������������������592
OSB Configuration ���������������������������������������������������������������������������������������������������������������������592
Configuring Users and Classes �������������������������������������������������������������������������������������������������������������������������� 593
Configuring Media Families ������������������������������������������������������������������������������������������������������������������������������� 594
Configuring Database Backup Storage Selector ������������������������������������������������������������������������������������������������ 595
Database Backup ����������������������������������������������������������������������������������������������������������������������596
Database Restore ����������������������������������������������������������������������������������������������������������������������597
Filesystem Backup ��������������������������������������������������������������������������������������������������������������������598
Creating Data Set Files �������������������������������������������������������������������������������������������������������������������������������������� 598
Configuring Backup Windows ���������������������������������������������������������������������������������������������������������������������������� 599
Configuring Backup Schedules and Triggers ����������������������������������������������������������������������������������������������������� 600
Performing On-Demand Filesystem Backups ���������������������������������������������������������������������������������������������������� 601
Filesystem Restore ��������������������������������������������������������������������������������������������������������������������602
Performing Catalog-Based Restore ������������������������������������������������������������������������������������������������������������������� 602
Performing a Raw Restore ��������������������������������������������������������������������������������������������������������������������������������� 602
Performing an obtar Restore ����������������������������������������������������������������������������������������������������������������������������� 603
■ Contents
xxix
OSB Job Monitoring �������������������������������������������������������������������������������������������������������������������604
Listing Jobs ������������������������������������������������������������������������������������������������������������������������������������������������������� 604
Showing Job Transcripts ����������������������������������������������������������������������������������������������������������������������������������� 606
Monitoring OSB Logs ����������������������������������������������������������������������������������������������������������������������������������������� 607
Virtual Test Devices �������������������������������������������������������������������������������������������������������������������608
Oracle Database Backup in the Cloud ���������������������������������������������������������������������������������������609
OSB Software Upgrades ������������������������������������������������������������������������������������������������������������611
Summary �����������������������������������������������������������������������������������������������������������������������������������612
Chapter 21: Automating Jobs ■ ����������������������������������������������������������������������������������������613
Automating Jobs with Oracle Scheduler �����������������������������������������������������������������������������������614
Creating and Scheduling a Job �������������������������������������������������������������������������������������������������������������������������� 614
Viewing Job Details ������������������������������������������������������������������������������������������������������������������������������������������� 615
Modifying Job Logging History �������������������������������������������������������������������������������������������������������������������������� 615
Modifying a Job ������������������������������������������������������������������������������������������������������������������������������������������������� 616
Stopping a Job ��������������������������������������������������������������������������������������������������������������������������������������������������� 616
Disabling a Job �������������������������������������������������������������������������������������������������������������������������������������������������� 616
Enabling a Job ��������������������������������������������������������������������������������������������������������������������������������������������������� 616
Copying a Job ���������������������������������������������������������������������������������������������������������������������������������������������������� 617
Running a Job Manually ������������������������������������������������������������������������������������������������������������������������������������ 617
Deleting a Job ���������������������������������������������������������������������������������������������������������������������������������������������������� 617
Oracle Scheduler vs� cron ���������������������������������������������������������������������������������������������������������618
Automating Jobs via cron ����������������������������������������������������������������������������������������������������������618
How cron Works ������������������������������������������������������������������������������������������������������������������������������������������������� 619
Enabling Access to cron ������������������������������������������������������������������������������������������������������������������������������������ 620
Understanding cron Table Entries ���������������������������������������������������������������������������������������������������������������������� 621
Scheduling a Job to Run Automatically ������������������������������������������������������������������������������������������������������������� 622
Redirecting cron Output ������������������������������������������������������������������������������������������������������������������������������������� 624
Troubleshooting cron ����������������������������������������������������������������������������������������������������������������������������������������� 625
Examples of Automated DBA Jobs ��������������������������������������������������������������������������������������������626
Starting and Stopping the Database and Listener ��������������������������������������������������������������������������������������������� 626
Checking for Archive Redo Destination Fullness ����������������������������������������������������������������������������������������������� 630
■ Contents
xxx
Truncating Large Log Files �������������������������������������������������������������������������������������������������������������������������������� 631
Checking for Locked Production Accounts �������������������������������������������������������������������������������������������������������� 632
Checking for Files Older Than a Certain Age ����������������������������������������������������������������������������������������������������� 633
Checking for Too Many Processes ��������������������������������������������������������������������������������������������������������������������� 634
Verifying the Integrity of RMAN Backups ����������������������������������������������������������������������������������������������������������� 635
Summary �����������������������������������������������������������������������������������������������������������������������������������636
Chapter 22: Database Troubleshooting ■ ��������������������������������������������������������������������������637
Quickly Triaging �������������������������������������������������������������������������������������������������������������������������637
Checking Database Availability �������������������������������������������������������������������������������������������������������������������������� 637
Investigating Disk Fullness �������������������������������������������������������������������������������������������������������������������������������� 639
Inspecting the Alert Log ������������������������������������������������������������������������������������������������������������������������������������� 642
Identifying Bottlenecks via OS Utilities ��������������������������������������������������������������������������������������644
Identifying System Bottlenecks ������������������������������������������������������������������������������������������������������������������������� 645
Mapping an Operating System Process to an SQL Statement ��������������������������������������������������������������������������� 648
Finding Resource-Intensive SQL Statements ����������������������������������������������������������������������������651
Monitoring Real-Time SQL Execution Statistics ������������������������������������������������������������������������������������������������ 651
Running Oracle Diagnostic Utilities ������������������������������������������������������������������������������������������������������������������� 653
Detecting and Resolving Locking Issues �����������������������������������������������������������������������������������656
Resolving Open-Cursor Issues ��������������������������������������������������������������������������������������������������658
Troubleshooting Undo Tablespace Issues ����������������������������������������������������������������������������������659
Determining if Undo Is Correctly Sized �������������������������������������������������������������������������������������������������������������� 659
Viewing SQL That Is Consuming Undo Space ���������������������������������������������������������������������������������������������������� 661
Handling Temporary Tablespace Issues ������������������������������������������������������������������������������������662
Determining if Temporary Tablespace Is Sized Correctly ����������������������������������������������������������������������������������� 663
Viewing SQL That Is Consuming Temporary Space ������������������������������������������������������������������������������������������� 664
Summary �����������������������������������������������������������������������������������������������������������������������������������665
■ Contents
xxxi
Chapter 23: Pluggable Databases ■ ���������������������������������������������������������������������������������667
Understanding Pluggable Architecture ��������������������������������������������������������������������������������������668
Paradigm Shift ��������������������������������������������������������������������������������������������������������������������������������������������������� 671
B&R Implications ����������������������������������������������������������������������������������������������������������������������������������������������� 672
Tuning Nuances ������������������������������������������������������������������������������������������������������������������������������������������������� 672
Creating a CDB ��������������������������������������������������������������������������������������������������������������������������673
Creating Manually with SQL ������������������������������������������������������������������������������������������������������������������������������ 673
Using the DBCA �������������������������������������������������������������������������������������������������������������������������������������������������� 675
Generating CDB Create Scripts via DBCA ���������������������������������������������������������������������������������������������������������� 676
Verifying that a CDB was Created ���������������������������������������������������������������������������������������������������������������������� 677
Administrating the Root Container ��������������������������������������������������������������������������������������������678
Connecting to the Root Container ���������������������������������������������������������������������������������������������������������������������� 679
Displaying Currently Connected Container Information ������������������������������������������������������������������������������������� 679
Starting/Stopping the Root Container ���������������������������������������������������������������������������������������������������������������� 680
Creating Common Users ������������������������������������������������������������������������������������������������������������������������������������ 680
Creating Common Roles ������������������������������������������������������������������������������������������������������������������������������������ 681
Reporting on Container Space ��������������������������������������������������������������������������������������������������������������������������� 681
Switching Containers ����������������������������������������������������������������������������������������������������������������������������������������� 683
Creating a Pluggable Database within a CDB ����������������������������������������������������������������������������683
Cloning the Seed Database ������������������������������������������������������������������������������������������������������������������������������� 684
Cloning an Existing Pluggable Database ����������������������������������������������������������������������������������������������������������� 685
Cloning from a Non-CDB Database �������������������������������������������������������������������������������������������������������������������� 686
Unplugging a Pluggable Database from a CDB �������������������������������������������������������������������������������������������������� 688
Plugging an Unplugged Pluggable Database into a CDB ����������������������������������������������������������������������������������� 689
Using the DBCA to Create a Pluggable Database from the Seed Database ������������������������������������������������������� 689
Checking the Status of Pluggable Databases ���������������������������������������������������������������������������������������������������� 690
Administrating Pluggable Databases ����������������������������������������������������������������������������������������691
Connecting to a Pluggable Database ����������������������������������������������������������������������������������������������������������������� 691
Managing a Listener in a Pluggable Database Environment ����������������������������������������������������������������������������� 691
Showing the Currently Connected Pluggable Database ������������������������������������������������������������������������������������ 693
Starting/Stopping a Pluggable Database ����������������������������������������������������������������������������������������������������������� 693
■ Contents
xxxii
Modifying Initialization Parameters Specific to a Pluggable Database ������������������������������������������������������������� 694
Renaming a Pluggable Database ����������������������������������������������������������������������������������������������������������������������� 695
Limiting the Amount of Space Consumed by a Pluggable Database ����������������������������������������������������������������� 695
Viewing Pluggable Database History ����������������������������������������������������������������������������������������������������������������� 695
Dropping a Pluggable Database ������������������������������������������������������������������������������������������������������������������������ 696
Summary �����������������������������������������������������������������������������������������������������������������������������������697
Index ���������������������������������������������������������������������������������������������������������������������������������699
xxxiii
About the Author
Darl Kuhn is currently a database administrator working for Oracle Corporation. He has written books on a variety of IT topics, including SQL, performance tuning, Linux, backup and recovery, Oracle Recovery Manager, and database administration. Darl also teaches Oracle classes at Regis University and does volunteer work for the Rocky Mountain Oracle Users Group.
xxxv
About the Technical Reviewers
Fuad Arshad has been a database administrator for more than 16 years. He has experience in all aspects of the Oracle database, from management to tuning, and is an Oracle Certified Expert. He frequently blogs about Oracle (http://www.fuadarshad.com) as well as participating in online forums and social media (http://www.twitter.com/fuadar). Fuad has presented at the conferences Collaborate and Oracle OpenWorld on topics ranging from Oracle Real Application Clusters to Oracle Database Appliance. Fuad currently works for a Fortune 500 company. He lives in Lindenhurst, Illinois, with his family.
Bernard Lopuz is a senior principal technical support analyst at Oracle Corporation since 2001, and he is an Oracle Certified Professional (OCP). Before he became an Oracle DBA, he was a programmer developing Unisys Linc and Oracle applications, as well as interactive voice response (IVR) applications such as telephone banking voice-processing applications. Bernard was coauthor of the Linux Recipes for Oracle DBAs (Apress, 2008) and technical reviewer of three other books, namely, Oracle RMAN Recipes (Apress, 2007), Pro Oracle Database 11g Administration (Apress, 2010), and Pro Oracle SQL (Apress, 2010). He has a bachelor’s degree in computer engineering from the Mapúa Institute of Technology in Manila, Philippines. Bernard was born in Iligan, Philippines, and now resides in Ottawa, Canada, with his wife, Leizle, and daughters, Juliet and Carol. Aside from tinkering with computers, Bernard is a soccer and basketball fanatic.
Bill Padfield is an Oracle Certified Professional, working as a senior database administrator for a large telecommunications company in Denver, Colorado. Bill helps administer and manage a data warehouse environment consisting of more than 100 databases. He has been an Oracle database administrator for more than 16 years and has worked in the IT industry since 1985. Bill also teaches graduate database courses at Regis University. He presently resides in Aurora, Colorado, with his wife, Oyuna, and son, Evan.
xxxvii
Acknowledgments
Special thanks go to Jonathan Gennick. His vision and keen organizational and writing skills have made this book a much greater sum than its parts. A big thank-you to Bernard Lopuz, who made countless suggestions and modifications that contributed tremendously to the quality of the final product. Bernard also authored Chapter 20, on Oracle Secure Backup. Thanks also to Fuad Arshad, who provided a technical review of several chapters to help keep us on schedule. I would like to thank as well the coordinating editor, Kevin Shea; the copy editor, Lisa Vecchione; and the entire Apress production team.
Finally, my thanks to the numerous database administrators, system administrators, and developers from whom I’ve learned database administration techniques over the years: Roger Murphy, Bob Suehrstedt, Scott Schulze, Dave Jennings, Pete Mullineaux, Shawn Heisdorffer, Tim Gorman, Sujit Pattanaik, Ken Toney, Janet Bacon, Sue Wagner, Doug Davis, Ken Roberts, Mehran Sowdaey, Dan Fink, Steve Roughton, Barb Sannwald, Andy Brown, Guido Handley, Nehru Kaja, Tim Colbert, Patrick Gates, Bill Padfield, Bob Mason, Glenn Balanoff, Ravi Narayanaswamy, Kevin Bayer, Abdul Ebadi, Kevin Hoyt, Trent Sherman, Sandra Montijo, Sean Best, Roy Backstrom, Mohan Koneru, John Lilly, Todd Wichers, Mike Tanaka, Will Thornburg, Ashley Jackson, Aaron Isom, Carson Vowles, Kevin Cook, Doug Cushing, Jeff Sherard, Liz Brill, Greg Roberts, Debbie Earman, Ennio Murroni, Beth Loker, Bob Sell, Mike O’Neill, Tom Wheltle, Gabor Gyurovszky, Gary Smith, Mark Lutze, and Jim Stark.
—Darl Kuhn
xxxix
Introduction
Many companies, large and small, use Oracle products. At the heart of this technology is an Oracle database. Businesses use the technology to store and manage mission critical data. This information is the basis for making smart business decisions. Companies that effectively transform data into business intelligence quickly gain a competitive edge in the marketplace.
Oracle database administrators (DBAs) play a pivotal role in implementing and leveraging Oracle database technology. DBAs add value by ensuring that databases are created in an efficient manner and optimally maintained. DBAs are often queried for architectural advice on features, implementation, data migration, replication, SQL coding, tuning, and so on. DBAs fill the role of the go-to person for anything related to Oracle.
The job of an Oracle DBA is frequently complex and challenging. This book focuses on practical examples and techniques for providing a smoothly operating database environment. The content is drawn from years of experience working with Oracle technology. The book shows you from the ground up how a senior DBA manages a multifaceted database environment. I try to focus on demonstrating how to correctly implement features, with scalability and maintainability in mind.
I hope you find the material in this book useful. The goal is to elevate you to a professional level as a DBA. Being a DBA doesn’t have to be constantly painful. The key is to correctly implement the technology the first time, not paint yourself into a corner with a badly implemented feature, and proactively manage your surroundings.
This book doesn’t show you the most complex and sophisticated techniques used in database administration. I try to keep my techniques as simple as possible, yet robust enough to manage any level of chaos and complexity. You should be able to take the concepts elucidated in this book and build on them to help you manage any type of database environment.
Who This Book Is ForThis book is for DBAs who want real-world guidance on how to efficiently configure and maintain complex database environments. Whether you are a novice or an expert, this book contains practical examples of how to implement Oracle database technology. This book is for those who want advice from a real DBA on how Oracle database technology is effectively implemented and maintained.
How This Book Is StructuredThe book is divided into several sections, each covering a logical group of database administration topics, as follows:
Part 1 concentrates on creating a working environment. This includes installing the Oracle software and creating databases.
Part 2 deals with managing critical database files. Topics explored are tablespaces, data files, control files, and online redo log files.
Part 3 discusses configuring users and database objects, such as tables, constraints, indexes, views, synonyms, sequences, and so on.
■ IntroduCtIon
xl
Part 4 details how to create and maintain large database objects and partitioned tables and indexes.
Part 5 shows how DBAs use tools such as Data Pump, external tables, and materialized views to manage and distribute large amounts of data.
Part 6 takes a deep dive into backup-and-recovery (B&R) concepts. Both user-managed backups and Oracle Recovery Manager (RMAN) B&R are presented in detail.
Part 7 focuses on techniques used to automate database jobs and how to troubleshoot typical problems that DBAs encounter.
Part 8 describes how to implement and manage container and pluggable databases.
ConventionsThe following typographical conventions are used in this book:
$ is used to denote Linux/Unix commands that can be run by the operating system (OS) owner •of the Oracle binaries (usually named oracle).
# is used to denote Linux/Unix commands that should be run as the root OS user.•
SQL > is used to denote one-line SQL*Plus statements.•
• Monospaced font is used for code examples, utility names, file names, URLs, and directory paths.
• Italic is used to highlight a new concept or term.
• UPPERCASE indicates names of database objects, such as views, tables, and corresponding column names.
< > is used where you need to provide input, such as a file name or password.•
Downloading the CodeThe code for the examples shown in this book is available on the Apress web site (www.apress.com). A link can be found on the book’s information page, under the Source Code/Downloads tab. This tab is located beneath the Related Titles section of the page.
Contacting the AuthorIf you have any questions regarding the book, please feel free to contact me directly at the following e-mail address: [email protected].