OCP: Oracle8i DBA SQL and PL/SQL Study Guide Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com OCP: Oracle8i™ DBA SQL and PL/SQL Study Guide Chip Dawes Biju Thomas San Francisco • Paris • Düsseldorf • Soest • London Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Associate Publisher: Richard Mills Contracts and Licensing Manager: Kristine O’Callaghan Acquisitions & Developmental Editor: Kim Goodfriend Associate Developmental Editor: Ben Tompkins Editor: Nancy Conner, Marilyn Smith Production Editors: Lisa Duran, Leslie E H Light Technical Editors: Betty MacEwen, Ashok Hanumanth Book Designer: Bill Gibson Graphic Illustrator: Tony Jonick Electronic Publishing Specialist: Susie Hendrickson Proofreader: Lindy Wolf Indexer: Matthew Spence CD Coordinator: Kara Eve Schwartz CD Technician: Keith McNeil Cover Design: Archer Design Cover/Photograph: Photo Researchers Copyright © 2000 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: 00-105388 ISBN: 0-7821-2682-0 SYBEX and the SYBEX logo are trademarks of SYBEX Inc in the USA and other countries The CD interface was created using Macromedia Director, COPYRIGHT 1994, 1997-1999 Macromedia Inc For more information on Macromedia and Macromedia Director, visit http://www.macromedia.com 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Software License Agreement: Terms and Conditions The media and/or any online materials accompanying this book that are available now or in the future contain programs and/or text files (the "Software") to be used in connection with the book SYBEX hereby grants to you a license to use the Software, subject to the terms that follow Your purchase, acceptance, or use of the Software will constitute your acceptance of such terms The Software compilation is the property of SYBEX unless otherwise indicated and is protected by copyright to SYBEX or other copyright owner(s) as indicated in the media files (the "Owner(s)") You are hereby granted a single-user license to use the Software for your personal, noncommercial use only You may not reproduce, sell, distribute, publish, circulate, or commercially exploit the Software, or any portion thereof, without the written consent of SYBEX and the specific copyright owner(s) of any component software included on this media In the event that the Software or components include specific license requirements or end-user agreements, statements of condition, disclaimers, limitations or warranties ("End-User License"), those End-User Licenses supersede the terms and conditions herein as to that particular Software component Your purchase, acceptance, or use of the Software will constitute your acceptance of such End-User Licenses By purchase, use or acceptance of the Software you further agree to comply with all export laws and regulations of the United States as such laws and regulations may exist from time to time Reusable Code in This Book The authors created reusable code in this publication expressly for reuse for readers Sybex grants readers permission to reuse for any purpose the code found in this publication or its accompanying CD-ROM so long as all three authors are attributed in any application containing the reusable code, and the code itself is never sold or commercially exploited as a stand-alone product Software Support Components of the supplemental Software and any offers associated with them may be supported by the specific Owner(s) of that material but they are not supported by SYBEX Information regarding any available support may be obtained from the Owner(s) using the information provided in the appropriate read.me files or listed elsewhere on the media Should the manufacturer(s) or other Owner(s) cease to offer support or decline to honor any offer, SYBEX bears no responsibility This notice concerning support for the Software is provided for your information only SYBEX is not the agent or principal of the Owner(s), and SYBEX is in no way responsible for providing any support for the Software, nor is it liable or responsible for any support provided, or not provided, by the Owner(s) Warranty Software is not available from SYBEX in any other form or media than that enclosed herein or posted to www.sybex.com If you discover a defect in the media during this warranty period, you may obtain a replacement of identical format at no charge by sending the defective media, postage prepaid, with proof of purchase to: SYBEX Inc Customer Service Department 1151 Marina Village Parkway Alameda, CA 94501 (510) 523-8233 Fax: (510) 523-2373 e-mail: info@sybex.com WEB: HTTP://WWW.SYBEX.COM After the 90-day period, you can obtain replacement media of identical format by sending us the defective disk, proof of purchase, and a check or money order for $10, payable to SYBEX Disclaimer SYBEX makes no warranty or representation, either expressed or implied, with respect to the Software or its contents, quality, performance, merchantability, or fitness for a particular purpose In no event will SYBEX, its distributors, or dealers be liable to you or any other party for direct, indirect, special, incidental, consequential, or other damages arising out of the use of or inability to use the Software or its contents even if advised of the possibility of such damage In the event that the Software includes an online update feature, SYBEX further disclaims any obligation to provide this feature for any specific duration other than the initial posting The exclusion of implied warranties is not permitted by some states Therefore, the above exclusion may not apply to you This warranty provides you with specific legal rights; there may be other rights that you may have that vary from state to state The pricing of the book with the Software by SYBEX reflects the allocation of risk and limitations on liability contained in this agreement of Terms and Conditions Shareware Distribution This Software may contain various programs that are distributed as shareware Copyright laws apply to both shareware and ordinary commercial software, and the copyright Owner(s) retains all rights If you try a shareware program and continue using it, you are expected to register it Individual programs differ on details of trial periods, registration, and payment Please observe the requirements stated in appropriate files Copy Protection The Software in whole or in part may or may not be copy-protected or encrypted However, in all cases, reselling or redistributing these files without authorization is expressly forbidden except as specifically provided for by the Owner(s) therein SYBEX warrants the enclosed media to be free of physical defects for a period of ninety (90) days after purchase The Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com To my wife Mary and my children Zachary and Charlie -Chip Dawes To my wife Shiji and my parents, who are there whenever I need support and guidance -Biju Thomas Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Glossary Primary Key Constraint A constraint on one or more columns that combines NOT NULL constraints on each protected column and a unique constraint on all protected columns The primary key uniquely identifies any row in a table 479 Script File A file that contains a set of commands that are run sequentially Self-Join A join that occurs when the table is joined to itself in a query Private Synonym A restricted alias to another object Sequence An Oracle object that provides unique sequential numbers Procedure A stored PL/SQL program that gets called as a statement A procedure does not return any value directly, but you may pass values to and from the procedure using parameters Procedures cannot be used in SQL statements Single-Row Functions Functions that operate on a single row at a time These functions know how many arguments they will operate on at compile time, before any data is fetched Public Synonym A global alias to another object SQL Buffer The area in SQL*Plus where the last command executed is saved Q SQL*Plus Oracle’s native tool to interact with the database Qualify To further specify a table or column name to avoid ambiguity The table name is qualified with its owner or schema name; a column name is qualified with its table name or alias name SQLCODE A built-in function that returns the current database error number Query A SELECT statement used to retrieve already-saved data from the database R Raise an Exception To cause an error to occur RDBMS Relational Database Management System The most widely used database concept in the information technology world Record A composite datatype SQLERRM A built-in function that returns the text of the current database error Statement A single SQL command that can include subqueries Structured Query Language SQL, the databaseaccess language to query and manipulate data in the database Sub-Block The block that appears inside a block in a nested block structure Subquery A query inside a query ROLLBACK An action that undoes the changes made to the database since the transaction began Subscript Notation The parenthetical notation used in references to elements in a collection ROWID The pseudo-column and physical address of a row in a table Synonym An alias name for an object Synonyms can mask the owner or even the database of the object SYS The schema that owns the Oracle data dictionary S SAVEPOINT A marker set in between DML statements in a single transaction to go back to a specific point Schema objects A logical grouping of Oracle database SCN System Change Number A number that represents a committed, consistent image of the database SCNs only increase with time T Table The basic unit of data storage in Oracle The data is stored in rows and columns Transaction A logical group of DML statements considered a single unit Together, the statements constitute an atomic view of data or an atomic change to data Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 480 Glossary Trigger A stored program unit created in the Oracle server, which is attached to an event and executes when the event occurs Prior to Oracle8i, a trigger was always attached to a table and the events were INSERT, UPDATE, and DELETE In Oracle8i, triggers can be created for database-level or user-level events Truncate To remove all rows of data from the table TYPE The statement used to define a record or collection U Unique Constraint A constraint on one or more columns in a table that ensures no two rows contain duplicate data in the protected columns User Another term used for schema Schema, user, and owner represent a logical grouping of database objects in the database V Variable A memory location to store a value, which may be used any number of times in the PL/SQL program The value of the variable can be changed inside the program View A logical representation of data from tables Views are stored queries W WHERE CURRENT OF A clause used in UPDATE and DELETE statements inside an explicit cursor to point to the most recent row fetched Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com ...OCP: Oracle8 i™ DBA SQL and PL /SQL Study Guide Chip Dawes Biju Thomas San Francisco • Paris • Düsseldorf • Soest • London Copyright ©2000 SYBEX , Inc., Alameda, CA www .sybex. com Associate... prior agreement and written permission of the publisher Library of Congress Card Number: 00-105388 ISBN: 0-7821-2682-0 SYBEX and the SYBEX logo are trademarks of SYBEX Inc in the USA and other countries... children Zachary and Charlie -Chip Dawes To my wife Shiji and my parents, who are there whenever I need support and guidance -Biju Thomas Copyright ©2000 SYBEX , Inc., Alameda, CA www .sybex. com Glossary