You are previewing SQL in a Nutshell.
O'Reilly logo
SQL in a Nutshell

Book Description

SQL (Structured Query Language) is a standardized query language for requesting information from a database. Historically, SQL has been the choice for database management systems running on minicomputers and mainframes. Increasingly, however, SQL is being adapted to PC database systems because it supports distributed databases--databases that are spread out over several computer systems, so that several users on a local-area network can access the same database simultaneously. Although there are different dialects of SQL, it is the closest thing to a standard query language that currently exists. SQL in a Nutshell is a practical and useful command reference to the latest release of the Structured Query Language (SQL99), helping readers learn how their favorite database product supports any standard SQL command. This book presents each of the SQL commands and describes its use in both commercial (Microsoft SQL Server 2000 and Oracle 8i) and open source (MySQL, PostgreSQL 7.0) implementations. Each command reference includes the command syntax (by vendor, if the syntax differs across implementations), a description, and informative examples that illustrate important concepts and uses. SQL in a Nutshell is more than a convenient reference guide for experienced SQL programmers, analysts, and database administrators. It's also a great learning resource for novice and auxiliary SQL users such as system administrators, users of packaged client/server products, and consultants who need to be familiar with the various SQL dialects across many platforms.

Table of Contents

  1. SQL in a Nutshell
    1. Preface
      1. How This Book Is Organized
      2. Conventions Used in This Book
      3. How to Contact Us
      4. Resources
      5. Acknowledgments
    2. 1. SQL, Vendor Implementations, and Some History
      1. The Relational Database Model
      2. The Databases Described in This Book
      3. The SQL Standard
        1. Levels of Conformance
        2. Supplemental Features Packages
        3. SQL99 Statement Classes
      4. Dialects of SQL
      5. Principles of Relational Databases
    3. 2. Foundational Concepts
      1. Row Processing Versus Set Processing
      2. The Relational Model
      3. SQL99 and Vendor-Specific Datatypes
        1. Microsoft SQL Server Datatypes
        2. MySQL Datatypes
        3. Oracle Datatypes
        4. PostgreSQL Datatypes
      4. Processing NULLS
      5. Categories of Syntax
        1. Identifiers
          1. Naming conventions
          2. Identity rules
        2. Literals
        3. System Delimiters and Operators
        4. Keywords and Reserved Words
      6. Using SQL
        1. Projections
        2. Selections
        3. Joins
      7. Conclusion
    4. 3. SQL Statements Command Reference
      1. Recommended Reading Approach
      2. Quick SQL Command Reference
      3. ALTER PROCEDURE
        1. ALTER PROCEDURE
      4. ALTER TABLE
        1. ALTER TABLE
      5. ALTER TRIGGER
        1. ALTER TRIGGER
      6. ALTER VIEW
        1. ALTER VIEW
      7. CALL
        1. CALL
      8. CASE
        1. CASE
      9. CAST
        1. CAST
      10. CLOSE CURSOR
        1. CLOSE CURSOR
      11. COMMIT TRANSACTION
        1. COMMIT TRANSACTION
      12. Concatenation Operators
        1. Concatenation Operators
      13. CONNECT
        1. CONNECT
      14. CREATE DATABASE
        1. CREATE DATABASE
      15. CREATE FUNCTION
        1. CREATE FUNCTION
      16. CREATE INDEX
        1. CREATE INDEX
      17. CREATE PROCEDURE
        1. CREATE PROCEDURE
      18. CREATE ROLE
        1. CREATE ROLE
      19. CREATE SCHEMA
        1. CREATE SCHEMA
      20. CREATE TABLE
        1. CREATE TABLE
      21. CREATE TRIGGER
        1. CREATE TRIGGER
      22. CREATE VIEW
        1. CREATE VIEW
      23. DECLARE CURSOR
        1. DECLARE CURSOR
      24. DELETE
        1. DELETE
      25. DISCONNECT
        1. DISCONNECT
      26. DROP Statements
      27. DROP DATABASE
        1. DROP DATABASE
      28. DROP FUNCTION
        1. DROP FUNCTION
      29. DROP INDEX
        1. DROP INDEX
      30. DROP PROCEDURE
        1. DROP PROCEDURE
      31. DROP ROLE
        1. DROP ROLE
      32. DROP TABLE
        1. DROP TABLE
      33. DROP TRIGGER
        1. DROP TRIGGER
      34. DROP VIEW
        1. DROP VIEW
      35. FETCH
        1. FETCH
      36. GRANT
        1. GRANT
      37. INSERT
        1. INSERT
      38. LIKE Operator
        1. LIKE Operator
      39. OPEN
        1. OPEN
      40. Operators
        1. Operators
      41. RETURN
        1. RETURN
      42. REVOKE
        1. REVOKE
      43. ROLLBACK
        1. ROLLBACK
      44. SAVEPOINT
        1. SAVEPOINT
      45. SELECT
        1. SELECT
      46. SET CONNECTION
        1. SET CONNECTION
      47. SET ROLE
        1. SET ROLE
      48. SET TIME ZONE
        1. SET TIME ZONE
      49. SET TRANSACTION
        1. SET TRANSACTION
      50. START TRANSACTION
        1. START TRANSACTION
      51. TRUNCATE TABLE
        1. TRUNCATE TABLE
      52. UPDATE
        1. UPDATE
      53. Conclusion
    5. 4. SQL Functions
      1. Deterministic and Nondeterministic Functions
      2. Types of Functions
        1. Aggregate Functions
          1. AVG and SUM
          2. COUNT
          3. MIN and MAX
          4. BIT_LENGTH, CHAR_LENGTH, and OCTET_LENGTH
          5. EXTRACT
          6. POSITION
          7. CONCATENATE
          8. CONVERT and TRANSLATE
          9. LOWER and UPPER
          10. SUBSTRING
          11. TRIM
      3. Vendor Extensions
        1. Microsoft SQL Server-Supported Functions
        2. MySQL-Supported Functions
        3. Oracle SQL-Supported Functions
        4. PostgreSQL-Supported Functions
    6. 5. Unimplemented SQL99 Commands
    7. A. SQL99 and Vendor-Specific Keywords
    8. Index
    9. Colophon