oracle8i dba bible

1198
O racle8 i DBA: Architecture and Administration Master the material for the Oracle8i DBA Exam 1Z0-023 Test your knowledge with assessment questions, scenarios, and lab exercises Practice on state-of-the-art test-preparation software “Damir Bersinic delivers a clearly written, comprehensive guide — with hundreds of targeted exam-prep questions — that is sure to help Oracle professionals prepare for and pass the second Oracle certification exam.— Harry Liebschutz, Senior Oracle Consultant, HDL Consulting, Inc., and author of The Oracle Cookbook 100% ONE HUNDRED PERCENT COMPREHENSIVE AUTHORITATIVE WHAT YOU NEED ONE HUNDRED PERCENT Damir Bersinic, Oracle Trainer, MCDBA, MCSE+I, MCT, Todd Ross, and Yury Sabinin “Damir Bersinic delivers a clearly written, comprehensive guide — with hundreds of targeted exam-prep questions — that is sure to help Oracle professionals prepare for and pass the second Oracle certification exam.— Harry Liebschutz, Senior Oracle Consultant, HDL Consulting, Inc., and author of The Oracle Cookbook Hungry Minds Test Engine powered by O racle8 i DBA: Architecture and Administration

Upload: api-3697145

Post on 10-Apr-2015

1.321 views

Category:

Documents


2 download

TRANSCRIPT

100%ONE HUNDRED PERCENT

COMPREHENSIVE AUTHORITATIVE WHAT YOU NEEDONE HUNDRED PERCENT

Damir Bersinic delivers a clearly written, comprehensive guide with hundreds of targeted exam-prep questions that is sure to help Oracle professionals prepare for and pass the second Oracle certification exam. Harry Liebschutz, Senior Oracle Consultant, HDL Consulting, Inc., and author of The Oracle Cookbook

Master the materialfor the Oracle8i DBA Exam 1Z0-023

Test your knowledgewith assessment questions, scenarios, and lab exercises

Practice onstate-of-the-art test-preparation software

OHungry Minds Test Engine powered by

racle8i DBA:

Architecture and Administration

Damir Bersinic, Oracle Trainer, MCDBA, MCSE+I, MCT, Todd Ross, and Yury Sabinin

Oracle8i DBA: Architecture and Administration Certification Bible

Oracle8i DBA: Architecture and Administration Certification BibleDamir Bersinic, Todd Ross, Yury Sabinin

Best-Selling Books Digital Downloads e-Books Answer Networks e-Newsletters Branded Web Sites e-Learning

New York, NY Cleveland, OH Indianapolis, IN

Oracle8i DBA: Architecture and Administration Certification Bible Published by Hungry Minds, Inc. 909 Third Avenue New York, NY 10022 www.hungryminds.com Copyright 2002 Hungry Minds, Inc. All rights reserved. No part of this book, including interior design, cover design, and icons, may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording, or otherwise) without the prior written permission of the publisher. Library of Congress Control Number: 2001092906 ISBN: 0-7645-4817-4 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 1P/TQ/RR/QR/IN Distributed in the United States by Hungry Minds, Inc. Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United Kingdom; by IDG Norge Books for Norway; by IDG Sweden Books for Sweden; by IDG Books Australia Publishing Corporation Pty. Ltd. for Australia and New Zealand; by TransQuest Publishers Pte Ltd. for Singapore, Malaysia, Thailand, Indonesia, and Hong Kong; by Gotop Information Inc. for Taiwan; by ICG Muse, Inc. for Japan; by Intersoft for South Africa; by Eyrolles for France; by International Thomson Publishing for Germany, Austria, and Switzerland; by Distribuidora Cuspide for Argentina; by LR International for Brazil; by Galileo Libros for Chile; by Ediciones ZETA S.C.R. Ltda. for Peru;

by WS Computer Publishing Corporation, Inc., for the Philippines; by Contemporanea de Ediciones for Venezuela; by Express Computer Distributors for the Caribbean and West Indies; by Micronesia Media Distributor, Inc. for Micronesia; by Chips Computadoras S.A. de C.V. for Mexico; by Editorial Norma de Panama S.A. for Panama; by American Bookshops for Finland. For general information on Hungry Minds products and services please contact our Customer Care department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002. For sales inquiries and reseller information, including discounts, premium and bulk quantity sales, and foreign-language translations, please contact our Customer Care department at 800-434-3422, fax 317-572-4002 or write to Hungry Minds, Inc., Attn: Customer Care Department, 10475 Crosspoint Boulevard, Indianapolis, IN 46256. For information on licensing foreign or domestic rights, please contact our Sub-Rights Customer Care department at 212-884-5000. For information on using Hungry Minds products and services in the classroom or for ordering examination copies, please contact our Educational Sales department at 800-434-2086 or fax 317-572-4005. For press review copies, author interviews, or other publicity information, please contact our Public Relations department at 317-572-3168 or fax 317-572-4168. For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 978-750-4470.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES. Trademarks: Hungry Minds and related tradedress are trademarks of Hungry Minds, Inc. All other trademarks are the property of their respective owners. Hungry Minds, Inc., is not associated with any product or vendor mentioned in this book. is a trademark of Hungry Minds, Inc.

About the AuthorsDamir Bersinic has over seventeen years of industry experience working with Oracle, SQL Server, Microsoft Windows NT/2000, BackOffice, and other advanced products. He is President and founder of Bradley Systems Incorporated, a Microsoft Certified Partner focusing on database, Internet, and system integration consulting and training. He holds a number of industry certifications including Oracle Certified Professional (DBA) for Oracle 7.3, 8, and 8i; Microsoft Certified Systems Engineer (MCSE); Microsoft Certified Database Administrator (MCDBA); Microsoft Certified Trainer (MCT); and Certified Technical Trainer (CTT). His extensive work with Oracle, SQL Server, Windows NT/2000, and BackOffice has enabled him to provide high-level consulting and other assistance to clients in Canada, the United States, and other parts of the globe. He is an avid fan of Formula 1 and CART racing and can be found in front of his large-screen TV on almost all race weekends. When hes not working, he enjoys time with his wife Visnja and son Anthony. Damir can be reached via e-mail at [email protected]. Todd Ross is a Senior Oracle and UNIX instructor, as well as the Corporate Oracle Stream Leader, for TMI-Learnix Ltd. He is a Certified Oracle Professional in Oracle 7.3, 8.0, and 8i. He also runs an Oracle and Informix consulting company that specializes in database and SQL tuning as well as corporate backup and recovery strategies. Over the past eight years, Todd has been involved in Oracle implementations ranging from Oracle 6 to 8i on several different operating systems such as VAX, UNIX, NT, and 2000 all around the world. Todd is currently working with Oracle9i and trying to spend as much time as possible at home with his wife and two young children. Yury Sabinin is an Oracle Certified Professional (DBA) living in Vancouver, British Columbia, Canada, with his wife and son. He has been involved in the industry since 1987. He is currently a full-time trainer with TMI-Learnix Ltd., teaching Oracle and other courses. He is also a consultant at SYM IT Services Ltd., a Vancouver consulting firm. In his spare time (not that he has any), he collects mechanical watches and tries to stay as far away from computers as possible.

CreditsAcquisitions Editor Terri Varveris Project Editor Barbra Guerra Technical Editor Mike Hordila Copy Editors Barbra Guerra Dennis Weaver Susan Christophersen Editorial Manager Kyle Looper Project Coordinator Dale White Graphics and Production Specialists Laurie Petrone, Jill Piscitelli, Jacque Schneider, Brian Torwelle, Jeremey Unger Quality Control Technicians Laura Albert, David Faust, John Greenough, Andy Hollandbeck, Robert Springer Permissions Editor Laura Moss Media Development Specialist Travis Silver Proofreading and Indexing TECHBOOKS Production Services

I would like to dedicate this book to what a colleague of mine refers to as the lightbulbs the look in the eye of a student or reader when the pieces fall into place. As you continue your journey in Oracle certification with this book, may you be blessed with many lightbulbs. Damir Bersinic

Preface

P

reparing to become an Oracle Certified Professional in the database administration (DBA) track is a journey that starts with a single step. If you have already passed the Introduction to Oracle: SQL & PL/SQL exam you have taken that first step and are well on your way. The next step in the process is to take and pass the Oracle8i: Architecture and Administration exam, a task which this book is designed to help you accomplish. In order to become an Oracle Certified Professional (OCP) in the DBA track for Oracle8i, you will need to pass the following examinations: Exam 1Z0-001: Introduction to Oracle: SQL & PL/SQL Exam 1Z0-023: Oracle8i Architecture and Administration Exam 1Z0-025: Oracle8i Backup and Recovery Exam 1Z0-024: Oracle8i Performance and Tuning Exam 1Z0-026: Oracle8i Network Administration The Oracle8i certification path is designed to lead you to the goal of becoming an OCP in a gradual process. There is no requirement to take the exams in the order they are intended so you do not need to take the exam for which this book prepares you right away. If you prefer to gain more experience and take another one of the exams first, this is acceptable. The only requirement to become an Oracle Certified Professional in the DBA track is that you pass all five exams, in no particular order.

For each of the above exams, Oracle provides a set of objectives that you will be tested on and required to be familiar with. The objectives for the Oracle8i: Architecture and Administration exam are listed in Appendix C, as well as a cross-reference of which chapters in this book provide information on that objective. The complete set of objectives for the entire track may be found in the Oracle Certified Professional Program Candidate Guide, Oracle8i Certified Database Administrator Track available on Oracles Web site at http://www.oracle.com/ education/certification/index.html?ocpguides.html. The exact link to the Adobe Acrobat PDF file for the DBA track is: http://www.oracle.com/ education/downloads/dba8i_cg.pdf. The Candidate Guide document should be reviewed to gain a full understanding of the Oracle Certified Professional Program, as well as how to schedule your exams for your geographical area.

Preface

ix

Whats In This Book?This book is divided into six parts. Part I Overview of Oracle Architecture and Administration. Like in most things, it is always good to start at the beginning. This first part of the book does exactly that by introducing you to the architectural elements of Oracle so that you have a better sense of what components make up an Oracle database and instance. You will then find out what tools are available to administer an Oracle database. This part presents the 40,000-foot view of Oracle. All of the information you are introduced here is explained in much more detail in the parts of the book that follow. Part II Creating and Administering an Oracle Instance and Database. After receiving the 40,000-foot view of Oracle in Part I of this book, Part II takes you to the next logical progression creating a database and learning more about what each of the database components is used for and how to administer them. You will be shown how an instance is configured and started, and the steps required to create a database from scratch. This will be followed by information on how to manage key Oracle database files including the control files, redo log files, and datafiles. The emphasis of this part of the book is on the administration of Oracles physical elements. Part III Administering Storage for Oracle Objects. Knowing how to create a database, tablespaces, and datafiles is only one part of administering Oracle. You also need to be aware of issues surrounding the proper location of various objects in Oracle that require storage (segments). This part of the book, divided into five chapters that first introduce you to the different types of segments in an Oracle database, then follows with a discussion on each segments particular storage needs, and finishes with a discussion on how to enforce data integrity in the database and the impact of constraints. The focus of this part of the book is the logical structure of the Oracle database and how to ensure that the database is operating as efficiently as possible. Even though a thorough discussion on performance tuning is beyond the scope of this book, Part III will provide hints on the efficient use of space for each segment type. Part IV Managing Oracle Data. During your career as a database administrator there will be times when you will need to load large amounts of data into your database, move data from one database to another, or simply reorganize data in an existing database to improve performance and provide for more efficient storage. The use of Import and Export utilities, and other means to reorganize the data in the database to ensure efficient data retrieval, and how to load data into an Oracle database using SQL*Loader are covered in the two chapters that make up Part IV. Part V Administering Oracle Security. This part of the book deals with database security, from understanding how configure security profiles,

x

Oracle8i DBA: Architecture and Administration Certification Bible

creating and managing users, assigning permissions and the different types of permissions available, all the way to simplifying the administration of permissions using roles. As a database administrator it will be your responsibility to ensure that the database is not compromised and that only those individuals who need access have it. Part VI National Language Support. Oracle introduced National Language Support to make it easier to deploy databases that will be accessed by users in multiple geographic areas simultaneously. This feature allows national language sorting, error message display, and much more. The single chapter in this part allows you to gain an understanding of how to use this ability to the benefit of your users. The book has been divided into these parts from the standpoint of organization and logic and not to satisfy the exam requirements in a one-to-one mapping. Each objective of the exam is covered by material in the book. Appendix C lists the exam objectives and the relevant section of the book where each is covered. The appendixes of the book provide a number of useful items: Appendix A outlines the programs and other information found on the CD-ROM provided. These include an electronic copy of the book in PDF format, a sample exam with 300 or so questions that will help you to prepare to write the real exam, and many other useful software programs. Appendix B contains a sample exam with the same number of questions as found in the actual Oracle exam. The styles of questions in this appendix are designed to closely emulate the type of questions you can expect on the exam and therefore help to prepare for it. Answers to each question are also provided, along with an explanation of why the correct answer is correct and the others are incorrect. Appendix C provides a mapping of the Oracle8i: Architecture and Administration exam objectives to the chapters and sections where these objectives are covered in the book. If you find that you are weak in a particular area, this appendix will let you focus your study be pointing you to the correct part of the book with the information you require. Appendix D contains information on what to do to properly prepare for the exam, and what some of the rules are. Appendix E lists the objects used by the exercises at the end of each chapter, as well as providing a hard copy of the scripts used to create and populate the objects. Appendix F recommends some other books, Web sites, and other resources that may be useful in helping you prepare for the exam, as well as increase your knowledge of relational databases and Oracle.

Preface

xi

How to Use This BookWhen asked what the best place to start would be, a wise individual once said at the beginning. This same truth holds true here. The parts and chapters of this book are meant to build upon concepts presented in previous chapters. Similarly, the labs of each chapter may also depend upon the results of labs in previous chapters. While this last point is not a hard and fast rule, it should be kept in mind. The recommended practice is to read the book from beginning to end and absorb the material in the order presented. Each chapter, as well, follows a consistent structure. You are first presented with a series of questions to test your knowledge of the material in the chapter. This is useful if you feel that you are quite familiar with the topics about to be presented the Chapter Pre-Test questions allow you to verify that you have a good grasp of the information. Following the Chapter Pre-Test, the main body of the chapter is presented. You will be introduced to concepts and shown examples of code, as appropriate. Feel free to try the code as you are reading the material to verify that you get the same results as the author. In some cases, the same steps may be followed in the labs at the end of the chapter, so if the code does not work, check that section of the chapter. Each chapter ends with a Key Point Summary, designed to reinforce the main elements presented in the chapter, and then presents a series of exam-style questions to test your understanding of the material. This is followed by one or more scenario-based questions to further test your understanding of the material. You are then asked to complete some Lab Exercises to provide you with some hands-on experience in the material. You are free to do the labs before answering the Quick Assessment exam-style questions. Answers for the Chapter Pre-Test, Quick Assessment, Scenarios, and Lab Exercises are provided at the end of the chapter. These are designed to allow you to confirm the results of your work, and will provide additional information where necessary. After you have read each chapter, you should use the CD-based exam to further test your knowledge. When you feel that you are ready, you can then try your hand at the Practice Exam in Appendix B. If you feel that you have sufficient information, go ahead and schedule your exam. The night before taking the exam, review each chapters Key Point Summary to make sure you understand the material, and answer the Chapter Pre-Test questions again. After passing the exam, the book can also make an excellent reference for any DBA, so keep it handy.

xii

Oracle8i DBA: Architecture and Administration Certification Bible

Conventions Used in This BookWhenever command syntax was presented it will appear similar to the following:CREATE [GLOBAL TEMPORARY] TABLE [schema.]tablename (columnname datatype [NULL | NOT NULL] [DEFAULT expression] [, ...]);

Any elements of the command that are required are presented in uppercase, such as the words CREATE and TABLE in the above example. Any elements of the command language that are optional are presented in uppercase and enclosed in square brackets ([ and ]), such as the [GLOBAL TEMPORARY] option in the above example. Any element that is a substitution variable for an object name in a code example is presented in lowercase, such as the word tablename or columnname or datatype in the above example. Any element that is an optional substitution variable for an object name component, or an object name, such as the word schema in the above example, will be all lowercase and enclosed in square brackets. Any optional element of the command syntax will always be enclosed in square brackets. Any portion of the command syntax where mutually exclusive choices need to be made, will separate those choices by a pipe symbol |. An example of this is the choice between NULL and NOT NULL in the above syntax. Any element that can be repeated several times within the code syntax will be represented by three dots (...). Any element that is underlined denotes the default option for the command.

What the Icons MeanThroughout the book, weve used icons in the left margin to call your attention to points that are particularly important.The Objective icon indicates that the material being presented in the following section directly maps to an objective on the Oracle8i: Architecture and Administration exam.

Note icons are used to tell you that something is important and perhaps a concept that may help you master the task at hand or something fundamental for understanding subsequent material.

Preface

xiii

Tip icons indicate a more efficient way of doing something, or a technique that may not be obvious.

The Exam Tip icon is used to help you focus your studies more precisely. Throughout the book many topics are covered in more detail than necessary to pass the exam. The Exam Tip icon provides information on which elements you will most likely be tested on.

Caution icons are used when performing a certain operation incorrectly or in a particular way can cause problems down the road.

The Cross Reference icon is used to refer you to other sections of the same chapter or other chapters that have more to say on a subject.

The In The Real World icon is used to present information on how experienced DBAs perform certain tasks and what really happens versus what Oracle may want you to think is happening. This icon also may present an alternative method of performing a certain task.

Acknowledgments

I

would like to acknowledge the hard work put in by my contributing authors on this title. It was a new experience to some of you but you all came through it with flying colors. This was greatly helped by the assistance of the entire Hungry Minds team, who pushed us when we needed to be pushed, but let us do what we needed to do otherwise. Each of us would also like to acknowledge the contributions our families made to this project. Their understanding when would rather be with them, but needed to write, helped make the process less painful. They also know that the smoother the process was for us involved, the sooner we would be able to spend more time with them. To our wives, husbands, and children: we are always grateful for your support and understanding, even if we dont show it all the time. Finally, if you read the short snippets of information on the authors contributing to this book, you will note that two out of three work for the same company: TMI-Learnix. A special thank you goes out to Tim Mabey and Mia Hempey who not only allowed me to grab some of their trainers free time and get them involved on this project, but also actively encouraged it. Working with you folks has always been, and continues to be, a pleasure.

Contents at a GlancePreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv

Part I: Overview of Oracle Architecture and Administration . . . . . . 1Chapter 1: Oracle8i Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Getting Started with Oracle8i Server . . . . . . . . . . . . . . . . . . . 35

Part II: Creating and Administering an Oracle Instance and Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Chapter 3: Managing an Oracle Instance . . . . . . . . . . . . . . . . . . . . . . . . 91 Chapter 4: Creating a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Chapter 5: Creating Data Dictionary Views and Standard Packages . . . . . . . 193 Chapter 6: Maintaining the Control File . . . . . . . . . . . . . . . . . . . . . . . . 253 Chapter 7: Maintaining Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . . 273 Chapter 8: Managing Tablespaces and Datafiles . . . . . . . . . . . . . . . . . . . 325

Part III: Administering Storage for Oracle Objects . . . . . . . . . . . 387Chapter 9: Storage Structure and Relationships Chapter 10: Managing Rollback Segments . . . Chapter 11: Managing Tables . . . . . . . . . . Chapter 12: Managing Indexes . . . . . . . . . . Chatper 13: Maintaining Data Integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 425 485 579 629

Part IV: Managing Oracle Data . . . . . . . . . . . . . . . . . . . . . . 683Chapter 14: Loading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685 Chapter 15: Reorganizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731

Part V: Managing Oracle Security . . . . . . . . . . . . . . . . . . . . . 797Chapter 16: Managing Password Security and Resources Chapter 17: Managing Users . . . . . . . . . . . . . . . . . Chapter 18: Managing Privileges . . . . . . . . . . . . . . . Chapter 19: Managing Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799 845 891 973

Part VI: National Language Support . . . . . . . . . . . . . . . . . . 1021Chapter 20: Using National Language Support . . . . . . . . . . . . . . . . . . . 1023 Appendix A: Whats on the CD-ROM . . . . . . . . . . . . . . . . . . Appendix B: Practice Exam . . . . . . . . . . . . . . . . . . . . . . . Appendix C: Objective Mapping . . . . . . . . . . . . . . . . . . . . Appendix D: Exam Tips . . . . . . . . . . . . . . . . . . . . . . . . . Appendix E: Database Schema for Labs . . . . . . . . . . . . . . . . Appendix F: Suggested Readings, Web Sites, and Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1065 1071 1095 1103 1107 1125

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1129 End-User License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1168

ContentsPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv

Part I: Overview of Oracle Architecture and Administration

1

Chapter 1: Oracle8i Architecture . . . . . . . . . . . . . . . . . . . . . . . 3Oracle Architectural Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Oracle instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Oracle database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Other key Oracle files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Processing SQL Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Connecting to an instance . . . . . . . . . . . . . . . . . . . . . . . . . 22 Statement and transaction processing . . . . . . . . . . . . . . . . . . 24 Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Answers to Chapter Questions . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Chapter 2: Getting Started with Oracle8i Server . . . . . . . . . . . . 35Oracle Universal Installer . . . . . . . . . . . . . . . . Optimal Flexible Architecture (OFA) . . . . . . Privileged Users . . . . . . . . . . . . . . . . . . . . . Authenticating privileged users . . . . . . . . . Oracle Tools for Administration . . . . . . . . . . . . Interactive/command-line administration tools Oracle Enterprise Manager . . . . . . . . . . . . Other graphical administration tools . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 42 43 45 53 53 60 76 78 80 83 83 85 85 86 88

xviii

Oracle8i DBA: Architecture and Administration Certification Bible

Part II: Creating and Administering an Oracle Instance and Database

89

Chapter 3: Managing an Oracle Instance . . . . . . . . . . . . . . . . . 91Overview of Starting and Stopping an Oracle Instance . . . . . . . . . . . . 93 Parameter File (INIT.ORA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Required INIT.ORA parameters . . . . . . . . . . . . . . . . . . . . . . 96 Other key INIT.ORA parameters . . . . . . . . . . . . . . . . . . . . . . 97 Storing saved configurations using Instance Manager . . . . . . . . 102 Starting Up and Shutting Down an Oracle Instance . . . . . . . . . . . . . 103 Startup/shutdown stages . . . . . . . . . . . . . . . . . . . . . . . . . 103 The STARTUP command . . . . . . . . . . . . . . . . . . . . . . . . . . 104 The SHUTDOWN command . . . . . . . . . . . . . . . . . . . . . . . . 108 Dynamic performance views . . . . . . . . . . . . . . . . . . . . . . . 111 Managing Oracle Instance Settings . . . . . . . . . . . . . . . . . . . . . . . 115 Displaying parameter values . . . . . . . . . . . . . . . . . . . . . . . 115 Dynamically changing parameter values . . . . . . . . . . . . . . . . 116 Managing User Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Managing the ALERT File and Trace Files . . . . . . . . . . . . . . . . . . . 122 Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Answers to Chapter Questions . . . . . . . . . . . . . . . . . . . . . . . . . 131 Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

Chapter 4: Creating a Database . . . . . . . . . . . . . . . . . . . . . . 139Overview of Creating and Managing a Database . . . . . Creation Prerequisites . . . . . . . . . . . . . . . . . . . . Operating system considerations . . . . . . . . . . Permissions . . . . . . . . . . . . . . . . . . . . . . . Planning database file locations . . . . . . . . . . . Creating a Database Using the Oracle Database Configuration Assistant Creating a database manually using the CREATE DATABASE command . . . . . . . . Troubleshooting Database Creation Problems . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . 141 142 142 144 144 149 . . . . . . . . . . 149 . . . . . . . . . . 165 . . . . . . . . . . 178 . . . . . . . . . . 179 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Contents

xix

Assessment Questions . . . . . Scenarios . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Exercises . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

182 185 185 186 186 187 188 189

Chapter 5: Creating Data Dictionary Views and Standard Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Overview of Data Dictionary Views, Standard Packages, and Database Event Triggers . . . . . . . . . . . . . . . . . . . Data dictionary base tables and views . . . . . . . . . Uses of the Oracle data dictionary . . . . . . . . . . . . Data Dictionary View Types . . . . . . . . . . . . . . . . . . . DBA_ Views . . . . . . . . . . . . . . . . . . . . . . . . . USER_ Views . . . . . . . . . . . . . . . . . . . . . . . . ALL_ Views . . . . . . . . . . . . . . . . . . . . . . . . . Special data dictionary views . . . . . . . . . . . . . . . Dynamic performance views . . . . . . . . . . . . . . . Stored Program Units . . . . . . . . . . . . . . . . . . . . . . . Stored program unit types . . . . . . . . . . . . . . . . Benefits of stored program units . . . . . . . . . . . . . Stored PL/SQL program units . . . . . . . . . . . . . . . Oracle data dictionary packages . . . . . . . . . . . . . View stored object information . . . . . . . . . . . . . Creating Data Dictionary Views . . . . . . . . . . . . . . . . . Scripts to create data dictionary views and packages . Other scripts and data dictionary objects . . . . . . . The Next Step . . . . . . . . . . . . . . . . . . . . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 197 199 199 200 202 204 205 206 209 209 210 211 228 230 232 232 237 239 239 241 244 244 245 245 246 248 248

Chapter 6: Maintaining the Control File . . . . . . . . . . . . . . . . . 253Overview of the Control File . . . . . . . . . . . . . . . . . . . . . . . 255 Control File Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Creating the Control File . . . . . . . . . . . . . . . . . . . . . . . . . 257

xx

Oracle8i DBA: Architecture and Administration Certification Bible

Protecting the Control File . . . . . . . . Multiplexing the control file . . . . . . . Backing up the control file . . . . . . . . Displaying Information about the Control File Views using the control file . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

258 259 260 261 263 264 265 266 267 269 269 270 270

Chapter 7: Maintaining Redo Log Files . . . . . . . . . . . . . . . . . 273Overview of the Online Redo Log Files . . . . . . . . . . . . . . . Planning Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . Redo log file structure . . . . . . . . . . . . . . . . . . . . . Multiplexing redo log files . . . . . . . . . . . . . . . . . . . Using Online Redo Log Files . . . . . . . . . . . . . . . . . . . . . Log writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . Log switches . . . . . . . . . . . . . . . . . . . . . . . . . . Checkpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . Controlling log switches and checkpoints . . . . . . . . . Archiving Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . NOARCHIVELOG mode . . . . . . . . . . . . . . . . . . . . ARCHIVELOG mode . . . . . . . . . . . . . . . . . . . . . . Maintaining Redo Log Files . . . . . . . . . . . . . . . . . . . . . Obtaining information about redo log files and archiving V$LOGFILE . . . . . . . . . . . . . . . . . . . . . . . . . . . V$DATABASE . . . . . . . . . . . . . . . . . . . . . . . . . . V$INSTANCE . . . . . . . . . . . . . . . . . . . . . . . . . . ARCHIVE LOG LIST . . . . . . . . . . . . . . . . . . . . . . . Managing Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . Adding online redo log groups . . . . . . . . . . . . . . . . Adding online redo log members . . . . . . . . . . . . . . . Dropping online redo log groups . . . . . . . . . . . . . . . Dropping online redo log members . . . . . . . . . . . . . Moving or renaming online redo log files . . . . . . . . . . Clearing online redo log files . . . . . . . . . . . . . . . . . Using Oracle Enterprise Manager . . . . . . . . . . . . . . . . . . Troubleshooting LGWR Problems . . . . . . . . . . . . . . . . . Using LogMiner . . . . . . . . . . . . . . . . . . . . . . . . . . . . How LogMiner Works . . . . . . . . . . . . . . . . . . . . . Finishing LogMiner sessions . . . . . . . . . . . . . . . . . Obtaining information about the LogMiner analysis . . . . Features and restrictions of LogMiner . . . . . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 277 277 281 281 282 282 283 283 287 287 289 291 291 292 293 294 294 295 295 296 296 298 299 300 300 300 302 302 305 305 306 306 308

Contents

xxi

Scenarios . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Solutions . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

312 314 317 317 318 320 321

Chapter 8: Managing Tablespaces and Datafiles . . . . . . . . . . . 325The Oracle Database Storage Hierarchy . . . Physical components . . . . . . . . . . Logical components . . . . . . . . . . . Tablespaces . . . . . . . . . . . . . . . . . . . Tablespace types . . . . . . . . . . . . . Tablespace contents . . . . . . . . . . . Creating tablespaces . . . . . . . . . . . Maintaining tablespaces . . . . . . . . . Getting information about tablespaces Guidelines for tablespaces . . . . . . . Key Point Summary . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 328 329 333 334 336 339 345 359 362 363 366 368 369 372 372 373 375 377

Part III: Administering Storage for Oracle ObjectsOverview of Logical Storage Structure Components Types of Segments . . . . . . . . . . . . . . . . . . . Table . . . . . . . . . . . . . . . . . . . . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . Cluster . . . . . . . . . . . . . . . . . . . . . . . Index-organized table . . . . . . . . . . . . . . Partitions . . . . . . . . . . . . . . . . . . . . . Rollback segment . . . . . . . . . . . . . . . . Temporary segment . . . . . . . . . . . . . . . LOB segment . . . . . . . . . . . . . . . . . . . Nested table . . . . . . . . . . . . . . . . . . . . Bootstrap segment . . . . . . . . . . . . . . . . Storage Clause Precedence . . . . . . . . . . . . . . Extents . . . . . . . . . . . . . . . . . . . . . . . . . . Automatic and manual allocation of extents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

387. . . . . . . . . . . . . . . 391 392 392 392 393 393 393 396 396 397 397 397 398 401 401

Chapter 9: Storage Structure and Relationships . . . . . . . . . . . . 389

xxii

Oracle8i DBA: Architecture and Administration Certification Bible

Block Space Utilization . . . . . . . . . . . . . . . . . . . . Database block contents . . . . . . . . . . . . . . . Block space utilization parameters . . . . . . . . . Getting Information about Database Storage Structures . Planning the Location of Segments . . . . . . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

402 402 404 406 409 412 414 416 417 419 419 420 421 422

Chapter 10: Managing Rollback Segments . . . . . . . . . . . . . . . 425The Use of Rollback Segments . . . . . . . . . . . . . . . . . . . . Purpose of Rollback Segments . . . . . . . . . . . . . . . . . . . . Transaction rollback . . . . . . . . . . . . . . . . . . . . . . . Transaction recovery . . . . . . . . . . . . . . . . . . . . . . Read consistency . . . . . . . . . . . . . . . . . . . . . . . . . Types of Rollback Segments . . . . . . . . . . . . . . . . . . . . . . SYSTEM rollback segment . . . . . . . . . . . . . . . . . . . non-SYSTEM rollback segments . . . . . . . . . . . . . . . . DEFERRED rollback segments . . . . . . . . . . . . . . . . . Rollback Segment Operations . . . . . . . . . . . . . . . . . . . . . How transactions use rollback segments . . . . . . . . . . . Growth of rollback segments . . . . . . . . . . . . . . . . . . Shrinkage of rollback segments . . . . . . . . . . . . . . . . Creating Rollback Segments . . . . . . . . . . . . . . . . . . . . . Guidelines for creating rollback segments . . . . . . . . . . Creating rollback segments using OEM Storage Manager . . Getting Information about Rollback Segments . . . . . . . . . . . DBA_ROLLBACK_SEGS . . . . . . . . . . . . . . . . . . . . . V$ROLLNAME . . . . . . . . . . . . . . . . . . . . . . . . . . . V$ROLLSTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . V$TRANSACTION . . . . . . . . . . . . . . . . . . . . . . . . . Maintaining Rollback Segments . . . . . . . . . . . . . . . . . . . . Bringing rollback segments online . . . . . . . . . . . . . . . Using OEM to bring rollback segments online . . . . . . . . Taking rollback segments offline . . . . . . . . . . . . . . . . Changing rollback segment storage parameters . . . . . . . Changing rollback segment storage parameters using OEM Shrinking rollback segments . . . . . . . . . . . . . . . . . . Dropping rollback segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 430 430 431 431 431 432 432 433 433 433 435 436 438 439 442 443 443 445 445 451 453 453 455 455 459 459 460 462

Contents

xxiii

Troubleshooting Rollback Segments . . . . . . . . . Insufficient space for transactions . . . . . . . Read consistency error . . . . . . . . . . . . . Blocking session . . . . . . . . . . . . . . . . . Error in taking a tablespace offline . . . . . . . Planning Rollback Segments . . . . . . . . . . . . . . Online transaction processing environments Data warehousing environments . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . Lab Solutions . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

463 463 464 464 466 467 467 468 468 470 472 473 476 476 477 477 478

Chapter 11: Managing Tables . . . . . . . . . . . . . . . . . . . . . . . 485Data Storage Basics . . . . . . . . . . . . . . . . . . . . . . . . Basic data storage structures . . . . . . . . . . . . . . . Structure of a row . . . . . . . . . . . . . . . . . . . . . Built-in Oracle datatypes . . . . . . . . . . . . . . . . . Large object datatypes . . . . . . . . . . . . . . . . . . The ROWID and UROWID datatypes . . . . . . . . . . . Collection types . . . . . . . . . . . . . . . . . . . . . . Creating Tables . . . . . . . . . . . . . . . . . . . . . . . . . . The CREATE TABLE syntax . . . . . . . . . . . . . . . . Creating tables using Oracle Schema Manager in OEM Temporary tables . . . . . . . . . . . . . . . . . . . . . Creating tables on clusters . . . . . . . . . . . . . . . . Guidelines for creating tables . . . . . . . . . . . . . . . Modifying Tables . . . . . . . . . . . . . . . . . . . . . . . . . Altering storage parameters . . . . . . . . . . . . . . . Manually allocating extents . . . . . . . . . . . . . . . . Moving tables . . . . . . . . . . . . . . . . . . . . . . . . Handling unused space . . . . . . . . . . . . . . . . . . Truncating tables . . . . . . . . . . . . . . . . . . . . . . Dropping a table . . . . . . . . . . . . . . . . . . . . . . Dropping a column . . . . . . . . . . . . . . . . . . . . . Retrieving Table Information . . . . . . . . . . . . . . . . . . DBA_OBJECTS . . . . . . . . . . . . . . . . . . . . . . . DBA_TABLES . . . . . . . . . . . . . . . . . . . . . . . . DBA_SEGMENTS . . . . . . . . . . . . . . . . . . . . . . DBA_EXTENTS . . . . . . . . . . . . . . . . . . . . . . . DBA_TAB_COLUMNS . . . . . . . . . . . . . . . . . . . . DBMS_ROWID Package . . . . . . . . . . . . . . . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 488 492 493 498 499 502 506 507 514 514 517 522 530 530 532 534 537 541 542 542 545 545 546 549 551 552 553 555

xxiv

Oracle8i DBA: Architecture and Administration Certification Bible

Assessment Questions . . . . . Scenarios . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Solutions . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

557 561 563 567 567 568 570 571

Chapter 12: Managing Indexes . . . . . . . . . . . . . . . . . . . . . . 579Index Basics . . . . . . . . . . . . . . . . . . . . . Logical elements of indexes . . . . . . . . . Physical elements of indexes . . . . . . . . Types of Indexes . . . . . . . . . . . . . . . . . . B-tree indexes . . . . . . . . . . . . . . . . . How indexes are used by SQL statements Effect of DML on indexes . . . . . . . . . . Bitmap indexes . . . . . . . . . . . . . . . . Comparing B-tree and bitmap indexes . . Creating B-Tree Indexes . . . . . . . . . . . . . . The CREATE INDEX command . . . . . . . Creating indexes using OEM . . . . . . . . Modifying Indexes . . . . . . . . . . . . . . . . . Altering storage parameters . . . . . . . . Allocating and deallocating index space . Rebuilding indexes . . . . . . . . . . . . . . Rebuilding indexes online . . . . . . . . . . Coalescing indexes . . . . . . . . . . . . . . Dropping indexes . . . . . . . . . . . . . . . Getting Information on Indexes . . . . . . . . . . Data dictionary views . . . . . . . . . . . . Getting index information using OEM . . . Key Point Summary . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 582 585 585 585 587 587 593 596 597 597 601 604 604 605 605 607 608 608 609 609 615 616 618 620 621 622 622 623 624 624

Chapter 13: Maintaining Data Integrity . . . . . . . . . . . . . . . . . 629Overview of Data Integrity in Oracle . . . . . Integrity Constraints in Oracle . . . . . . . . Types of constraints . . . . . . . . . . . Constraint states . . . . . . . . . . . . . When are constraints checked? . . . . Special considerations for constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 634 634 642 647 649

Contents

xxv

Implementing Constraints . . . Modifying Constraints . . . . . Disabled novalidate . . . Disabled validate . . . . . Enabled novalidate . . . . Enabled validate . . . . . Getting Constraint Information DBA_CONSTRAINTS . . . DBA_CONS_COLUMNS . . Other helpful queries . . Key Point Summary . . . . . . . Assessment Questions . . . . . Scenarios . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Exercises . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . .

654 659 659 660 660 661 663 663 665 666 666 669 672 673 674 674 676 677 678

Part IV: Managing Oracle DataOverview of Loading Data into Oracle Databases . . . . . . . Loading Data Using Direct-Load INSERTs . . . . . . . . . . . . NOLOGGING option . . . . . . . . . . . . . . . . . . . . . Parallel direct-load INSERTs . . . . . . . . . . . . . . . . Pros and cons of direct-load INSERTs . . . . . . . . . . . Loading Data Using SQL*Loader . . . . . . . . . . . . . . . . . Files used by SQL*Loader . . . . . . . . . . . . . . . . . . Invoking SQL*Loader from the command line . . . . . . Invoking SQL*Loader using Oracle Enterprise Manager Comparing conventional and direct-path loads . . . . . Guidelines for Using SQL*Loader . . . . . . . . . . . . . . . . . Troubleshooting SQL*Loader . . . . . . . . . . . . . . . . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

683. . . . . . . . . . . . . . . . . . . . . 687 688 690 691 695 696 697 702 705 711 714 715 717 719 721 722 723 723 724 725 726

Chapter 14: Loading Data . . . . . . . . . . . . . . . . . . . . . . . . . 685

xxvi

Oracle8i DBA: Architecture and Administration Certification Bible

Chapter 15: Reorganizing Data . . . . . . . . . . . . . . . . . . . . . . 731Overview of Reorganizing Data . . . . . . . . . . . . . Moving Data . . . . . . . . . . . . . . . . . . . . . . . . The create table as select (CTAS) method . . . The alter table method . . . . . . . . . . . . . . The Import and Export utilities . . . . . . . . . Export modes . . . . . . . . . . . . . . . . . . . . Moving data scenarios . . . . . . . . . . . . . . . Export types . . . . . . . . . . . . . . . . . . . . Exporting Data Using the Export Utility . . . . . . . . Interactive mode . . . . . . . . . . . . . . . . . . Command Line mode . . . . . . . . . . . . . . . Exporting using Oracle Enterprise Manager . . Importing Data Using the Import Utility . . . . . . . . Interactive mode . . . . . . . . . . . . . . . . . . Command Line mode . . . . . . . . . . . . . . . Importing using Oracle Enterprise Manager . . Import behavior . . . . . . . . . . . . . . . . . . Export and import guidelines . . . . . . . . . . . Transportable Tablespaces . . . . . . . . . . . . . . . Implementing Transportable Tablespaces . . . Transportable Tablespace uses and guidelines Checking for self-contained tablespaces . . . . Key Point Summary . . . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . . . . . . . . . Chapter Pre-Test . . . . . . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 735 735 737 738 738 743 744 745 749 751 753 756 760 762 770 772 775 776 777 779 780 782 784 787 787 789 789 790 790 792

Part V: Managing Oracle SecurityOverview of Oracle Security . . . . . . Profiles . . . . . . . . . . . . . . . . . . Overview of profiles . . . . . . . Profile settings . . . . . . . . . . Creating and managing profiles Key Point Summary . . . . . . . . . . . Assessment Questions . . . . . . . . . Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

797. . . . . . . . 801 803 804 805 813 827 828 832

Chapter 16: Managing Password Security and Resources . . . . . . 799

Contents

xxvii

Lab Exercises . . . . . . . . . . Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Exercises . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

832 834 834 836 837 839

Chapter 17: Managing Users . . . . . . . . . . . . . . . . . . . . . . . 845Overview of User Management . . . Users and schemas . . . . . . . Guidelines for Creating Users . . . . Authentication mechanisms . Quotas . . . . . . . . . . . . . . Tablespace assignment . . . . Other user creation guidelines Managing Users . . . . . . . . . . . . Creating users . . . . . . . . . Modifying users . . . . . . . . Dropping users . . . . . . . . . Getting Information about Users . . Key Point Summary . . . . . . . . . . Chapter Assessment . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . Answers to Chapter Questions . . . Chapter Pre-Test . . . . . . . . Assessment Questions . . . . . Scenarios . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847 847 849 849 850 852 852 853 853 863 866 869 871 873 876 877 879 879 880 881 883

Chapter 18: Managing Privileges . . . . . . . . . . . . . . . . . . . . . 891Overview of Managing Privileges . . . . . Types of Privileges . . . . . . . . . . . . . System privileges . . . . . . . . . . . Object privileges . . . . . . . . . . . Auditing Privilege Usage . . . . . . . . . . Types of auditing . . . . . . . . . . . Database auditing guidelines . . . . Implementing database auditing . . Getting information about auditing Key Point Summary . . . . . . . . . . . . . Assessment Questions . . . . . . . . . . . Scenarios . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 893 894 894 914 932 933 934 936 946 952 954 957 958

xxviii

Oracle8i DBA: Architecture and Administration Certification Bible

Answers to Chapter Questions Chapter Pre-Test . . . . . Assessment Questions . . Scenarios . . . . . . . . . Lab Exercises . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

959 959 960 962 964

Chapter 19: Managing Roles . . . . . . . . . . . . . . . . . . . . . . . . 973Overview and Benefits of Roles . . . . . . . . . . . . . . . . . . . . . . . . . 975 Characteristics of roles . . . . . . . . . . . . . . . . . . . . . . . . . . 975 Benefits of roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 976 Implementing and Using Roles . . . . . . . . . . . . . . . . . . . . . . . . . 978 Pre-defined roles in Oracle8i . . . . . . . . . . . . . . . . . . . . . . . 978 Creating roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 982 Managing privileges with roles . . . . . . . . . . . . . . . . . . . . . . 986 Modifying Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990 Managing roles for users . . . . . . . . . . . . . . . . . . . . . . . . . 991 Querying role information in the data dictionary . . . . . . . . . . . 999 Guidelines for using roles . . . . . . . . . . . . . . . . . . . . . . . . 1003 Key Point Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1005 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1006 Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009 Lab Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009 Answers to Chapter Questions . . . . . . . . . . . . . . . . . . . . . . . . 1010 Chapter Pre-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010 Assessment Questions . . . . . . . . . . . . . . . . . . . . . . . . . . 1011 Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1012 Lab Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1013

Part VI: National Language SupportOverview of National Language Support (NLS) . . . . . . . . . . Choosing a Character Set and National Language Character Set for Your Database . . . . . . . . . . . . . . . . . . . . . . . . . Character sets and encoding schemes . . . . . . . . . . . . Character sets and datatypes . . . . . . . . . . . . . . . . . Guidelines for choosing a character set and NLS Character set . . . . . . . . . . . . . . . . . . . . . . Specifying Language-Dependent Behavior in Oracle . . . . . . . INIT.ORA parameters for configuring NLS behavior . . . . Using the NLS_LANG environment variable to configure NLS settings . . . . . . . . . . . . . . . . . . Changing NLS settings for a session . . . . . . . . . . . . . Using NLS in Oracle8i . . . . . . . . . . . . . . . . . . . . . . . . . Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using NLS parameters in SQL functions . . . . . . . . . . . Using Import/Export, SQL*Loader, and NLS . . . . . . . . .

1021. . . . . 1025 . . . . . 1026 . . . . . 1027 . . . . . 1029 . . . . . 1030 . . . . . 1032 . . . . . 1032 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035 1036 1038 1038 1042 1044

Chapter 20: Using National Language Support . . . . . . . . . . . . 1023

Contents

xxix

Getting Information about NLS Settings Key Point Summary . . . . . . . . . . . . Assessment Questions . . . . . . . . . . Scenario . . . . . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . . . . . Answers to Chapter Questions . . . . . Chapter Pre-Test . . . . . . . . . . Assessment Questions . . . . . . . Scenario . . . . . . . . . . . . . . . Lab Exercises . . . . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

1045 1050 1052 1055 1056 1057 1057 1058 1059 1060

Appendix A: Whats on the CD-ROM . . . . . . . . . . . . . . . . . . 1065 Appendix B: Practice Exam . . . . . . . . . . . . . . . . . . . . . . . . 1071 Appendix C: Objective Mapping . . . . . . . . . . . . . . . . . . . . . 1095 Appendix D: Exam Tips . . . . . . . . . . . . . . . . . . . . . . . . . . 1103 Appendix E: Database Schema for Labs . . . . . . . . . . . . . . . . 1107 Appendix F: Suggested Readings, Web Sites, and Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1129 End-User License Agreement . . . . . . . . . . . . . . . . . . . . . . . . 1168

P

A

R

T

Overview of Oracle Architecture and Administrations is true with most things, it is always good to start at the beginning. This first part of the book does exactly that by introducing you to the architectural elements of Oracle so that you have a better sense of what components make up an Oracle database and instance. You then find out what tools are available to administer an Oracle database. Chapter 1 provides a pretty comprehensive overview of the architectural components that make up Oracle. You will learn what the difference between an Oracle database and an Oracle instance is. You will also find out what components make up an Oracle instance from shared memory structures to background processes. You will then learn what is meant by the term Oracle database and which files are part of a database. Then other key files will be presented, followed by a discussion on how a SQL statement is processed and what components of Oracle are involved. Chapter 2 will deal more with administration and a lot less with architecture. The different tools available to administer an Oracle instance and database will first be introduced to you. This will be followed by a discussion on what a privileged user is and why this is so important in the administration of Oracle. You will also learn how to grant a user the necessary permissions to be a privileged user and which users have them when a database is first created. As mentioned at the outset, this part presents the 40,000-foot view of Oracle. All of the information you are introduced here is explained in much more detail in the parts of the book that follow.

I In This PartChapter 1 Oracle8i Architecture Chapter 2 Getting Started with Oracle8i Server

A

C H A P T E R

Oracle8i ArchitectureEXAM OBJECTIVES

1

Oracle Architectural Components Describe the Oracle server architecture and its main components List the structures involved in connecting a user to an Oracle instance List the stages in processing queries, DML statements, COMMITS

4

Part I Overview of Oracle Architecture and Administration

CHAPTER PRE-TEST1. List the various components of the Oracle database. 2. What does the term Oracle instance refer to? 3. How many required background processes are there in Oracle8i, what are they, and what does each do? 4. Which optional background process is strongly recommended to ensure good database recoverability and what does it do? 5. If a user issues a COMMIT command to end a transaction, what must take place before the user is notified that the transaction has been committed? 6. Which Oracle file provides information on the configuration of the instance and what naming convention does it follow? 7. On which computer does the user process typically reside? How about the server process? 8. Can more than one instance access data in a single Oracle database at the same time? 9. What is stored in the shared pool? 10. Which Oracle database files are written to most often? 11. What are the three phases of processing an SQL statement?

Answers to these questions can be found at the end of the chapter.

Chapter 1 Oracle8i Architecture

5

he first phase of being able to pass the Oracle8i: Architecture and Administration exam is to understand, at a relatively high level, how Oracle works. Just as a pilot needs to understand the basics of flight and how an airplane is put together, a database administrator (DBA) of an Oracle database needs to understand what parts make up both the Oracle instance and the database, how these are configured, and how client applications access the database to query and modify data. However, the pilot of an airplane is not the person who has all the answers. Where an aircraft mechanic has more knowledge about the inner workings of the jet engine, for example, the database administrator does not necessarily need to know intimate details about how the different components of Oracle work but does need to understand the interrelationships between them. The goal of this first chapter is to provide you with the basics of the Oracle architecture and how Oracle processes SQL statements. This information is built upon throughout the remainder of the book, so this is not to be a detailed discussion but more of a 40,000-foot view.

T

Oracle Architectural OverviewDescribe the Oracle server architecture and its main components

The whole point of a relational database management system (RDBMS) is to store and supply data to clients who request it. Each RDBMS does this in its own way, so knowing how one works does not necessarily mean that you can figure out the rest. Oracle, being one of the more sophisticated RDBMSs out there, allows for a great deal of flexibility in its configuration and operation. Part of this is possibly due to its architectural design. The architecture of Oracle is configured in such a way as to ensure that client requests for data retrieval and modification are satisfied efficiently while maintaining database integrity. The architecture also ensures that, should parts of the system become unavailable, mechanisms of the architecture can be used to recover from such failure and, once again, bring the database to a consistent state, ensuring database integrity. Furthermore, the architecture of Oracle needs to provide this capability to many clients at the same time so performance is a consideration when the architecture is configured. In understanding the Oracle architecture and how it is used to process client requests, several terms need to be introduced. Figure 1-1 displays a diagram of the architectural components that make up a typical Oracle configuration. The terms shown in the diagram and briefly explained below deal with shared memory structures, processes, and datafiles that are used by Oracle. The terms that you will read about in more detail in this chapter and that are referred to throughout the book include:

6

Part I Overview of Oracle Architecture and Administration

Oracle InstanceSGA Shared Pool Data Dictionary Cache Redo Log Buffer Database Buffer Cache Library Cache

LGWR

PMON

DBWO

CKPT

SMON

Server Processed PGA User Process

Data Files

Control Files

Redo Log Files

Parameter File

Password file

Oracle Database

Archived Redo Log Files

Figure 1-1: Oracles architectural components include the instance, database, and other files and processes.

Oracle Instance The instance is a combination of a memory structure shared by all clients accessing the data, and a number of background processes that perform actions for the instance as a whole. The shared memory structure is called the SGA, which stands for System Global Area or Shared Global Area, depending on who you ask. Either term is equally acceptable and the acronym SGA is the most common way to refer to this memory structure. Oracle also includes a number of background processes that are started when the instance is started. These include the database writer (DBW0), system monitor (SMON), process monitor (PMON), log writer (LGWR), and checkpoint process (CKPT). Depending on the configuration of your instance and your requirements, others may also be started. An example of this is the archiver process (ARC0), which will be started if automatic archiving of log files is turned on.

Chapter 1 Oracle8i Architecture

7

Oracle Database The database consists of three types of files. Datafiles, of which there can be many depending on the requirements of the database, are used to store the data that users query and modify. The control file is a set of one or more files that keeps information about the status of the database and the data and log files that make it up. The redo log files are used to store a chronological record of changes to the data in the datafiles.More information is provided about the control file in Chapter 6. Chapter 7 provides additional insight into redo log files, while datafiles are covered in more detail in Chapter 8.

User Process The user process is any application, either on the same computer as the database or on another computer across a network that can be used to query the database. For example, one of the standard Oracle query tools is SQL*Plus a user process. Another example of a user process is Microsoft Excel or an Oracle Financials application. Any application that makes use of the database to query and modify data in the database is considered a user process. The user process does not have to come from Oracle Corporation; it only needs to make use of the Oracle database. Server Process The server process is a process launched when a user process makes a connection to the instance. The server process resides on the same computer as the instance and database and performs all of the work that the user process requests. As you will find out in more detail later in this chapter, the server process receives requests from the user process in the form of SQL commands, checks their syntax, executes the statements and returns the data to the user process. In a typical Oracle configuration, each user process will have a corresponding server process on the Oracle server to perform all the work on its behalf. Other Oracle Files The remainder of the files that can be found on the hard disk of the server computer include the Oracle parameter files (also known as the INIT.ORA file), which has information on how the instance should be configured and how operations on the database will be performed/optimized, the password file, which is used to authenticate privileged users that can stop and start the instance, as well as perform other actions, and the archived redo log files, which are a copy of the redo log file that has been filled up. Archived redo log files exist to help the DBA ensure good recoverability of the database.The parameter file is covered in more detail in Chapter 3 while the password file is explained in Chapter 2.

Oracle instanceAs shown in Figure 1-2, the Oracle instance is made up of a shared memory structure (the SGA), which is composed of a number of distinct memory areas. The other part of the instance is the set of background processes, both required and optional, that perform work on the database.

8

Part I Overview of Oracle Architecture and Administration

The instance is always associated with one, and only one, database. This means that when an instance is started, the DB_NAME parameter in the Oracle parameter (INIT.ORA) file specifies which database the instance will be connected to, while the INSTANCE_NAME parameter (which defaults to the value of the DB_NAME parameter) specifies the name of the instance. The configuration of the instance is always performed through parameters specified in the INIT.ORA file and one environment variable ORACLE_SID which is used to determine which instance to start and perform configuration operations on when on the same server as the database.

Oracle InstanceSGA Shared Pool Data Dictionary Cache Redo Log Buffer Database Buffer Cache Library Cache

LGWR

PMON

DBWO

CKPT

SMON

Figure 1-2: The Oracle instance is composed of a number of shared memory areas and background processes.

One of the main objectives of the instance is to ensure that connections by multiple users to access database data are handled as efficiently as possible. One way it accomplishes this is by holding information in the datafiles in one of its shared memory structures the database buffer cache to allow multiple users reading the same data to retrieve that data from memory instead of disk since access to memory is about a thousand times quicker than access to a disk file. Another reason that the instance is important is that, when multiple users access Oracle data, allowing more than one to make changes to the same data can cause data corruption and cause the integrity of the data to become suspect. The instance facilitates locking and the ability for several users to access data at the same time.It is important to remember that a user process, when attempting to access data in the database does not connect to the database but to the instance. When specifying what to connect to from a user process, you always specify the name of the instance and not the name of the database. The instance, in this way, is the gatekeeper to the database. It provides the interface to the database without allowing a user to actually touch the various files that make up the database.

Chapter 1 Oracle8i Architecture

9

System Global Area (SGA)The SGA is a shared memory structure that is accessed by all processes in order to perform database activity, such as read and write data, log changes to the log files, and keep track of frequently executed code and data dictionary objects. The SGA is allocated memory from the operating system on which the instance is started, but the memory that is allocated to it is managed by various Oracle processes. The SGA is composed of several specific memory structures, as shown in Figure 1-2. These include: Shared Pool The Shared Pool is an area of SGA memory whose size is specified by the INIT.ORA parameter SHARED_POOL_SIZE. The default value for SHARED_POOL_SIZE is 3,000,000 bytes, or just under 3MB in versions of Oracle prior to 8.1.7, and 8,000KB bytes, or just under 8MB in Oracle 8.1.7. The size of the shared pool remains constant while the instance is running and can only be changed by shutting down and restarting the instance, after modifying the value in the INIT.ORA file.For information on how to configure, start, and stop an Oracle instance, please refer to Chapter 3.

The shared pool is divided into two main areas of memory the data dictionary cache (also called the dictionary cache or row cache) and the library cache. The data dictionary cache is used to store a cached copy of information on frequently accessed data dictionary objects. The information cached includes the name of the object, permissions granted on the object, dependency information, and so on. The data dictionary cache also includes information on the files that make up the database and what tablespaces they belong to, as well as other important information. When a server process needs to determine what the name Students refers to, it queries the data dictionary cache for that information and, if the information cannot be found, it reads the information from the datafile where the data dictionary is located and then places it in a cache for others to read. The information in the cache is stored using a least-recently-used (or LRU) algorithm. This means that information that is frequently requested remains in the cache while information that is only occasionally required is brought into the cache and flushed out if space is required to bring other information in. You cannot manually size the data dictionary cache Oracle does this dynamically and automatically. If more memory is required to cache data dictionary information, which may be the case in a database with many objects, the cache is made larger to accommodate the requests. If the memory is needed by the library cache component of the shared pool, some memory may be freed up and removed from the data dictionary cache. The other major component of the shared pool is the library cache. The library cache is used to store frequently executed SQL statements and PL/SQL program units such as stored procedures and packages. Storing the parsed statement along with the execution plan for the commands sent to the server

10

Part I Overview of Oracle Architecture and Administration

in memory allows other users executing the same statement (that is, identical in every way including case of statement text, spaces and punctuation) to reduce the work required by not having to re-parse the code. This improves performance and allows the code to appear to run quicker. The library cache is broken up into a series of memory structures called shared SQL areas that store three elements of every command sent to the server: the text of the SQL statement or anonymous PL/SQL block itself, the parse tree or compiled version of the statement, and the execution plan for the statement that outlines the steps to be followed to perform the actions for the SQL statement of PL/SQL block. Each shared SQL area is assigned a unique value that is based upon the hash calculated by Oracle from the text of the statement, the letters and case thereof in it, spacing, and other factors. Identical statements always hash out to the same value whereas different statements, even returning the same result, hash out to different values. For example, the following two statements use two shared SQL areas because their case is different, though they both return the same information:SELECT * FROM DBA_USERS; select * from dba_users;

One of the goals for ensuring good performance of the applications accessing data in the database is to share SQL areas by ensuring that the statement returning the same result are identical, thereby allowing each subsequent execution following the first of the same SQL statement to use the execution plan created the first time a command is run. The preceding two statements are considered inefficient because they would need to allocate two shared SQL areas to return the same results. This would consume more memory in the shared pool (once for each statement), as well as cause the server process to build the execution plan each time. Like the data dictionary cache, the library cache also works on an LRU algorithm that ensures that statements that are frequently executed by users remain in the cache while those executed infrequently or just once be aged out when space is required. Also like the data dictionary cache, you cannot specifically size the library cache Oracle sizes it automatically based upon the requirements of the users and statements sent to the server, as well as memory allocated to the shared pool with the SHARED_POOL_SIZE parameter. Database Buffer Cache The database buffer cache is used to store the most recently used blocks from the datafiles in memory. Because Oracle does