Free downloads

The LearnSQL practice database

Everything you need to follow along with the book — the sample database plus every example query, ready to run. No sign-up required.

Verified for SQL Server, MySQL 8+ & PostgreSQL 15+

Choose your database

Two files per engine

Setup builds the practice database (5 tables, ~980 rows) and the Lesson 8 sample function. Queries holds every example from the book, in order, so you can follow along.

SQL Server

2019 / 2022 · T-SQL

PostgreSQL

15 or later

Quick start

Running in a browser, no install

  1. Open DB Fiddle (or dbfiddle.uk) and set the database dropdown to your engine — SQL Server, MySQL, or PostgreSQL.
  2. Paste the matching Setup script into the left (schema) panel and click Run. Your practice tables are ready.
  3. Paste any query from the Queries file into the right panel to see it work — or write your own.

Prefer a local install? Open the Setup script in SQL Server Management Studio, MySQL Workbench, or pgAdmin and run it there. It builds the tables and loads the data in one step.

What's inside

The LearnSQL sample data

A deliberately simple world of pet owners and their animals, so you can focus on learning SQL instead of decoding the data.

5
related tables
355
pet owners
258
dogs
266
cats
84
vet visits

Get the full walkthrough

These scripts pair with the book

Every script here is explained step by step across 20 short lessons in From Zero to SQL in 20 Lessons.

Get the book →