Oracle Essentials Oracle Database 11G
Total Page:16
File Type:pdf, Size:1020Kb
FOURTH EDITION Oracle Essentials Oracle Database 11g Rick Greenwald, Robert Stackowiak, and Jonathan Stern Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Oracle Essentials: Oracle Database 11g, Fourth Edition by Rick Greenwald, Robert Stackowiak, and Jonathan Stern Copyright © 2008 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editors: Colleen Gorman and Deborah Russell Interior Designer: David Futato Production Editor: Sumita Mukherji Cover Designer: Karen Montgomery Production Services: Tolman Creek Design Illustrator: Robert Romano Printing History: October 1999: First Edition. Originally published under the title Oracle Essentials: Oracle8 and Oracle8i June 2001: Second Edition. Originally published under the title Oracle Essentials: Oracle9i, Oracle8i and Oracle8 February 2004: Third Edition. Originally published under the title Oracle Essentials: Oracle Database 10g November 2007: Fourth Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Oracle Essentials: Oracle Database 11g, the image of cicadas, and related trade dress are trademarks of O’Reilly Media, Inc. Oracle® and all Oracle-based trademarks and logos are trademarks or registered trademarks of Oracle Corporation, Inc. in the United States and other countries. O’Reilly Media, Inc. is independent of Oracle Corporation. Java™ and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. O’Reilly Media, Inc. is independent of Sun Microsystems. .NET is a registered trademark of Microsoft Corporation. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. This book uses RepKover™, a durable and flexible lay-flat binding. ISBN-10: 0-596-51454-9 ISBN-13: 978-0-596-51454-9 [M] Table of Contents Preface . xi 1. Introducing Oracle . 1 The Evolution of the Relational Database 2 The Oracle Database Family 7 Summary of Oracle Database Features 9 Database Application Development Features 9 Database Connection Features 13 Distributed Database Features 17 Data Movement Features 18 Database Performance Features 20 Database Management Features 23 Database Security Features 27 Oracle Development Tools 28 Embedded Databases 31 2. Oracle Architecture . 33 Databases and Instances 33 Deploying Physical Components 38 Instance Memory and Processes 48 The Data Dictionary 54 3. Installing and Running Oracle . 56 Installing Oracle 56 Creating a Database 59 Configuring Oracle Net 63 vii Starting Up the Database 68 Shutting Down the Database 69 Accessing a Database 70 Oracle at Work 77 4. Oracle Data Structures . 82 Datatypes 82 Basic Data Structures 90 Additional Data Structures 98 Extended Logic for Data 100 Data Design 102 Constraints 104 Triggers 107 Query Optimization 108 Understanding the Execution Plan 118 SQL Advisors 120 Data Dictionary Tables 120 5. Managing Oracle . 122 Manageability Features 124 Oracle Enterprise Manager 126 Fragmentation and Reorganization 132 Backup and Recovery 133 Working with Oracle Support 137 6. Oracle Security, Auditing, and Compliance . 139 Security 139 Auditing 150 Compliance 151 7. Oracle Performance . 154 Performance Tuning Basics 154 Oracle and Disk I/O Resources 160 Oracle and Parallelism 169 Oracle and Memory Resources 176 Oracle and CPU Resources 182 Database Resource Manager 184 viii | Table of Contents 8. Oracle Multiuser Concurrency . 186 Basics of Concurrent Access 187 Oracle and Concurrent User Access 190 Oracle’s Isolation Levels 191 Oracle Concurrency Features 192 How Oracle Handles Locking 194 Concurrent Access and Performance 197 Workspaces 198 9. Oracle and Transaction Processing . 201 OLTP Basics 201 Oracle’s OLTP Heritage 205 Architectures for OLTP 206 Oracle Features for OLTP 211 High Availability 217 Oracle Streams and Advanced Queuing 218 Object Technologies and Distributed Components 221 10. Oracle Data Warehousing and Business Intelligence . 222 Business Intelligence Basics 223 Data Warehouse Design 227 Query Optimization 230 Analytics, OLAP, and Data Mining in the Database 233 Managing the Data Warehouse 236 Other Software for the Data Warehouse 236 The Metadata Challenge 248 Best Practices 249 11. Oracle and High Availability . 253 What Is High Availability? 254 System Failure 257 Protecting Against System Failure 262 Recovering from Failures 275 Complete Site Failure 281 Data Redundancy Solutions 285 Rolling Upgrades 289 Table of Contents | ix 12. Oracle and Hardware Architecture . 290 System Basics 290 Uniprocessor Systems 292 Symmetric Multiprocessing Systems 293 Clusters 295 Non-Uniform Memory Access Systems 298 Grid Computing 299 Disk and Storage Technology 300 Which Platform Deployment Solution? 302 13. Oracle Distributed Databases and Distributed Data . 305 Accessing Multiple Databases As a Single Entity 305 Moving Data Between Distributed Systems 310 14. Oracle Extended Datatypes . 318 Object-Oriented Development 318 Extensibility Features and Options 324 Using the Extensibility Framework in Oracle 329 15. Beyond the Oracle Database . 331 Application Express 331 Oracle Fusion Middleware 332 Oracle SOA Suite 345 A. What’s New in This Book for Oracle Database 11g . 349 B. Additional Resources . 356 Index . 365 x | Table of Contents - Preface1 We dedicate this book to the memory of one of our original coauthors, Jonathan Stern. Jonathan unexpectedly passed away in March of 2007. Yet his memory lives on for those of us who knew him and, in many ways, for those who will read this book. Let us explain. The original outline for this book was first assembled at the ubiquitous coffee shop located in the Sears Tower in Chicago. It was 1998 and the authors had gathered there with a common goal. We were all Oracle employees working in technical sales roles and had visited many organizations and companies. We found that many IT managers, Oracle database administrators (DBAs), and Oracle developers were quite adept at reading Oracle’s documentation, but seemed to be missing an understand- ing of the overall Oracle footprint and how to practically apply what they were reading. It was as if they had a recipe book, but were unclear on how to gather the right ingredients and mix them together successfully. This bothered all of us, but it particularly frustrated Jonathan. Jonathan was the kind of person who sought to understand how things worked. Nothing delighted Jonathan more than gaining such an understanding, then spend- ing hours thinking of ways to translate his understanding into something that would be more meaningful to others. He believed that a key role for himself while at Oracle was the transfer of such knowledge to others. He continued to perform similar roles later at other companies at which he worked. Writing the first edition of Oracle Essentials was a lengthy process. Jonathan wrote several of the original chapters, and he also reviewed some of the other original work and was quick to identify where he thought something was wrong. For Jonathan, “wrong” meant that the text could be misinterpreted and that further clarity was needed to make sure the right conclusion was drawn. The first edition became much more useful through Jonathan’s efforts. He was always quite proud of that effort. Even as the book changed with succeeding editions and Jonathan moved on to other companies, he continued to feel that this book remained an important accomplish- ment in his life. xi Some explanations of how Oracle works are fundamental to the database and have not changed in subsequent editions of the book, so some of Jonathan’s original work remains here, although much of the surrounding text is now considerably different. Of course, some entire sections describing the complex steps that were once needed to manage and deploy older releases of the database are no longer relevant and thus are no longer included. Jonathan would probably view Oracle’s self-managing and self-tuning improvements as incredible achievements, but would also wonder whether it is a good thing that people can know even less today about how the data- base works but still deploy it. So, we introduce you to the fourth edition of Oracle Essentials. We have made many changes in this edition. Some, of course, result from changes in features in Oracle Database 11g and the ways that youcan now useand deploy the latest release of the database. But we have also made a considerable effort to go back and rewrite parts of the book that we did not believe possessed the clarity needed by our readers—clarity that Jonathan would want in such a book. So, he influences us still. Goals of This Book Our main goal is to give you a foundation for using the Oracle database effectively and efficiently. Therefore, we wrote with these principles in mind: Focus We’ve tried to concentrate on the most important Oracle issues. Every topic pro- vides a comprehensive but concise discussion of how Oracle handles an issue and the repercussions of that action. Brevity One of the first decisions we made was to concentrate on principles rather than syntax. There simply isn’t room for myriad syntax diagrams and examples in this book. Uniqueness We’ve tried to make this an ideal first Oracle book for a wide spectrum of Oracle users—but not the last! You will very likely have to refer to Oracle documenta- tion or other, more specific books for more details about using Oracle.