[ Home ]

SQL 2nd cover

SQL (Second Edition)
Visual QuickStart Guide
by Chris Fehily

A newer edition is available.

Download this book’s companion files.

Description

SQL: Visual QuickStart Guide teaches SQL — the language of databases — to beginning and intermediate programmers. With SQL, you can create, alter, and drop tables, indexes, and views; insert, update, query, and delete data; and execute transactions to maintain the integrity of your data. This book covers the relational model, the core language for ANSI/ISO (standard) SQL, and product-specific variations for Microsoft Access, Microsoft SQL Server, Oracle, IBM DB2, MySQL, and PostgreSQL. Hundreds of examples of varied difficulty encourage you to experiment and explore. Extensive cross references make this book a good quick reference for experienced programmers.

Contents

Introduction
1. DBMS Specifics
2. The Relational Model
3. SQL Basics
4. Retrieving Data From a Table
5. Operators and Functions
6. Summarizing and Grouping Data
7. Joins
8. Subqueries
9. Set Operations
10. Inserting, Updating, and Deleting Rows
11. Creating, Altering, and Dropping Tables
12. Indexes
13. Views
14. Transactions
Appendix A. Creating the Sample Database
Appendix B. SQL Keywords
Index

Download

This book’s examples use the sample database books, described in “The Sample Database” in Chapter 2. To create books, download the zip file sql_vqs2_files.zip, expand it, and follow the instructions for your DBMS given in Appendix A, “Creating the Sample Database.” The file readme.txt describes the distribution.

If you’re running a DBMS locally (that is, on your own computer), then you’re the database administrator (DBA) and have all the privileges you need. If you’re connecting to a DBMS on a network server, then ask your DBA for connection parameters and the privileges to create, query, update, and drop databases and tables.

The instructions for creating the sample database explain how to use simple tools and settings. As you gain experience, you might want to switch to using the statement CREATE DATABASE to create new databases. CREATE DATABASE is a powerful but nonstandard SQL command, so its syntax and capabilities vary by DBMS; see your DBMS’s documentation. (Microsoft Access doesn’t support CREATE DATABASE, but you can create Access databases programmatically by using Visual Basic for Applications or C#.)

Errata and updates

Page xiii — In the caption for Listing i.2, change “performs the query” to “performs the same query”.

Page 16 — In the step for “To exit the db2 command-line utility”, change “quit” to “quit;”.

Page 22 — In the last bullet point, change “or, strictly speaking, a schema” to “or, strictly speaking, within a schema”.

Page 29 — In the third paragraph, change “accepts null values” to “accepts nulls”.

Page 64 — In the first paragraph, change “data and time arithmetic” to “date and time arithmetic”.

Page 68 — In Figure 3.4, change the value “0.28” to “0.08” in the table commissions for employee E06.

Page 124 — Move the section “Case-Insensitive Comparisons” to page 122.

Page 148 — In the first sentence, change “(Chapter 8)” to “(Chapter 7)”.

Page 184 — In the fifth bullet point, change “can convert implicitly” to “can convert implicitly to a common type”.