MTU Library Catalogue

Syndetics cover image
Image from Syndetics

The practical SQL handbook : using SQL variants / Judith S. Bowman ... [et al.]

By: Bowman, Judith S.
Contributor(s): Emerson, Sandra L, 1947- | Darnovsky, Marcy.
Material type: materialTypeLabelBookPublisher: Boston : Addison-Wesley, 2001Edition: 4th ed.Description: xxxvi, 469 p. : ill. ; 24 cm. + 1 computer optical disc (4 3/4 in.).ISBN: 0201703092.Subject(s): SQL (Computer program language) | Relational databasesDDC classification: 005.756
Contents:
SQL and Relational Database Management -- Designing Databases -- Creating and Filling a Database -- Selecting Data from the Database -- Sorting Data and Other Selection Techniques -- Grouping Data and Reporting from It -- Joining tables for Comprehensive Data Analysis -- Structuring Queries with Subqueries -- Creating and using views -- Security, Transactions, Performance and Integrity -- Solving Business Problems.
Holdings
Item type Current library Call number Copy number Status Barcode
General lending MTU Bishopstown Library Lending 005.756 (Browse shelf(Opens below)) 1 Available 00078544
General lending MTU Bishopstown Library CD 005.756 (Browse shelf(Opens below)) 1 Available 00095466
Total holds: 0

Enhanced descriptions from Syndetics:

This latest edition of the best-selling implementation guide to the Structured Query Language teaches SQL fundamentals while providing practical solutions for critical business applications. The Practical SQL Handbook, Fourth Edition now includes expanded platform SQL coverage and extensive real-world examples based on feedback from actual SQL users.

The Practical SQL Handbook begins with a step-by-step introduction to SQL basics and examines the issues involved in designing SQL-based database applications. It fully explores SQL#146;s most popular implementations from industry leaders, Oracle, Microsoft, Sybase, and Informix.

Highlights include:

Detailed coverage of SQL commands for creating databases, tables, and indexes, and for adding, changing, and deleting data Using the SELECT command to retrieve specific data Handling NULL values (missing information) in a relational database Joining tables, including self joins and outer joins (ANSI and WHERE-clause syntax) Working with nested queries (subqueries) to get data from multiple tables Creating views (virtual tables) to provide customized access to data Using SQL functions

A bonus CD-ROM contains a time-limited, full-feature version of the Sybase® Adaptive Server Anywhere(tm) software as well as the sample database, scripts, and examples included in the book.

The Practical SQL Handbook is the most complete reference available for day-to-day SQL implementations.



0201703092B05222001

CD-ROM available at desk.

Includes bibliographical references and index.

SQL and Relational Database Management -- Designing Databases -- Creating and Filling a Database -- Selecting Data from the Database -- Sorting Data and Other Selection Techniques -- Grouping Data and Reporting from It -- Joining tables for Comprehensive Data Analysis -- Structuring Queries with Subqueries -- Creating and using views -- Security, Transactions, Performance and Integrity -- Solving Business Problems.

Table of contents provided by Syndetics

  • List of Figures (p. xix)
  • Foreword to the Fourth Edition (p. xxi)
  • Preface (p. xxiii)
  • Why New Editions? (p. xxiii)
  • Changes for Recent Editions (p. xxiv)
  • Include More Real-World Examples (p. xxiv)
  • Emphasize SQL-92 (p. xxiv)
  • Provide Software for Hands-On Practice (p. xxv)
  • The Fourth Edition (p. xxv)
  • Test on More Systems (p. xxv)
  • Show Examples of Vendor-Specific Differences (p. xxvi)
  • Acknowledgments (p. xxvi)
  • Introduction (p. xxvii)
  • The Beginnings of SQL (p. xxvii)
  • The Commercialization of SQL (p. xxviii)
  • Who Should Use This Book (p. xxix)
  • The Focus of This Book (p. xxix)
  • How to Learn SQL with This Book (p. xxxi)
  • The Structure of This Book (p. xxxii)
  • How to Use This Book (p. xxxiii)
  • An Overview of the Book (p. xxxiv)
  • Chapter 1 SQL and Relational Database Management (p. 1)
  • In This Chapter (p. 1)
  • Relational Database Management (p. 1)
  • The Relational Model: It's All Tables (p. 3)
  • Independence Forever (p. 4)
  • A High-Level Language (p. 5)
  • Data Manipulation (p. 6)
  • Data Definition (p. 7)
  • Data Administration (p. 8)
  • Relational Operations (p. 8)
  • Projection (p. 9)
  • Selection (p. 10)
  • Join (p. 10)
  • Alternatives for Viewing Data (p. 13)
  • NULLs (p. 15)
  • Security (p. 15)
  • Integrity (p. 16)
  • SQL Functions (p. 17)
  • Summary (p. 18)
  • Chapter 2 Designing Databases (p. 21)
  • In This Chapter (p. 21)
  • Design Considerations (p. 21)
  • Do You Need an Expert? (p. 22)
  • Data Definition and Customization (p. 23)
  • How to Approach Database Design (p. 23)
  • Introducing the Sample Database (p. 27)
  • Data Entities and Relationships (p. 29)
  • Entities: Things with an Independent Existence (p. 29)
  • One-to-Many Relationships (p. 33)
  • Many-to-Many Relationships (p. 36)
  • One-to-One Relationships (p. 37)
  • The Entity-Relationship Approach Summarized (p. 38)
  • The Normalization Guidelines (p. 39)
  • First Normal Form (p. 40)
  • Second Normal Form (p. 41)
  • Third Normal Form (p. 43)
  • Fourth Normal Form (p. 45)
  • Reviewing the Database Design (p. 46)
  • Summarizing the bookbiz Database (p. 48)
  • Testing Your Database Design (p. 49)
  • Other Database Definition Considerations (p. 50)
  • Summary (p. 50)
  • Chapter 3 Creating and Filling a Database (p. 51)
  • In This Chapter (p. 51)
  • From Theory to Practice: Installing bookbiz (p. 51)
  • Distinguishing SQL Examples and Syntax (p. 52)
  • Coping with Failure (p. 55)
  • Working with Databases (p. 56)
  • Getting Started (p. 56)
  • Recognizing Roles (p. 57)
  • Reserving Space for Database Objects (p. 57)
  • Choosing Databases (p. 58)
  • Creating Simple Tables (p. 58)
  • Choosing Datatypes (p. 61)
  • Assigning NULL and NOT NULL (p. 64)
  • Planning Tables (p. 66)
  • Defining the Tables in bookbiz (p. 66)
  • Creating Indexes (p. 68)
  • The CREATE INDEX Statement (p. 69)
  • How, What, and Why to Index (p. 71)
  • Creating Tables with SQL-92 Constraints (p. 72)
  • Sketching Constraints (p. 73)
  • Implementing Constraints on Individual Columns (p. 75)
  • Implementing Multicolumn Constraints (p. 77)
  • Changing and Deleting Databases and Objects (p. 79)
  • Changing Databases (p. 79)
  • Changing Table Definitions (p. 79)
  • Removing Databases (p. 81)
  • Removing Tables (p. 82)
  • Removing Indexes (p. 82)
  • Adding, Changing, and Removing Data (p. 83)
  • Adding New Rows: INSERT (p. 84)
  • Changing Existing Data: UPDATE (p. 89)
  • Removing Data: DELETE (p. 93)
  • Summary (p. 94)
  • Chapter 4 Selecting Data from the Database (p. 95)
  • In This Chapter (p. 95)
  • SELECT Overview and Syntax (p. 95)
  • Basic SELECT Syntax (p. 96)
  • Full SELECT Syntax (p. 99)
  • Choosing Columns: The SELECT Clause (p. 100)
  • Choosing All Columns: SELECT (p. 101)
  • Choosing Specific Columns (p. 102)
  • More Than Column Names (p. 103)
  • Specifying Tables: The FROM Clause Table List (p. 114)
  • Using Table Aliases (p. 114)
  • Skipping FROM (p. 115)
  • Selecting Rows: The WHERE Clause (p. 116)
  • Comparison Operators (p. 117)
  • Connecting Conditions with Logical Operators (p. 120)
  • Ranges (BETWEEN and NOT BETWEEN) (p. 127)
  • Lists (IN and NOT IN) (p. 130)
  • Selecting Null Values (p. 131)
  • Matching Character Strings: LIKE (p. 134)
  • Like, Is IN LIKE Equals...? (p. 139)
  • Summary (p. 142)
  • Chapter 5 Sorting Data and Other Selection Techniques (p. 143)
  • In This Chapter (p. 143)
  • A New Batch of SELECT Statement Clauses (p. 143)
  • Sorting Query Results: ORDER BY (p. 144)
  • ORDER BY Syntax (p. 144)
  • Character Sets and Sort Orders (p. 146)
  • Sorts Within Sorts (p. 148)
  • Sort Up, Sort Down (p. 149)
  • What About More Complex Expressions? (p. 150)
  • How Do You Sort Nulls? (p. 154)
  • Eliminating Duplicate Rows: DISTINCT and ALL (p. 155)
  • DISTINCT Syntax (p. 157)
  • DISTINCT with Multiple SELECT List Items (p. 158)
  • Aggregate Functions (p. 162)
  • Aggregate Syntax (p. 164)
  • Summary (p. 173)
  • Chapter 6 Grouping Data and Reporting from It (p. 175)
  • In This Chapter (p. 175)
  • Grouping and Aggregates (p. 175)
  • The GROUP BY Clause (p. 175)
  • GROUP BY Syntax (p. 176)
  • Cautions and Restrictions (p. 178)
  • NULLs and Groups (p. 182)
  • GROUP BY: Aggregate Interactions (p. 186)
  • GROUP BY with WHERE (p. 189)
  • GROUP BY and ORDER BY (p. 191)
  • The HAVING Clause (p. 192)
  • Garden-Variety HAVING (p. 193)
  • Where, Group by, Having, Order by (p. 197)
  • All About NULLs (p. 197)
  • NULLs and Database Design (p. 198)
  • Comparisons Involving NULLs (p. 198)
  • NULLs and Computations (p. 199)
  • Defaults as Alternatives to NULLs (p. 201)
  • Functions That Work with NULLs (p. 201)
  • NULL Functions and "What-If" Calculations (p. 203)
  • Summary (p. 203)
  • Chapter 7 Joining Tables for Comprehensive Data Analysis (p. 205)
  • In This Chapter (p. 205)
  • Defining Joins (p. 205)
  • Why Joins Are Necessary (p. 206)
  • Associating Data from Separate Tables (p. 206)
  • Providing Flexibility (p. 207)
  • Getting a Good Join (p. 208)
  • From/Where Join Syntax (p. 209)
  • SQL-92 Join Syntax (p. 210)
  • Analyzing a Join (p. 212)
  • Improving the Readability of Join Results (p. 213)
  • Avoiding Duplication (p. 213)
  • Limiting the Width of the Display (p. 214)
  • Using Aliases in the From Clause Table/View List (p. 216)
  • Specifying Join Conditions (p. 218)
  • Joins Based on Equality (p. 218)
  • Joins Not Based on Equality (p. 220)
  • Joining More Than Two Tables (p. 221)
  • Exploring Exotic Joins (p. 222)
  • Joining a Table with Itself: The Self-Join (p. 222)
  • Showing the Background: Outer Joins (p. 225)
  • Avoiding a Common Source of Errors (p. 230)
  • Understanding the Cartesian Product (p. 230)
  • Using the Cartesian Product (p. 232)
  • Constraining the Cartesian Product (p. 233)
  • Going Beyond Joins: Union, Intersect, Minus (p. 233)
  • Union (p. 234)
  • Intersect and Minus (p. 239)
  • Summary (p. 241)
  • Chapter 8 Structuring Queries with Subqueries (p. 243)
  • In This Chapter (p. 243)
  • What Is a Subquery? (p. 243)
  • Simplified Subquery Syntax (p. 244)
  • How Do Subqueries Work? (p. 244)
  • Simple Subquery Processing (p. 245)
  • Correlated Subquery Processing (p. 247)
  • Simple-Correlated Performance Issues (p. 249)
  • Joins or Subqueries? (p. 249)
  • Subqueries! (p. 249)
  • Joins! (p. 251)
  • Subqueries vs. Self-Joins? (p. 251)
  • Which Is Better? (p. 252)
  • Subquery Rules (p. 252)
  • Subqueries Returning Zero or More Values (p. 253)
  • Subqueries Introduced with In (p. 254)
  • Subqueries Introduced with not in (p. 256)
  • Correlated Subqueries Introduced with in (p. 257)
  • Subqueries Introduced with Comparison Operators and Any or All (p. 259)
  • Subqueries Returning a Single Value (p. 266)
  • Aggregate Functions Guarantee a Single Value (p. 267)
  • Group By and Having Must Return a Single Value (p. 268)
  • Correlated Subqueries with Comparison Operators (p. 269)
  • Subqueries Testing Existence (p. 270)
  • Not Exists Seeks the Empty Set (p. 273)
  • Using Exists to Find Intersection and Difference (p. 274)
  • Exists Alternatives (p. 275)
  • Subqueries in Multiple Levels of Nesting (p. 276)
  • Subqueries in Update, Delete, and Insert Statements (p. 277)
  • Subqueries in from and Select Clauses (p. 278)
  • Subqueries in the from Clause (p. 278)
  • Subqueries in the Select Clause (p. 280)
  • Summary (p. 282)
  • Chapter 9 Creating and Using Views (p. 283)
  • In This Chapter (p. 283)
  • With a View Toward Flexibility (p. 283)
  • View Commands (p. 284)
  • Creating Views (p. 284)
  • Displaying Data Through Views (p. 285)
  • Dropping Views (p. 287)
  • Advantages of Views (p. 287)
  • Focus, Simplification, and Customization (p. 292)
  • Security (p. 292)
  • Independence (p. 292)
  • How Views Work (p. 294)
  • Naming View Columns (p. 296)
  • Creating Views with Multiple Underlying Objects (p. 298)
  • Resolving Views (p. 300)
  • Data Modification Through Views (p. 306)
  • The Rules According to ANSI (p. 306)
  • Creating Copies of Data (p. 310)
  • Summary (p. 312)
  • Chapter 10 Security, Transactions, Performance, and Integrity (p. 315)
  • In This Chapter (p. 315)
  • Database Management in the Real World (p. 315)
  • Data Security (p. 316)
  • User Identification and Special Users (p. 317)
  • The Grant and Revoke Commands (p. 320)
  • Views as Security Mechanisms (p. 324)
  • Transactions (p. 326)
  • Transactions and Concurrency (p. 326)
  • Transactions and Recovery (p. 327)
  • User-Defined Transactions (p. 327)
  • Performance (p. 330)
  • Benchmarking (p. 331)
  • Design and Indexing (p. 332)
  • Optimizing Queries (p. 333)
  • Other Tools for Monitoring and Boosting Performance (p. 336)
  • Data Integrity (p. 338)
  • Domain Constraints (p. 339)
  • Entity Integrity (p. 341)
  • Referential Integrity (p. 341)
  • Stored Procedures and Triggers (p. 342)
  • Summary (p. 343)
  • Chapter 11 Solving Business Problems (p. 345)
  • In This Chapter (p. 345)
  • Using SQL on the Job (p. 345)
  • Thinking Conditionally (p. 346)
  • Case/Decode (p. 346)
  • Changing Null Displays (p. 351)
  • Formatting and Displaying Data (p. 353)
  • Displaying One Column as Two (p. 353)
  • Displaying Two Columns as One (p. 356)
  • Converting from One Datatype to Another (p. 358)
  • Playing with Patterns (p. 361)
  • Matching Uppercase and Lowercase Letters (p. 361)
  • Finding Data Within a Range When You Don't Know the Values (p. 363)
  • Locating Date Data (p. 365)
  • Displaying Data by Time Units (p. 369)
  • Avoiding Mistakes (p. 370)
  • Distinguishing Distincts (p. 371)
  • Removing Duplicates (p. 375)
  • Finding the "First" Entry (p. 377)
  • Summary (p. 378)
  • Appendix A Syntax Summary for the SQL Used in This Book (p. 379)
  • In This Appendix (p. 379)
  • Formatting (p. 379)
  • Syntax Conventions (p. 380)
  • Statement List (p. 380)
  • Appendix B Industry SQL Equivalents (p. 381)
  • In This Appendix (p. 381)
  • Comparisons (p. 381)
  • Naming Convention Comparison (p. 381)
  • Datatype Comparison (p. 382)
  • Function Comparison (p. 384)
  • Character Functions (p. 384)
  • Conditional Functions (p. 385)
  • Date and Time Functions (p. 385)
  • Appendix C Glossary (p. 387)
  • Appendix D The bookbiz Sample Database (p. 403)
  • In This Appendix (p. 403)
  • Database Details (p. 403)
  • Table Charts (p. 403)
  • publishers Table (p. 403)
  • authors Table (p. 404)
  • titles Table (p. 405)
  • titleauthors Table (p. 408)
  • sales Table (p. 409)
  • salesdetails Table (p. 410)
  • editors Table (p. 411)
  • titleditors Table (p. 412)
  • roysched Table (p. 413)
  • Create Statements for the bookbiz Database (p. 414)
  • Adaptive Server Anywhere Creates (p. 415)
  • Transact-SQL Creates (p. 418)
  • Oracle Creates (p. 422)
  • Informix Creates (p. 424)
  • Insert Statements (p. 427)
  • Create View Statements (p. 446)
  • Appendix E Resources (p. 451)
  • In This Appendix (p. 451)
  • Books (p. 451)
  • General (p. 451)
  • Informix (p. 452)
  • Microsoft SQL Server (p. 452)
  • mSQL/MySQL (p. 452)
  • Oracle (p. 453)
  • Sybase (p. 453)
  • Transact-SQL (p. 453)
  • Web Sites (p. 454)
  • Vendor Sites (p. 454)
  • Other Links (p. 454)
  • Newsgroups (p. 454)
  • Index (p. 455)

Excerpt provided by Syndetics

Why New Editions? Many things have changed since this book was first published in 1989, and SQL is no exception. The SQL language has expanded tremendously, both in numbers of users and in numbers of commands. Sales of relational databases continue to rise at a strong and steady rate.       When we wrote the first edition of The Practical SQL Handbook, the American National Standards Institute (ANSI) had already approved the 1986 SQL standard. The International Standards Organization (ISO) adopted it in 1987. Both ANSI and ISO helped create the 1989 version. The 1986 standards were skimpy, lacking features that most commercial vendors offered. The 1989 standards were more complete but still left many important elements undefined.       For the first edition, we felt we should focus on industry practice: As always, each vendor was keeping a wary eye on what the others were doing and making core offerings similar enough to attract both customers migrating from competitors, as well as new users looking for database systems they could build on. Because of this, we left both the not-quite-jelled ANSI standards and particular vendor implementations to the experts in those fields and concentrated on the common ground: generic or "industry-practice" SQL. Our goal was to offer the intelligent amateur practical information on how to use the actually available SQL of that time.       The 1992 ANSI standard (often called SQL-2 or SQL-92) represented a new stage in SQL development. This standard was more comprehensive than the 1989 standard: In written form it contained more than four times as many pages as the earlier version. Database vendors have adopted large parts of the 1992 standard. With the widespread adoption of the SQL-92 standard, the industry practice and the ANSI/ISO standards began to converge.       Despite vendor-specific differences, there is a general, industrywide core of SQL commands that all users need to understand. Adopting standards doesn't happen overnight; it is a long process. At any point, vendors will have varying levels of conformance and will continue to produce vendor-specific variations. This book aims to give SQL users a mastery of the fundamentals of the language, with a side glance at the specifics of particular implementations. Changes for Recent Editions The changes for recent editions have been threefold: To include more real-world examples To emphasize the SQL-92 features that most vendors have imple-mented To provide software for hands-on practice Include More Real-World Examples In talking to new and developing SQL users, we heard over and over of their need for more examples to follow, change, narrow, and broaden. Accordingly, the bulk of the added material in the second edition consisted of code "recipes." Chapter 11, Solving Business Problems, is a selection of code samples based on questions and answers that came over computer newsgroups. We reproduce interesting problems and solutions in terms of the sample bookbiz database used throughout the book. The chapter includes examples of using the CASE function for conditional logic, formatting results, and finding date data. A few samples fall into a different category. They aren't so much solutions to problems as indications of common errors. They include issues with DISTINCT and misunderstandings of what SQL can do. Emphasize SQL-92 With the third edition, we revised the book to incorporate the SQL-92 features that most vendors had adopted. These include new datatypes, additions to the CREATE TABLE statement that allow built-in integrity constraints, modifications to the ORDER BY and GROUP BY clauses, the new escape character for the LIKE keyword, and changes to GRANT and REVOKE, among others. Provide Software for Hands-On Practice With the fully usable trial version of Sybase's Adaptive Server Anywhere (ASA) on the CD that accompanies this book, you can run the examples (and your variants) on a PC. We've always felt that the secret to learning SQL is practice. Now you can experiment to your heart's content, trying out code samples with data you know and checking the results to see if they are what you expect. When you're stumped by complicated code, break it into small, meaningful pieces and run the pieces separately to make sure you understand what each segment does. Then put them together in increasingly complex combinations--and have fun!       The Sybase Adaptive Server Anywhere software on the CD is a 60-day full-feature version that allows you to create objects as well as to query existing objects. ASA is built with an updated version of the bookbiz database: For the fourth edition, we increased book prices and made dates more recent. Also included on the CD are scripts to create the database on ASA (in case you damage the original) and on the other systems discussed in the book. The Fourth Edition The Practical SQL Handbook, Fourth Edition, continues to focus on industry-practice SQL, but the information included is at once more general and more specific than earlier editions. For the fourth edition, we had two objectives: To expand our test base, running the examples on five different database systems To show vendor-specific differences among systems Test on More Systems For the fourth edition, all examples were run on five systems (Sybase Adaptive Server Anywhere, Adaptive Server Enterprise, Microsoft SQL Server, Oracle, Informix), rather than on Sybase systems only, as in the third edition. This expanded test base makes the information more universal. We are no longer limited to what we can explore or verify on a particular system. If an important feature doesn't exist on Adaptive Server Anywhere (ASA, the RDBMS included on the CD), we can show code and results from Oracle or SQL Server. Show Examples of Vendor-Specific Differences On the other hand, this edition is more specific. It includes information on specific idiosyncrasies of the five SQL dialects, warning readers where to look for differences. In this, it reflects the real world--lots of database users are working with multiple systems, either sequentially or simultaneously. Interesting SQL differences are flagged as SQL Variants, in-text sections that show details of differences in SQL use by different vendors. For example, how single and double quotes are used, or database users added, or outer joins specified. You won't see code for every one of the five systems every time, but you'll get an introduction to the kind of differences that are likely in a particular area. Acknowledgments We would like to thank the following people for their contributions to this book: Donna Jeker and Stu Schuster for supplying timely support and encouragement; Jeff Lichtman and Howard Torf for offering advice, examples, anecdotes, and reality checks; Tom Bondur, Susie Bowman, John Cooper, and Wayne Duquesne for providing resource materials and other information; Paul Winsberg for reviewing the database design chapter in the first edition; Robert Garvey for technical review of the second edition; Karen Ali for facilitating the third edition's SQL Anywhere CD; and Theo Posselt for technical review of the third edition.       For the fourth edition, we would like to acknowledge Mike Radencich of iAnywhere Solutions (a Sybase Company), for providing the software and permissions for the Adaptive Server Anywhere CD; Lance Batten of Tilden Park Software and Sanford Jacobs of Paragon Software for comments and corrections; our reviewers, on whom we rely for timely and detailed feedback: Vijayanandan Venkatachalam, curriculum director of Oracle Corporation; David McGoveran of Alternative Technologies; Roger Snowden; Amy Sticksel of Sticksel Data Systems; Paul Irvine of Emerald Solutions; and Karl Batten-Bowman. 0201703092P06042001 Excerpted from The Practical SQL Handbook: Using SQL Variants by Judith Bowman, Sandra Emerson, Marcy Darnovsky All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Author notes provided by Syndetics

Judith S. Bowman has been a database professional since the early 1980s. She is currently an independent consultant specializing in SQL and relational database issues and is the author of Practical SQL: The Sequel (Addison-Wesley, 2001). Sandra L. Emerson is an independent consultant and former Vice President of Publishing Programs for Sybase. Marcy Darnovsky , teaches at colleges throughout the San Francisco Bay area. She was formerly at Sybase.

0201703092AB04062001