Oracle9i DBA JumpStart by Bob Bryla ISBN:0782141897 Sybex © 2003 (347 pages) Get up to speed for Oracle9i Administration Training Courses Fast! Table of Contents Oracle9i DBA JumpStart Introduction Relational Database Chapter 1 Concepts SQL*Plus and iSQL*Plus Chapter 2 Basics Oracle Database Chapter 3 Functions Restricting, Sorting, and Chapter 4 Grouping Data Chapter 5 - Using Multiple Tables Chapter 6 - Advanced SQL Queries Chapter 7 - Logical Consistency Installing Oracle and Chapter 8 Creating a Database Chapter 9 - Reporting Techniques Creating and Maintaining Chapter 10 Database Objects Chapter 11 - Users and Security Making Things Run Fast Chapter 12 (Enough) Chapter 13 - Saving Your Stuff (Backups) Chapter 14 - Troubleshooting Answers to Review Appendix A Questions Appendix B - Glossary Common Database Appendix C Platforms Index Where Can I Find? List of Tables List of Sidebars Back Cover Oracle9i DBA JumpStart gives you the solid grounding you need to approach Oracle certification with confidence: Introduction to relational database concepts Using basic SQL *Plus and iSQL *Plus commands Understanding Oracle database functions Using multiple tables Restricting, sorting, and grouping data Creating and maintaining a database Using SQL *Plus reporting techniques Setting up users and managing security Configuring optimization Creating backups Troubleshooting About the Author Bob Bryla, is an Oracle9i Certified Professional with more than ten years of experience in database design, database application development, training, and database administration He is currently an internet database analyst and DBA at Land’s End, Inc in Dodgeville, Wisconsin Oracle9i DBA JumpStart Bob Bryla Associate Publisher: Neil Edde Acquisitions Editor: Elizabeth Hurley Peterson Developmental Editor: Heather O’Connor Production Editor: Leslie E.H Light Technical Editor: Betty MacEwen Copyeditor: Marilyn Smith Compositor: Kate Reber, Happenstance Type-O-Rama Graphic Illustrator: Jeffery Wilson, Happenstance Type-O-Rama Proofreaders: Nancy Riddiough, Monique Van Den Berg, and Emily Hsuan Indexer: Ann Rogers Book Designer: Maureen Forys, Happenstance Type-O-Rama Cover Designer: Archer Design Cover Illustrator/Photographer: Archer Design Copyright ©2003 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501 World rights reserved No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher Library of Congress Card Number: 2002115476 ISBN: 0-7821-4189-7 JumpStart is a trademark of SYBEX Inc SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc in the United States and/or other countries Screen reproductions produced with FullShot 99 FullShot 99 © 19911999 Inbit Incorporated All rights reserved FullShot is a trademark of Inbit Incorporated Internet screen shot(s) using Microsoft Internet Explorer 6 reprinted by permission from Microsoft Corporation SYBEX is an independent entity from Oracle Corporation and is not affiliated with Oracle Corporation in any manner This publication may be used in assisting students to prepare for an Oracle Certified Professional exam Neither Oracle Corporation nor SYBEX warrants that use of this publication will ensure passing the relevant exam Oracle is either a registered trademark or a trademark of Oracle Corporation in the United States and/or other countries TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever possible Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s) The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 For MCL and the kids Acknowledgments I couldn’t have written this book without the help of many talented and creative people I would like to thank Neil Edde, associate publisher, and Elizabeth Hurley, acquisitions editor, for recognizing the need for an introductory Oracle DBA text Many thanks to developmental editor Heather O’Connor for telling me in the nicest possible way when I was way out in left field, and production editor Leslie Light and copyeditor Marilyn Smith for their valuable advice Thanks also to technical editor Betty MacEwen for her attention to detail and helpful suggestions throughout the book The nature of this book required a great deal of artwork Jeffery Wilson and the rest of Happenstance Type-O-Rama did an excellent job of creating artwork that was appropriate for the book They say a picture is worth a thousand words, and their art is an essential part of this book Somehow they were able to decipher my Microsoft Word cave drawings and turn them into real graphics Many of my professional colleagues at both Lands’ End and Greenbrier & Russel were a source of both inspiration and guidance Also, regards to my long lost friend from fourth grade, Janice, who I’m sure is a DBA out there somewhere Finally, I want to thank my family for all of their support and patience I was still able to give the kids a bath and read books at bedtime, even with the tough deadlines The journey wouldn’t have been half the fun without them Introduction So, you want to be an Oracle database administrator (DBA), but you’re not sure what the job might be like? Well, this is a good place to start! This book is intended to bridge the gap for people who are technically oriented but are not quite ready for an Oracle Certified Associate or Oracle Certified Professional study guide If you don’t have a lot of direct experience with databases, this book can get you up to speed on enough of the basics to feel comfortable going into Oracle’s official certification track What You Need Oracle9i DBA JumpStart assumes some minimal level of expertise in using an operating system such as Windows or Unix in a graphical user interface (GUI) environment Any experience with a personal database, such as Microsoft Access, is helpful but not required To follow along with the examples in the book, you will need an installation of the Oracle database software version 9.0 or 9.2, Standard or Enterprise Edition, including the sample schemas provided by Oracle in the installation package, preferably on a Microsoft Windows platform What This Book Covers This book provides all the information you need to understand the job of an Oracle DBA It is organized as follows: Chapter 1, “Relational Database Concepts” Covers the basics of relational database technology It defines terms such as tables, rows, and columns, and it provides an introduction to database design Chapter 2, “SQL*Plus and iSQL*Plus Basics” Introduces the various ways to send SQL commands to the database It explains the tools available for issuing SQL commands and how to interact with the database Chapter 3, “Oracle Database Functions” Focuses on Oracle functions, both built-in and user defined, and how they can make an application developer’s or DBA’s job easier Chapter 4, “Restricting, Sorting, and Grouping Data” Describes how to manage queries by restricting and sorting their results Chapter 5, “Using Multiple Tables” Moves from accessing single tables to joining multiple tables in a multitude of ways, with both the old and new join syntax Chapter 6, “Advanced SQL Queries” Covers some of the more advanced functions and explains how to nest a query within another query to retrieve the results you want Chapter 7, “Logical Consistency” Describes how to make sure that the rows entered into the database tables are accurate and consistent with data in other tables in the database This chapter discusses how you can validate the data before it is inserted into a row of a table Chapter 8, “Installing Oracle and Creating a Database” Shows you how to install the database software on the server and create a database using Oracle’s GUI-based tools Chapter 9, “Reporting Techniques” Investigates techniques for making reports easier to understand and manage Chapter 10, “Creating and Maintaining Database Objects” Explores the different ways to create tables, indexes, views, sequences, and synonyms It also describes how to use data dictionary views and dynamic performance views Chapter 11, “Users and Security” Focuses on how to prevent unauthorized or unintentional actions in the database It covers how to create user accounts, grant and revoke privileges, and keep tabs on who is accessing what kind of object and when Chapter 12, “Making Things Run Fast (Enough)” Explores techniques for tuning the database so it will respond to queries as quickly as possible This chapter covers how the Oracle optimizer works and how you can use indexes judiciously to make queries run in a reasonable amount of time Chapter 13, “Saving Your Stuff (Backups)” Describes how, by using the right combination of backup and recovery techniques, the DBA can minimize or even eliminate the possibility of losing any committed data in the database Chapter 14, “Troubleshooting” Reviews some of the places to look for error messages, along with some general troubleshooting techniques Index U underlying platform, and Oracle’s Tuning Methodology, 243 UNION ALL set operator, 126–130 UNION keyword, 126 UNION set operator, 126–130 UNIQUE constraints, 146–147 unique indexes, 209, 245 UNKNOWN values, 82 UPDATE statement, 30–31, 30–31 uppercase in syntax, 24 user accounts, creating, 224–227 assigning passwords and, 224–225 default tablespaces and quotas and, 226–227, 227 profiles and, 225–226 USER_ data dictionary views, 212 user-defined functions, 65–67 user-defined views, 210–212 user trace files, 297–301 converting, 300–301, 301 enabling tracing, 298 locating, 298–300, 300 username, defined, 224 users backup and recovery methods for, 268–275 Export utility (EXP), 269–271 flashback query, 273–275 Import utility (IMP), 271–273 object privileges, 229–231 user errors, 268 user privileges, 228 Index V views, 210–217 data dictionary, 212–215 dynamic performance, 215–217 user-defined, 210–212 V$INSTANCE, 216–217 V$OBJECT_USAGE clause, 249–250 V$SESSION, 216 Index W Web sites for data modeling tools, 7 IBM DB2/UDB, 329 Microsoft Access information, 330 Microsoft SQL Server information, 329 MySQL information, 330 Oracle information, 329 Sybase products, 329 for troubleshooting assistance with Metalink, 301 for troubleshooting assistance with Technet, 301 WebSphere, 329 WHERE clause, 72–82, 72 BETWEEN operator and, 76–78 IN operator and, 79–80 AND, OR, and NOT operators and, 74–76 comparison conditions and, 72–74 IS NULL and IS NOT NULL and, 81–82 LIKE operator and, 80–81 wildcard characters, and LIKE operator, 80 Windows, and running SQL*Plus, 15 wizards See Backup Wizard Where Can I Find? Aggregating data Chapter 4 Alert log file Chapter 14 Application tuning Chapter 12 Auditing Chapter 11 Backups Chapter 13 Built-in functions Chapter 3 Cartesian products Chapter 5 Configuring iSQL*Plus Chapter 9 Constraints Chapter 7 Correlated subqueries Chapter 6 Creating a database Chapter 8 Creating external tables Chapter 10 Creating relational tables Chapter 10 CUBE operator Chapter 6 Data dictionary views Chapter 10 Data modeling Chapter 1 Database failure types Chapter 13 DCL commands Chapter 2 DDL commands Chapter 2 Disk and memory structures Chapter 8 DML commands Chapter 2 Dynamic performance views Chapter 10 Equijoins Chapter 5 Export utility Chapter 13 Flashback queries Chapter 13 Formatting reports Chapter 9 Functions Chapter 3 Granting privileges Chapter 11 GROUP BY clause Chapter 4 Grouping functions Chapter 4 HAVING clause Chapter 4 Import utility Chapter 13 Indexes Chapters 10 and 12 Inner joins Chapter 5 Installing Oracle software Chapter 8 INTERSECT operator Chapter 6 iSQL*Plus Chapter 2 Log Miner Chapter 13 Materialized views Chapter 12 Memory tuning Chapter 12 MINUS operator Chapter 6 Monitoring events Chapter 14 Multiple-column subqueries Chapter 6 Non-equijoins Chapter 5 Object privileges Chapter 11 Optimizer modes Chapter 12 Oracle Enterprise Manager Chapter 8 ORDER BY clause Chapter 4 Outer joins Chapter 5 Partitioned tables Chapter 12 Performance tuning Chapter 12 Privileges Chapter 11 Profiles Chapter 11 Query operators Chapter 3 Recovery Manager Chapter 13 Revoking privileges Chapter 11 Roles Chapter 11 ROLLUP operator Chapter 6 Scripts Chapter 9 SELECT statements Chapter 2 Self-joins Chapter 5 Sequences Chapter 10 Set operators Chapter 6 Sorting rows Chapter 4 SQL*Plus Chapter 2 SQL99 standard Chapter 5 Subqueries Chapter 6 Substitution variables Chapter 9 Synonyms Chapter 10 System privileges Chapter 11 System trace files Chapter 14 Transaction processing Chapter 7 UNION operator Chapter 6 User accounts Chapter 11 User trace files Chapter 14 User-defined functions Chapter 3 Views Chapter 10 WHERE clause Chapter 4 List of Tables Chapter 3: Oracle Database Functions Table 3.1: Standard and Conditional Operators and Precedence Table 3.2: Built-in String Functions Table 3.3: Built-in Numeric Functions Table 3.4: Built-in Date Functions Table 3.5: Built-in Conversion Functions Table 3.6: Numeric Format Examples Using TO_CHAR Table 3.7: Built-in General Functions Chapter 4: Restricting, Sorting, and Grouping Data Table 4.1: Comparison Operators Table 4.2: Common Group Functions List of Sidebars Chapter 1: Relational Database Concepts Hierarchical and Network Databases Chapter 10: Creating and Maintaining Database Objects Data Dictionary View Shorthand Chapter 12: Making Things Run Fast (Enough) The Pseudo-column ROWID ... Library of Congress Card Number: 2002115476 ISBN: 0-7821-4189-7 JumpStart is a trademark of SYBEX Inc SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc in the United States and/or other countries... Sybex offers the following: OCP: Oracle9i DBA Fundamentals II Study Guide (exam 1Z0- 032: Oracle9i Database: Fundamentals II) OCP: Oracle9i DBA Performance Tuning Study Guide (exam 1Z0-033: Oracle9i Database: Performance Tuning)... To help you obtain the OCA, Sybex provides the following: OCA/OCP: Introduction to Oracle9i SQL Study Guide (exam 1Z0007: Introduction to Oracle9i SQL) OCA/OCP: Oracle9i DBA Fundamentals I Study Guide (exam 1Z0-031: Oracle9i Database: Fundamentals I)