C ONTENTS ORACLE DBA SURVIVAL GUIDE ® Joseph B Greene 201 West 103rd Street Indianapolis, Indiana 46290 Untitled-1 4/7/97, 11:38 AM i O RACLE DBA S URVIVAL G UIDE ii I came into this world knowing nothing Therefore, this book is dedicated to all the people along the way who took the time to teach me something A CQUIS ITI ON S E DIT OR Rosemarie Graham D EVELOP MENT E DI TOR Todd Bumbalough C OPYRIGHT © 1995 BY S AMS P UBLISHING FIRST EDITION S OFT WARE D EVELOPMEN T SPECIALIST Steve Flatt All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Neither is any liability assumed for damages resulting from the use of the information contained herein For information, address Sams Publishing, 201 W 103rd St., Indianapolis, IN 46290 P RO D UCT IO N E D I TO R Nancy Albright T ECHNICAL R EVIEWER Byron Pearce Mark Gokman E D I TO RI AL C O O RDI N ATO R Bill Whitmer International Standard Book Number: 0-672-30681-6 T ECHNICAL E DIT COORDI NATOR Library of Congress Catalog Card Number: 95-67649 Lynette Quinn 98 97 96 95 FORMATT ER Interpretation of the printing code: the rightmost double-digit number is the year of the book’s printing; the rightmost single-digit, the number of the book’s printing For example, a printing code of 95-1 shows that the first printing of the book occurred in 1995 Composed in New Century Schoolbook and MCPdigital by Macmillan Computer Publishing Printed in the United States of America All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams Publishing cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark PRESIDENT AND PUBLISHER ACQUISITIONS MANAGER DEVELOPMENT MANAGER MANAGING EDITOR MARKETING MANAGER Richard K Swadley Greg Wiegand Dean Miller Cindy Morrow Gregg Bushyeager Frank Sinclair C OVER D ESIGN ER Tim Amrhein B OOK D ESIGNER Alyssa Yesh P RODUCT ION T EAM S UPERVISOR Brad Chinn P AGE L AYOUT Louisa Klucznik Brian-Kent Proffitt Tina Trettin Susan Van Ness PROOF READI NG Nancy Price Brian-Kent Proffitt Erich Richter Susan D Van Ness Paul Wilson INDEXER Cheryl Dietsch Untitled-1 4/7/97, 11:38 AM C ONTENTS Overview Preface xvii Introduction P ART I OF THE O RACLE DBA The World of a Database Administrator The Database Administrator’s Job Description 13 History and Development of Databases and Oracle 43 Oracle and Its Environments 55 The Tools of the Trade 75 P ART II U NDERSTANDING H OW O RACLE W ORKS How the Oracle RDBMS Works Oracle Memory Structures 109 Oracle Files 123 Oracle Processes 137 10 Basic Oracle Database Objects 153 11 Oracle System Privileges 171 12 Oracle Object Privileges 191 13 Roles and Grants 205 14 Backup and Recovery 223 P ART III I NSTALLING AND U PGRADING 97 THE O RACLE S OFTWARE 15 The Life Cycle of an Oracle Database 251 16 Choosing Products and the Environment for Your Oracle Database 261 17 Planning an Oracle Installation 277 18 Oracle Installations 295 19 Planning an Oracle Upgrade 311 20 Oracle Upgrades 321 P ART IV Untitled-1 T HE J OB xviii DEVELOPING A D ATABASE A DMINISTRATION S CHEME 21 The Database Administration Scheme 329 22 Laying Out a Database 339 23 A Routine Maintenance Schedule 351 24 Developing Scripts to Automate Tasks 363 4/7/97, 11:38 AM iii iv O RACLE DBA S URVIVAL G UIDE P ART V T HE D AILY R OUTINE 25 The “Typical” Day 383 26 User Account Maintenance 393 27 Tablespace Maintenance 409 28 Table and Index Maintenance 423 P ART VI MONITORING D ATABASE ’ S HEALTH 29 The Health of a Database 447 30 Routine Monitoring 457 31 Auditing 479 32 Tuning the Database 495 33 Looking Toward the Future 517 P ART VII D EALING WITH P ROBLEMS 34 When Problems Occur 531 35 Space Problems 547 36 Instance and Application Crashes 563 37 When the Database Is Too Slow 575 38 Troubleshooting Checklist 585 P ART VIII S UPPORTING U SERS AND D EVELOPERS 39 Sound Database Object Design 593 40 Query Optimization 611 41 Keeping Current as a DBA 629 P ART IX Untitled-1 THE A DVANCED O RACLE T ECHNICAL F EATURES 42 Rollback Segments 641 43 L oc ks 649 44 Parallel Processing Options 655 45 Packages, Procedures, and Triggers 663 46 Client-Server and Networking 673 47 Where To Next? 681 48 Oracle Workgroup Server and Oracle 7.2 687 4/7/97, 11:38 AM C ONTENTS A PPENDIXES A SQL Commands 695 B Glossary of Terms 701 C SQL*Plus Features 705 D SQL*DBA Features 711 E SQL*Loaders 715 F Import and Export 719 G Where to Get More Information 725 H Sample System Configuration Analyses 727 The Disk Contents 731 Index 737 I Untitled-1 4/7/97, 11:38 AM v 768 UPGRADING planning, 258-259 README file, 312-315 storing new software, 314 support, 318 testing, 316 troubleshooting, 325-326 UPS (uninterruptable power supplies), 270 USE_MERGE hint, 623 USE_NL hint, 623 user account maintenance, 394-408 adding new users, 399-402 changing privileges, 402-406 deleting user accounts, 406-407 granting privileges, 400-402 group accounts, 398 operating system logon IDs, 396-399 passwords, 402 security schemes, 394-396 SQL*Net, 398 temporarily disabling users, 407 users administration (DBA job description), 21, 28-32 expectations (database speed), 578-579 future requirements planning database expansion, 520-522 groups (DBA continuing education), 637-638 privileges, 177-178 processing schedules (database administration schemes), 355-357 requirements (database administration schemes), 335-336 server processes (Oracle), 101 service processes, 138-139 sessions, killing user sessions (SQL*DBA), 713 support (DBA job description), 21, 28, 39-42 DBA daily routine overview, 387-388 User Manager, 65, 86 util_ck.sql script, 735 utilities, 63-65 at utility (UNIX), 374 Backup Manager, 64, 83-84 cron utility (UNIX), 374-377 Database Expander, 64, 85-86 Database Manager, 64, 83 Export, 63, 78, 90-91, 227, 238-239, 721 example, 721-722 selecting backup schemes, 241 Import, 63, 78, 90-91, 703, 720-723 command line mode, compared to interactive mode, 720 example, 722-723 parameters, 720-721 job submission utilities (database administration schemes), 373-377 Object Manager, 65, 86 ODBC Administrator, 84 Oracle Installer, 63 Oracle Network Manager, 63-64 Oracle Terminal, 63 Password Manager, 64, 84 Recovery Manager, 65, 86-87 Server Manager, 81-82 Session Manager, 64, 83 SQL*DBA, 63, 78, 78-81, 703, 712-713 command line mode, 712 compared to SQL*Plus, 709 executing scripts, 370-371 functions, 80-81 killing user sessions, 713 menu mode, 712 monitor locks option, 653-654 monitoring capabilities, 713 SQL*Loader, 63, 78, 91-92, 716-717 badfile optional parameter, 717 example control file, 717 fixed column formats, 716 load tables, 716 log file optional parameter, 717 population scripts, 716 SQL*Net, 64 listeners, 150 listeners process, 290 log files, 135 multi-threaded servers, 149-150 user account maintenance, 398 X SQL*Plus, 61-62, 78, 88-90, 703, 706-709 calling, 706 compared to SQL*DBA, 709 executing shell scripts, 370-373 formatting columns, 89 output formatting, 706-708 reports, 367-369 scripts, 708-709 trace utility (optimizing queries), 624-625 User Manager, 65, 86 utilization report monitoring databases, 452, 462-465 troubleshooting tablespaces, 548-551 V varchar2 data type, 161 variables, environmental variables, shell scripts, 371 VAX system, configuration, 271 vendor training programs, 632-634 vendors purchasing products, 274-276 technical support, 30-31 views, 158, 164-166, 424, 596 auditing databases, 482, 490-491 compared to summary calculation tables, 606 creating, 165 designing tables for decision support, 600-601 monitoring tablespaces, 416-418 privilege sets, 403-406 privileges, 194, 197-198 querying about privileges, 207-208 synonyms, 166-167 virtual memory, 111 LOCKS W warm backups, 226, 236-238 database administration schemes, 343 ending, 237 selecting backup schemes, 240-241 starting, 236 whenever clause (auditing databases), 489 white papers, 30 Windows, Oracle processes, 151 Workgroups Server, 688690 WorldWideWeb(WWW) DBA continuing education, 636-637 technical support, 543 writing to data files, 101 X–Y–Z X locks, 652 769 ... RACLE W ORKS How the Oracle RDBMS Works Oracle Memory Structures 109 Oracle Files 123 Oracle Processes 137 10 Basic Oracle Database Objects 153 11 Oracle System Privileges 171 12 Oracle Object Privileges... Cycle of an Oracle Database 251 16 Choosing Products and the Environment for Your Oracle Database 261 17 Planning an Oracle Installation 277 18 Oracle Installations 295 19 Planning an Oracle Upgrade... schemes), 335-336 server processes (Oracle) , 101 service processes, 138-139 sessions, killing user sessions (SQL *DBA) , 713 support (DBA job description), 21, 28, 39-42 DBA daily routine overview, 387-388