SQL Book

I am the author of the 4th edition of the SQL Pocket Guide.

You can purchase a physical copy through Amazon.

You can also read it online via the O’Reilly learning platform:

  • For a free 30 day trial, use the code: SQLPG21
  • Your local public library / university / company may have a subscription

———

“Overall this is definitely the strongest SQL title I have seen in a while in terms of content selection, writing style, accessibility, focus, and scope. It’s one I would keep on my shelf for my reference!”

– Thomas Nield, Author of Getting Started with SQL (O’Reilly)

———

There are many SQL books out there. What makes this one different?

1. I pack the most useful SQL info into as few pages as possible

This book includes the most common concepts and use cases, without the fluff. The whole book should take less than a day to read — perfect to skim before an interview or quickly look up syntax on the job.

2. I show examples instead of documentation

My goal was to write the book in the style of the top voted answers on Stack Overflow — succinct, in layman’s terms and with helpful examples.

This is what you’ll often see in official documentation:

decimal(p,s)]

Fixed precision and scale numbers. When maximum precision is used, valid values are from – 10^38 +1 through 10^38 – 1 (…and it continues on for another few paragraphs)

In the book, I present it like this:

CREATE TABLE my_table (
my_decimal_column DECIMAL(5,2)
);


Create a table with a column that can hold 5 total digits, with 2 digits to the right of the decimal point. For example, 12.3 would be stored as 12.30.

3. Five database management systems are compared side by side

When writing this book, I wanted to make it easy for a reader to compare the SQL syntax between MySQL, Oracle, PostgreSQL, SQL Server and SQLite.

I didn’t find any other resource (online or in book form) that did so in a clear, consistent and comprehensive way, so I compiled it for this book. Every concept throughout the book includes code for all five software. For example:

SoftwareCode
MySQL
PostgreSQL
SQLite
SELECT *
FROM birthdays
LIMIT 10;
Microsoft SQL ServerSELECT TOP 10 *
FROM birthdays;
Oracle DatabaseSELECT *
FROM birthdays
WHERE ROWNUM <= 10;