Using Your Sybex Electronic Book T o realize the full potential of this Sybex electronic book, you must have Adobe Acrobat Reader with Search installed on your computer. To find out if you have the correct version of Acrobat Reader, click on the Edit menu—Search should be an option within this menu file. If Search is not an option in the Edit menu, please exit this application and install Adobe Acrobat Reader with Search from this CD (double- click on rp500enu.exe in the Adobe folder). Navigation To search, click the Search Query button on the toolbar or choose Edit >Search > Query to open the Search window. In the Adobe Acrobat Search dialog’s text field, type the text you want to find and click Search. Use the Search Next button (Control+U) and Search Previous button (Control+Y) to go to other matches in the book. The Search command also has powerful tools for limiting and expanding the definition of the term you are searching for. Refer to Acrobat's online Help (Help > Plug-In Help > Using Acrobat Search) for more information. www.sybex.com Click here to begin using your Sybex E lectronic Book! Search Navigate throught the book by clicking on the headings that appear in the left panel; the corresponding page from the book displays in the right panel. San Francisco • London OCA/OCP: Introduction to Oracle9i ™ SQL Study Guide Chip Dawes Biju Thomas www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CA Associate Publishers: Richard Mills and Neil Edde Acquisitions Editor: Christine McGeever Developmental Editor: Elizabeth Hurley Editors: Marilyn Smith and Carol Henry Production Editor: Leslie E. H. Light Technical Editors: Ashok Hanumanth and Damir Bersinic Graphic Illustrator: Tony Jonick Electronic Publishing Specialist: Jill Niles Proofreaders: Emily Hsuan, David Nash, Laurie O’Connell, and Nancy Riddiough Indexer: Ted Laux CD Coordinator: Dan Mummert CD Technician: Kevin Ly Book Designer: Bill Gibson Cover Designer: Archer Design Cover Photographer: Photo Researchers Copyright © 2002 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 photo- copy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher. Library of Congress Card Number: 2001099188 ISBN: 0-7821-4062-9 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 © 1991-1999 Inbit Incorporated. All rights reserved. FullShot is a trademark of Inbit Incorporated. 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. Internet screen shot(s) using Microsoft Internet Explorer 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 Associate/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 Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com To Our Valued Readers: In a CertCities.com article dated December 15, 2001, Oracle certification was ranked #2 in a list of the “10 Hottest Certifications for 2002.” This shouldn’t come as a surprise, especially when you consider the fact that the OCP program nearly tripled in size (from 30,000 to 80,000) in the last year. Oracle continues to expand its dominance in the database market, and as companies begin integrating Oracle9i systems into their IT infrastructure, you can be assured of high demand for professionals with the Oracle Certified Associate and Oracle Certified Professional certifications. Sybex is proud to have helped thousands of Oracle certification candidates prepare for the exams over the years, and we are excited about the opportunity to continue to provide professionals like you with the skills needed to succeed in the highly competitive IT industry. Our authors and editors have worked hard to ensure that the Oracle9i Study Guide you hold in your hands is comprehensive, in-depth, and pedagogically sound. We’re confident that this book will meet and exceed the demanding standards of the certification marketplace and help you, the Oracle9i certification candidate, succeed in your endeavors. Good luck in pursuit of your Oracle9i certification! Neil Edde Associate Publisher—Certification Sybex, Inc. SYBEX Inc. 1151 Marina Village Parkway, Alameda, CA 94501 Tel: 510/523-8233 Fax: 510/523-2373 HTTP://www.sybex.com www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 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 of the 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 Soft- ware 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 SYBEX warrants the enclosed media to be free of physical defects for a period of ninety (90) days after purchase. The 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. Product Support Department 1151 Marina Village Parkway Alameda, CA 94501 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 pur- chase, 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 redis- tributing these files without authorization is expressly forbidden except as specifically provided for by the Owner(s) therein. www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com To my wife, Mary Chip Dawes To my son Joshua, the new light in my life Biju Thomas www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Acknowledgments I would like to acknowledge Jerie Dahlman for her help with many of the questions used in this book. Many thanks to the Sybex team—Elizabeth Hurley, Leslie Light, and Marilyn Smith—your skill and efforts have made for a fine book. Lastly, thank you to my family— Mary, Zachary, and Charlie—for giving me the support I needed to complete this book. Chip Dawes Within a couple of days of Oracle announcing the beta exams for Oracle9i certification, Sybex contacted me to inquire about my interest in another project. I'm impressed by the market awareness of Sybex and thank Sybex for considering me for this project. I would like to thank the following wonderful people at Sybex for their support and patience. Christine McGeever (Acquisition Editor) for getting me started on this project. Her timely call helped me register for the Oracle9i beta exams and get my Oracle9i certification, even before the exams were in production. Elizabeth Hurley (Development Editor) for her support and valuable comments. Leslie Light (Production Editor) for her patience and understanding, and making sure every piece of the book ties together and also keeping us on schedule. I know many more people from Sybex contributed to this book; I thank each one of them for their hard work and the high quality of that work. I owe Marilyn Smith (Editor) for her hard work. Marilyn, your edits and topic rearrangements definitely improved the quality of the chapters. Thank you. I thank Carol Henry for her edits and comments. I thank Ashok Hanumanth and Damir Bersinic for their technical review and valuable comments. Thank you Chip for your ideas and suggestions, and for taking time to reply to most of the reader comments. It would not have been possible for me to participate in this project if my parents had not come over to the U.S. from India, to take care of our son Joshua. I thank my parents for taking care of the baby and house for the past five months. Thank you Shiji for your endless support and love. Last, but not least, I thank my colleagues for their support and friendship. Thank you Wendy for understanding me so well and all the help you provided. Thank you all— you are the best to work with. Biju Thomas www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Introduction T here is high demand for professionals in the information technology (IT) industry, and Oracle certifications are the hottest credential in the data- base world. You have made the right decision to pursue certification, because being Oracle certified will give you a distinct advantage in this highly competitive market. Many readers may already be familiar with Oracle and do not need an introduction to the Oracle database world. For those who aren’t familiar with the company, Oracle, founded in 1977, sold the first commercial relational database and is now the world’s leading database company and second-largest independent software company, with revenues of more than $10 billion, serving more than 145 countries. Oracle databases are the de facto standard for large Internet sites, and Oracle advertisers are boastful but honest when they proclaim, “The Internet Runs on Oracle.” Almost all big Internet sites run Oracle databases. Oracle’s penetration of the database market runs deep and is not limited to dot-com implementations. Enterprise resource planning (ERP) application suites, data warehouses, and custom applications at many companies rely on Oracle. The demand for DBA resources remains higher than others during weak economic times. This book is intended to help you on your exciting path toward becoming an Oracle9i Oracle Certified Associate (OCA), which is the first step on the path toward Oracle Certified Professional (OCP) and Oracle Certified Master (OCM) certification. Basic knowledge of Oracle SQL is an advantage when reading this book but is not mandatory. Using this book and a practice data- base, you can start learning Oracle and pass the IZ0-007 test: Introduction to Oracle9i: SQL. Why Become an Oracle Certified Professional? The number one reason to become an OCP is to gain more visibility and greater access to the industry’s most challenging opportunities. Oracle cer- tification is the best way to demonstrate your knowledge and skills in Oracle database systems. The certification tests are scenario-based, which is the most effective way to assess your hands-on expertise and critical problem- solving skills. www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com xxii Introduction Certification is proof of your knowledge and shows that you have the skills required to support Oracle core products. The Oracle certification pro- gram can help a company to identify proven performers who have demon- strated their skills and who can support the company’s investment in Oracle technology. It demonstrates that you have a solid understanding of your job role and the Oracle products used in that role. OCPs are among the best paid in the IT industry. Salary surveys consis- tently show the OCP certification to yield higher salaries than other certifi- cations, including Microsoft, Novell, and Cisco. So, whether you are beginning a career, changing careers, securing your present position, or seeking to refine and promote your position, this book is for you! Oracle Certifications Oracle certifications follow a track that is oriented toward a job role. There are database administration, database operator, and developer tracks. Within each track, Oracle has a three-tiered certification program: The first tier is the Oracle Certified Associate (OCA). OCA certifica- tion typically requires you to complete two exams, the first via the Internet and the second in a proctored environment. The second tier is the Oracle Certified Professional (OCP), which builds upon and requires an OCA certification. The additional requirements for OCP certification are additional proctored exams. The third, and highest, tier is the Oracle Certified Master (OCM). OCM certification builds upon and requires OCP certification. To achieve OCM certification, you must attend two advanced Oracle Education classroom courses (from a specific list of qualifying courses) and complete a practicum exam. The following material will address only the database administration track, because at the time of this writing, it was the only 9i track offered by Oracle. The other tracks have 8 and 8i certifications and will undoubtedly have 9i certifications. See the Oracle website at http://www.oracle.com/ education/certification for the latest information. www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Introduction xxiii Oracle9i Certified Database Associate The role of the database administrator (DBA) has become a key to success in today’s highly complex database systems. The best DBAs work behind the scenes, but are in the spotlight when critical issues arise. They plan, create, maintain, and ensure that the database is available for the business. They are always watching the database for performance issues and to prevent unscheduled downtime. The DBA’s job requires broad understanding of the architecture of Oracle database and expertise in solving problems. The Oracle9i Certified Database Associate is the entry-level certification for the database administration track and is required to advance toward the more senior certification tiers. This certification requires you to pass two exams that demonstrate your knowledge of Oracle basics: 1Z0-007: Introduction to Oracle9i: SQL 1Z0-031: Oracle9i Database: Fundamentals I The 1Z0-007 exam, Introduction to Oracle9i: SQL, is offered on the Internet. The 1Z0-031 exam, Oracle9i Database: Fundamentals I, is offered at a Sylvan Prometric facility. Oracle9i Certified Database Administrator The OCP tier of the database administration track challenges you to dem- onstrate your continuing experience and knowledge of Oracle technologies. The Oracle9i Certified Database Administrator certification requires achieve- ment of the Certified Database Associate tier, as well as passing the following two exams at a Sylvan Prometric facility: 1Z0-032: Oracle9i Database: Fundamentals II 1Z0-033: Oracle9i Database: Performance Tuning Oracle9i Certified Master The Oracle9i Certified Master is the highest level of certification that Oracle offers. To become a certified master, you must first achieve Certified Data- base Administrator status, then complete two advanced instructor-led classes at an Oracle education facility, and finally pass a hands-on exam at Oracle Education. The classes and practicum exam are offered only at an www.sybex.com Copyright ©2002 SYBEX, Inc., Alameda, CACopyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com [...]... notice OCA /OCP Study Guides The Oracle9i database administration track certification consists of four tests: two for OCA level and two more for OCP level Sybex offers several study guides to help you achieve these certifications: OCA /OCP: Introduction to Oracle9i SQL Study Guide (exam 1Z 0-0 07: Introduction to Oracle9i: SQL) OCA /OCP: Oracle9i DBA Fundamentals I Study Guide (exam 1Z 0-0 31: Oracle9i Database:... Database: Fundamentals I) OCP: Oracle9i DBA Fundamentals II Study Guide (exam 1Z0032: Oracle9i Database: Fundamentals II) OCP: Oracle9i DBA Performance Tuning Study Guide (exam 1Z0033: Oracle9i Database: Performance Tuning) Additionally, these four books are offered in a boxed set: OCP: Oracle9i DBA Certification Kit Copyright ©2002 SYBEX, Inc., Alameda, CA www .sybex. com Introduction xxv Skills Required... order_total) VALUES (customer_id, sales_rep_id, order_total) WHEN order_mode ='direct' THEN INTO direct_orders (customer_id, sales_rep_id, order_total) VALUES (customer_id, sales_rep_id, order_total) WHEN order_mode in ('online','direct') THEN INTO direct_orders (customer_id, sales_rep_id, order_total) VALUES (customer_id, sales_rep_id, order_total) SELECT order_mode, customer_id, sales_rep_id, order_total... written to hit you hard and make sure you are ready for the exam Between the Review Questions, Practice Exams, and flashcards, you should be more than prepared for the exam Copyright ©2002 SYBEX, Inc., Alameda, CA www .sybex. com xxx Introduction OCA /OCP: Introduction to Oracle9i SQL Study Guide in PDF Sybex offers this Oracle certification book on the CD so you can read the book on your PC or laptop It...xxiv Introduction Oracle education facility and may require travel The advanced classes that will count toward your OCM requirement include the following: Oracle9i: Program with PL /SQL Oracle9i: Advanced PL /SQL Oracle9i: SQL Tuning Workshop Oracle9i: High Availability in an Internet Environment Oracle9i: Database: Implement Partitioning Oracle9i: Real Application Clusters Implementation Oracle9i: ... a NOT IN operator, no rows will be returned C Only = and != operators can be used to search for NULL values in a column D In an ascending order sort, NULL values appear at the bottom of the result set E Concatenating a NULL value to a non-NULL string results in a NULL Copyright ©2002 SYBEX, Inc., Alameda, CA www .sybex. com xxxii Assessment Test 4 Which components are required to run iSQL*Plus from your... constraints Copyright ©2002 SYBEX, Inc., Alameda, CA www .sybex. com Answers to Assessment Test xlvii 16 B You cannot rename a column in the table To rename a column, you must re-create a table or create a view on the table with the new column name See Chapter 7 for more information about modifying tables 17 D, E, F, G The INTERVAL DAY TO SECOND datatype is new to Oracle9i and is used to store an interval between... Oracle and SQL Each chapter begins with a list of exam objectives Chapter 1 Starts with the fundamentals of SQL and describes how to construct simple queries Chapter 2 Discusses SQL* Plus, Oracle’s tool to interact with the database Chapter 3 Discusses the single-row functions available in Oracle, with details on how and where to use them Chapter 4 Explains data aggregations, Oracle’s built-in group... discipline Try to set aside the same time period every day to study, and select a comfortable and quiet place to do so If you work hard, you will be surprised at how quickly you learn this material All the best! What’s on the CD? We have worked hard to provide some really great tools to help you with your certification process All of the following tools should be loaded on your workstation when you’re studying... extremely helpful to readers who fly or commute on a bus or train and don’t want to carry a book, as well as to readers who find it more comfortable reading from their computer How to Contact the Authors You can reach Chip Dawes through D & D Technologies, Inc (www.ddtechnologies.com)—a Chicago-based consultancy— or e-mail him at chip@ddtechnologies.com To contact Biju Thomas, you can e-mail him at biju@bijoos.com . several study guides to help you achieve these certifications: OCA /OCP: Introduction to Oracle9i SQL Study Guide (exam 1Z 0-0 07: Introduction to Oracle9i: SQL) . OCA /OCP: Oracle9i DBA Fundamentals I Study Guide (exam 1Z 0-0 31: Oracle9i Database: Fundamentals I) OCP: Oracle9i DBA Fundamentals II Study Guide