SQL Bible, Is the Most Up-To-Date and Complete Reference Available on SQL
Total Page:16
File Type:pdf, Size:1020Kb
525840 CoverPerfect 3/11/03 Bind • Trim:8:51 AM7 3/8 Page x 19 1/4 • • 4 color process • Yellow prints 110y 15m • + spot varnish (see spot varnish pdf) • Matte laminate If SQL can do it, you can do it too . Here, in one definitive volume, is all the information you need to understand and use SQL and its implementa- 100% COMPREHENSIVE 100% tions in accordance with the established SQL99 standard. Whether you want to learn database programming ONE HUNDRED PERCENT from scratch, you’d like to sharpen your SQL skills, or you need to know more about programming for a COMPREHENSIVE AUTHORITATIVE heterogeneous database environment, this book provides the complete menu. Tutorials and code examples in WHAT YOU NEED each chapter make it an indispensable reference for every level of expertise. ONE HUNDRED PERCENT Inside, you’ll find complete coverage of SQL Identify vendor- SQL specific dialect and • Understand the definition and characteristics of relational databases and SQL’s role within RDBMS SQL syntax variations in • Recognize vendor-specific implementation variations among Oracle, IBM DB2 UDB, and MS SQL Server IBM DB2 UDB, Oracle, • Create and modify RDBMS objects like tables, views, indexes, synonyms, sequences, and schemas using and Microsoft SQL Data Definition Language (DDL) Server • Comprehend Data Manipulation Language (DML) from different vendors’ JOIN3 (PROD_ID_N = ORDLINE_PRODID_FN) JOIN2 (ORDHDR_ID_N = ORDLINE_ORDHDRID_FN) Explore SQL security JOIN1 (CUST_ID_N = ORDHDR_CUSTID_FN) perspectives ORDER_LINE ORDLINE_ID_N features implemented ORDLINE_ORDHDRID_FN PRODUCT ORDER_HEADER ORDLINE_PRODID_FN PROD_ID_N ORDHDR_ID_N ORDLINE_ORDQTY_N PROD_PRICE_N ORDHDR_PAYTERMS_FN ORDLINE_SHIPQTY_N PROD_NUM_S CUSTOMER ORDHDR_STATUSID_FN ORDLINE_CREATEDATE_D PROD_DESCRIPTION_S • Master single-table select statements and multitable queries from the CUST_ID_N ORDHDR_CUSTID_FN ORDLINE_CREATEDBY_S PROD_STATUS_S by major RDBMS CUST_PAYTERMSID_FN ORDHDR_SALESMANID_FN PROD_BRAND_S CUST_SALESMANID_FN ORDHDR_NBR_S PROD_PLTWID_N CUST_STATUS_S ORDHDR_INVOICENBR_N PROD_PLTLEN_N CUST_NAME_S ORDHDR_ORDERDATE_D PROD_NETWGHT_N ground up CUST_ALIAS_S ORDHDR_INVOICEDATE_D PROD_SHIPWEIGHT_N CUST_CREDHOLD_S ORDHDR_CANCELDATE_D vendors ORDHDR_CREDITHOLD_S ORDHDR_READYTOINVOICE_S ORDHDR_NOTES_S ORDHDR_CREATEDBY_S ORDHDR_CREATEDATE_D • Explore in-depth SQL functions, operators, and data types for major Enlarge your RDBMS implementations understanding of • Discover new SQL developments including XML, OLAP, Web services, Master the art of standard SQL for and object-oriented features joining multiple tables for building heterogeneous data- powerful queries base environments /u02/oradata/acme/data01.dbf DATA01 /u02/oradata/acme/data02.dbf /u02/oradata/acme/data03.dbf Bonus CD-ROM includes: Understand the /u03/oradata/acme/index01.dbf INDEX01 • IBM® DB2® Universal Database Personal Edition v 8.1 for Windows® /u03/oradata/acme/index02.dbf relationship Operating Environments Evaluation copy between logical KRIEGEL • Complete original database example files from the authors LOB01 /u04/oradata/acme/lob01.dbf structure and • Complete book in PDF format physical storage & TRUKHNOV www.wiley.com/compbooks/ SQLSQL System Requirements: $49.99 USA Reader Level: Shelving Category: Bible PC running Windows NT v4 or later, ME, 2000, XP. $74.99 Canada Beginning to Advanced Programming/Software Intel Pentium processor or equivalent. At least £34.95 UK Development 128 MB of RAM and 450 MB of free disk space. Trial software A CD-ROM drive. See the About the CD appendix and more on CD-ROM! for details and complete system requirements. ISBN 0-7645-2584-0 BONUS CD-ROM Covers SQL99 ® ® IBM DB2 Universal Database standard Personal Edition v 8.1 for Windows® evaluation copy and original database *85555-IGDJJg ,!7IA7G4-fcfieb!:p;o;t;T;T example files Alex Kriegel and Boris M. Trukhnov 00 525840 RA.qxd 3/14/03 9:49 AM Page oi The WILEY Dear Valued Customer, advantage We realize you’re a busy professional with deadlines to hit. Whether your goal is to learn a new technology or solve a critical problem, we want to be there to lend you a hand. Our primary objective is to provide you with the insight and knowledge you need to stay atop the highly competitive and ever- changing technology industry. Wiley Publishing, Inc., offers books on a wide variety of technical categories, including security, data warehousing, software development tools, and networking — everything you need to reach your peak. Regardless of your level of expertise, the Wiley family of books has you covered. • For Dummies® – The fun and easy way™ to learn • The Weekend Crash Course® –The fastest way to learn a new tool or technology • Visual – For those who prefer to learn a new topic visually • The Bible – The 100% comprehensive tutorial and reference • The Wiley Professional list – Practical and reliable resources for IT professionals The book you now hold, SQL Bible, is the most up-to-date and complete reference available on SQL. It covers the latest approved SQL specification, SQL99, in its standard format, and you can apply the code and techniques in this book to SQL databases from any major vendor, including Microsoft SQL Server, Oracle, and IBM DB2. With the authors’ emphasis on standard SQL, you can implement heterogeneous database applications and be confident that the code will work across any major vendor offering. Whether you are a database administrator making your first foray into database programming or an experienced database programmer in need of a solid SQL99 reference, you’ll find SQL Bible your complete solution. Our commitment to you does not end at the last page of this book. We’d want to open a dialog with you to see what other solutions we can provide. Please be sure to visit us at www.wiley.com/compbooks to review our complete title list and explore the other resources we offer. If you have a comment, suggestion, or any other inquiry, please locate the “contact us” link at www.wiley.com. Thank you for your support and we look forward to hearing from you and serving your needs again in the future. Sincerely, Richard K. Swadley Vice President & Executive Group Publisher Wiley Technology Publishing 00 525840 RA.qxd 3/14/03 9:49 AM Page oii 01 525840 FM.qxd 3/14/03 9:49 AM Page i SQL Bible 01 525840 FM.qxd 3/14/03 9:49 AM Page ii 01 525840 FM.qxd 3/14/03 9:49 AM Page iii SQL Bible Alex Kriegel and Boris M. Trukhnov 01 525840 FM.qxd 3/14/03 9:49 AM Page iv SQL Bible Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2003 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada Library of Congress Control Number: 2003101832 ISBN: 0-7645-2584-0 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/QU/QU/QT/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8700. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail: [email protected]. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY 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. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE. 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. For general information on our other products and services or to obtain technical support, 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. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Trademarks: Wiley, the Wiley Publishing logo and related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc., in the United States and other countries, and may not be used without written permission. IBM and DB2 are trademarks of IBM Corporation in the United States, other countries, or both. Windows is a trademark of Microsoft Corporation in the United States, other countries, or both. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. is a trademark of Wiley Publishing, Inc. 01 525840 FM.qxd 3/14/03 9:49 AM Page v About the Authors Alex Kriegel, MCP/MCSD, has worked for Pope & Talbot, Inc., in Portland, Oregon, since 2001 as Senior Programmer/Analyst; prior to that, he worked for Psion Teklogix International, Inc., in the same capacity. He received his B.S. in Physics of Metals from Polytechnic Institute of Belarus in 1988, discovered PC programming in 1992, and has never looked back since. He is also the author of Microsoft SQL Server 2000 Weekend Crash Course (Wiley, 2001). Boris M. Trukhnov, OCP, has been working as Senior Technical Analyst/Oracle DBA for Pope & Talbot, Inc., in Portland, Oregon, since 1998. His previous job titles include Senior Programmer Analyst, Senior Software Developer, and Senior Operations Analyst. He has been working with SQL and relational databases since 1994. Boris holds a B.S.