SQL Books

Fehily, C. (2002) Visual QuickStart Guide SQL, Peachpit Press

There is a newer version of this book

Companion Web Site: http://www.fehily.com/books/sql_vqs_1.html

Download Source Code (ZIP 186KB)

Database management. It may sound daunting, but it doesn’t have to be, even if you’ve never programmed before. SQL: Visual QuickStart Guide isn’t an exhaustive guide to SQL written for aspiring programming experts. It’s simply an invaluable resource for those who want a fast, easy way to harness information living in complex databases.

Because author Chris Fehily assumes no prior programming experience on your part (just a familiarity with your OS’s file system), he spends the first few chapters laying out the basics, including clear explanations of the relational database model and SQL syntax. Then he jumps into step-by-step tasks designed to get you comfortable using SQL right away. You’ll learn how to use SQL’s most popular statements and commands to maintain, retrieve, and analyze database information, and to create and edit database objects. Each visually oriented task features the actual code and plenty of screenshots to keep you on track. Fehily takes a software-independent approach to teaching SQL, but includes tips for specific database software. You may not be a programming expert, but with SQL: VQS, who will be able to tell?

QL: 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, 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.

Table of 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. Retrieving Data From Multiple Tables.

 8. Subqueries.

 9. Inserting, Updating, and Deleting Rows.

10. Creating, Altering, and Dropping Tables.

11. Indexes.

12. Views.

13. Transactions.

Appendix.


Beaulieu, A. (2005) Learning SQL, O’Reilly Media, Inc

There is a newer version of this book

Download Source Code (TXT 28KB)
Change the file extension to .sql

SQL (Structured Query Language) is a standard programming language for generating, manipulating, and retrieving information from a relational database. If you’re working with a relational database–whether you’re writing applications, performing administrative tasks, or generating reports–you need to know how to interact with your data. Even if you are using a tool that generates SQL for you, such as a reporting tool, there may still be cases where you need to bypass the automatic generation feature and write your own SQL statements.

To help you attain this fundamental SQL knowledge, look to Learning SQL, an introductory guide to SQL, designed primarily for developers just cutting their teeth on the language.

Learning SQL moves you quickly through the basics and then on to some of the more commonly used advanced features. Among the topics discussed:

  • The history of the computerized database
  • SQL Data Statements–those used to create, manipulate, and retrieve data stored in your database; example statements include select, update, insert, and delete
  • SQL Schema Statements–those used to create database objects, such as tables, indexes, and constraints
  • How data sets can interact with queries
  • The importance of subqueries
  • Data conversion and manipulation via SQL’s built-in functions
  • How conditional logic can be used in Data Statements

Best of all, Learning SQL talks to you in a real-world manner, discussing various platform differences that you’re likely to encounter and offering a series of chapter exercises that walk you through the learning process. Whenever possible, the book sticks to the features included in the ANSI SQL standards. This means you’ll be able to apply what you learn to any of several different databases; the book covers MySQL, Microsoft SQL Server, and Oracle Database, but the features and syntax should apply just as well (perhaps with some tweaking) to IBM DB2, Sybase Adaptive Server, and PostgreSQL.Put the power and flexibility of SQL to work. With Learning SQL you can master this important skill and know that the SQL statements you write are indeed correct.

Table of Contents

Preface; Why Learn SQL?; Why Use This Book to Do It?; Structure of This Book; Conventions Used in This Book; How to Contact Us; Using Code Examples; Safari Enabled; Acknowledgments; Chapter 1: A Little Background; 1.1 Introduction to Databases; 1.2 What Is SQL?; 1.3 What Is MySQL?; 1.4 What’s in Store; Chapter 2: Creating and Populating a Database; 2.1 Creating a MySQL Database; 2.2 Using the mysql Command-Line Tool; 2.3 MySQL Data Types; 2.4 Table Creation; 2.5 Populating and Modifying Tables; 2.6 When Good Statements Go Bad; 2.7 The Bank Schema; Chapter 3: Query Primer; 3.1 Query Mechanics; 3.2 Query Clauses; 3.3 The select Clause; 3.4 The from Clause; 3.5 The where Clause; 3.6 The group by and having Clauses; 3.7 The order by Clause; 3.8 Exercises; Chapter 4: Filtering; 4.1 Condition Evaluation; 4.2 Building a Condition; 4.3 Condition Types; 4.4 NULL: That Four-Letter Word; 4.5 Exercises; Chapter 5: Querying Multiple Tables; 5.1 What Is a Join?; 5.2 Joining Three or More Tables; 5.3 Self-Joins; 5.4 Equi-Joins Versus Non-Equi-Joins; 5.5 Join Conditions Versus Filter Conditions; 5.6 Exercises; Chapter 6: Working with Sets; 6.1 Set Theory Primer; 6.2 Set Theory in Practice; 6.3 Set Operators; 6.4 Set Operation Rules; 6.5 Exercises; Chapter 7: Data Generation, Conversion, and Manipulation; 7.1 Working with String Data; 7.2 Working with Numeric Data; 7.3 Working with Temporal Data; 7.4 Conversion Functions; 7.5 Exercises; Chapter 8: Grouping and Aggregates; 8.1 Grouping Concepts; 8.2 Aggregate Functions; 8.3 Generating Groups; 8.4 Group Filter Conditions; 8.5 Exercises; 8.6 8-4 (Extra Credit); Chapter 9: Subqueries; 9.1 What Is a Subquery?; 9.2 Subquery Types; 9.3 Noncorrelated Subqueries; 9.4 Correlated Subqueries; 9.5 When to Use Subqueries; 9.6 Subquery Wrap-up; 9.7 Exercises; Chapter 10: Joins Revisited; 10.1 Outer Joins; 10.2 Cross Joins; 10.3 Natural Joins; 10.4 Exercises; Chapter 11: Conditional Logic; 11.1 What Is Conditional Logic?; 11.2 The Case Expression; 11.3 Case Expression Examples; 11.4 Exercises; Chapter 12: Transactions; 12.1 Multiuser Databases; 12.2 What Is a Transaction?; Chapter 13: Indexes and Constraints; 13.1 Indexes; 13.2 Constraints; Appendix A: ER Diagram for Example Database; Appendix B: MySQL Extensions to the SQL Language; B.1 Select Extensions; B.2 Combination Insert/Update Statements; B.3 Ordered Updates and Deletes; B.4 Multitable Updates and Deletes; Appendix C: Solutions to Exercises; C.1 Chapter 3; C.2 Chapter 4; C.3 Chapter 5; C.4 Chapter 6; C.5 Chapter 7; C.6 Chapter 8; C.7 8-4 (Extra Credit); C.8 Chapter 9; C.9 Chapter 10; C.10 Chapter 11; Appendix D: Further Resources; D.1 Advanced SQL; D.2 Database Programming; D.3 Database Design; D.4 Database Tuning; D.5 Database Administration; D.6 Report Generation; Colophon;


van der Lans, R. (1991) An SQL Guide for ORACLE, Addison Wesley

This book provides a practical and comprehensive tutorial on SQL, covering version 6.0 of ORACLE. It examines every aspect of SQL including creating tables, specifying primary and foreign keys, querying data transactions, data security and auditing.