---
title: "Sample Database Resources: 12 Free Datasets for SQL Practice"
description: "A sample database is a free, ready-made schema with realistic data you can load in minutes to practice SQL, test a tool or demo a dashboard."
canonical: "https://www.aifordatabase.com/blog/sample-database/"
author: "Dhrumil Barot"
author_bio: "Dhrumil is an enterprise analytics expert. Dhrumil built AI for Database so anyone on a team can get answers from live company data in plain English, without waiting on a data team."
published: 2026-11-02
updated: 2026-11-02
---

# Sample Database Resources: 12 Free Datasets for SQL Practice

**TL;DR:** A sample database is a free, ready-made schema with realistic data you can load in minutes to practice SQL, test a tool or demo a dashboard. Start with DVD Rental or Pagila for PostgreSQL, Sakila or classicmodels for MySQL, AdventureWorks or Northwind for SQL Server, and Chinook if you want one dataset that runs on every engine.

A sample database is a pre-built database, schema plus data, published so people can learn and test SQL without inventing their own tables. The most used are **Pagila** and **DVD Rental** (PostgreSQL), **Sakila**, **Employees** and **classicmodels** (MySQL), **AdventureWorks**, **Northwind** and **Wide World Importers** (SQL Server), and **Chinook**, which ships scripts for SQL Server, Oracle, MySQL, PostgreSQL, SQLite and DB2. Most load with one command (`psql -f`, `mysql <`, `pg_restore` or a SQL Server `.bak` restore). Below, each one is listed with its engine, its shape, what questions it is good for and the exact load command, grouped by database.

![Pick a sample database by engine first, then by the kind of questions you want to practice](https://cdn.sanity.io/images/upsr56wu/production/e363f6752287b3dc7b3fe43b0a365d927e4665cb-1344x326.png?w=1280)

FIG 01 — Chinook covers six engines, so it is the safe default if you switch databases.

## Where Can I Download a Sample PostgreSQL Database?

The fastest PostgreSQL sources are the DVD Rental tutorial file, the Pagila repository and Neon's collection of ready dumps.

*   [DVD Rental on PostgreSQL Tutorial](https://www.postgresqltutorial.com/postgresql-getting-started/postgresql-sample-database/): 15 tables (film, actor, customer, rental, payment) plus a printable ER diagram. Free. The best first database for a beginner because the schema fits on one page.
*   [Pagila](https://github.com/devrimgunduz/pagila): the PostgreSQL port of MySQL's Sakila, a DVD rental store with stores, staff, customers and payments. Free (open license). Worth it once DVD Rental feels small: it adds a JSONB schema variant (`pagila-schema-jsonb.sql`) and partitioned payment tables, so you practice real PostgreSQL features.
*   [Neon postgres-sample-dbs](https://github.com/neondatabase/postgres-sample-dbs): one repository with Chinook, DVD Rental, Pagila, Employees, Lego, Netflix, Titanic, World Happiness and more, dumped from Postgres 15. Free. The quickest way to try several datasets on any Postgres host; the largest is 333 MB.

Load Pagila:

```
createdb pagila
psql -d pagila -f pagila-schema.sql
psql -d pagila -f pagila-data.sql
```

Load DVD Rental (it ships as a `.tar` archive, so it needs `pg_restore`, not `psql`):

```
createdb dvdrental
pg_restore -U postgres -d dvdrental dvdrental.tar
```

A Neon dump gotcha the tutorials skip: those files use `COPY ... FROM stdin`, which only works through `psql -d "<connection string>" -f file.sql`. Pasting them into a GUI SQL editor fails with "No source stream defined".

## MySQL Sample Database Options: Sakila, Employees, classicmodels

MySQL's own documentation hosts two official samples, and MySQL Tutorial hosts a third that is the best for business reporting.

*   [Sakila](https://dev.mysql.com/doc/sakila/en/): Oracle's official MySQL sample, a DVD rental business with films, actors, inventory, rentals and payments. Free. Good for joins across many-to-many tables (film to actor, film to category).
*   [Employees (test\_db)](https://github.com/datacharmer/test_db): about 300,000 employee records and 2.8 million salary rows in a 167 MB export. Free. The one to use when you need volume: indexes, `EXPLAIN` and date-range queries only show their effect on real row counts. Runs on MySQL 5.0+ and PostgreSQL 12+.
*   [classicmodels on MySQL Tutorial](https://www.mysqltutorial.org/getting-started-with-mysql/mysql-sample-database/): a retailer of scale model cars with customers, products, product lines, orders, order details, payments, employees and offices. Free. The closest MySQL sample to a real sales database: revenue by month, top customers and sales rep performance all work out of the box.

Load Sakila:

```
mysql -u root -p < sakila-schema.sql
mysql -u root -p < sakila-data.sql
```

Load Employees on MySQL 9.5 or later (the dump uses `SOURCE`, which now needs the `--commands` client flag), then verify the checksums:

```
mysql --commands < employees.sql
mysql -t < test_employees_sha2.sql
```

## Which SQL Server Samples Does Microsoft Publish?

Microsoft publishes three samples, from small to enterprise-shaped.

*   [AdventureWorks](https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure): a bicycle manufacturer with sales, production, purchasing and HR schemas. Free. Ships as `.bak` files per SQL Server version (AdventureWorks2025, 2022, 2019 and older) in three variants: OLTP (the full transactional database), DW (a star-schema data warehouse) and LT (a lightweight cut). Start with the OLTP file matching your SQL Server version; use DW to learn dimensional modeling.
*   [Northwind and pubs](https://github.com/microsoft/sql-server-samples/tree/master/samples/databases/northwind-pubs): the classic trading company (customers, orders, products, suppliers, employees) as `instnwnd.sql`, with a separate script for Azure SQL Database. Free. Small and familiar: half the SQL tutorials on the web use it.
*   [Wide World Importers](https://learn.microsoft.com/en-us/sql/samples/wide-world-importers-what-is): a wholesale novelty goods importer with purchase orders, supplier payments, stock and customer orders. Free. Use it to practice newer SQL Server features such as temporal tables and JSON.

Restore AdventureWorks (adjust the path to your data directory):

```
RESTORE DATABASE AdventureWorks2022
FROM DISK = '/var/opt/mssql/backup/AdventureWorks2022.bak'
WITH MOVE 'AdventureWorks2022' TO '/var/opt/mssql/data/AdventureWorks2022.mdf',
     MOVE 'AdventureWorks2022_log' TO '/var/opt/mssql/data/AdventureWorks2022_log.ldf';
```

## Which Sample Database Works on Every Engine?

*   [Chinook](https://github.com/lerocha/chinook-database): a digital media store (artists, albums, tracks, playlists, invoices, customers) with scripts for SQL Server, Oracle, MySQL, PostgreSQL, SQLite and DB2. Free. Built as a cross-engine alternative to Northwind, so the same practice queries run everywhere; the repository now also links a Netflix sample database.

Load Chinook into SQLite, the zero-install option:

```
sqlite3 chinook.db < Chinook_Sqlite.sql
sqlite3 chinook.db "SELECT COUNT(*) FROM Invoice;"
```

![Chinook links customers to invoices to invoice lines to tracks, the join path most practice questions use](https://cdn.sanity.io/images/upsr56wu/production/2a73d0dc1355c36535fca8af49914715243ce3c2-1344x410.png?w=1280)

FIG 02 — Illustrative rows in Chinook's shape; run the query to see the real totals.

## Which Sample Database Is Best for Practicing SQL Joins?

Pagila or Sakila is the best sample database for practicing joins, because it has every relationship type: one-to-many (customer to rental), many-to-many through junction tables (`film_actor`, `film_category`) and a self-referencing chain (rental to inventory to film to store). Chinook is a close second with a clean five-table path from customer to track. Northwind is fine for basic inner and left joins but has few many-to-many cases.

A starter join on Pagila that touches four tables:

```
-- Top 5 film categories by rental revenue
SELECT c.name AS category, SUM(p.amount) AS revenue
FROM payment p
JOIN rental r         ON r.rental_id = p.rental_id
JOIN inventory i      ON i.inventory_id = r.inventory_id
JOIN film_category fc ON fc.film_id = i.film_id
JOIN category c       ON c.category_id = fc.category_id
GROUP BY c.name
ORDER BY revenue DESC
LIMIT 5;
```

For join types explained with rows, see our [JOIN glossary entry](https://www.aifordatabase.com/glossary/join/) and [selecting from multiple tables without JOIN](https://www.aifordatabase.com/blog/sql-select-from-multiple-tables-without-join-2026/).

## Is There a Sample SaaS or Ecommerce Database?

Yes, though fewer of them are official. These are the most realistic for business questions:

*   [Brazilian E-Commerce Public Dataset by Olist](https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce): real anonymized marketplace orders with customers, sellers, payments, reviews and delivery dates, as CSV files. Free (Kaggle account). The best ecommerce sample for delivery time, repeat purchase and review score analysis.
*   [classicmodels](https://www.mysqltutorial.org/getting-started-with-mysql/mysql-sample-database/) and [AdventureWorks](https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure): order and sales schemas for B2B and B2C revenue reports.
*   [TPC-H](https://www.tpc.org/tpch/): the standard decision-support benchmark schema (customers, orders, line items, suppliers, parts, nations) with a generator, `dbgen`, that builds any size by scale factor. Free. Use it when you need millions of order rows for performance tests.
*   [Supabase example projects](https://github.com/supabase/supabase/tree/master/examples): app-style schemas (auth users, profiles, subscriptions) close to what a real SaaS database looks like. Free.

There is no widely adopted official SaaS sample with subscriptions, plans and MRR. The usual workaround is to generate one: create `accounts`, `plans`, `subscriptions` and `invoices` tables and fill them with `generate_series` in PostgreSQL. Our [SaaS metrics glossary](https://www.aifordatabase.com/glossary/saas-metrics/) lists the metrics such a schema should support.

## How Do I Load a Sample Database?

Every sample above loads one of four ways, depending on the file type:

| File you downloaded | Engine | Command |
| --- | --- | --- |
| `.sql` script | PostgreSQL | `psql -d mydb -f file.sql` |
| `.tar` or custom dump | PostgreSQL | `pg_restore -d mydb file.tar` |
| `.sql` script | MySQL | `mysql -u root -p < file.sql` (add `--commands` on 9.5+ if it uses `SOURCE`) |
| `.bak` backup | SQL Server | `RESTORE DATABASE ... FROM DISK = '...'` |
| `.sql` script | SQLite | `sqlite3 file.db < file.sql` |
| `.csv` files | Any | create tables, then `\copy` (Postgres) or `LOAD DATA INFILE` (MySQL) |

Then run a count on the largest table to confirm the data arrived, for example `SELECT COUNT(*) FROM salaries;` on Employees should return about 2.8 million.

## Start Here: A Path for Beginners

1.  **Week 1:** DVD Rental on PostgreSQL. Learn `SELECT`, `WHERE`, `GROUP BY` and two-table joins against a schema small enough to memorize. Keep our [SQL cheat sheet](https://www.aifordatabase.com/blog/sql-cheat-sheet/) open.
2.  **Week 2:** Pagila. Practice many-to-many joins, window functions and JSONB.
3.  **Week 3:** Employees. Same queries at 2.8 million rows; add indexes and read `EXPLAIN` plans.
4.  **Week 4:** AdventureWorksDW or TPC-H. Star schemas and reporting queries, the shape analytics databases use. Our guide to [normalized databases](https://www.aifordatabase.com/blog/normalized-database/) explains why the OLTP and DW versions look so different.

Once your sample is loaded, a useful check on your own answers is to ask the same question in plain English and compare. AI for Database connects to any of these databases (and includes its own SaaS-style sample data at signup), writes the SQL for a question like "top 5 categories by rental revenue" and shows the query, so you can diff it against yours. [Try it free](https://app.aifordatabase.com/signup).

D

Written by [Dhrumil Barot](https://www.aifordatabase.com/about/#founder)

Dhrumil is an enterprise analytics expert. Dhrumil built AI for Database so anyone on a team can get answers from live company data in plain English, without waiting on a data team.

[LinkedIn](https://www.linkedin.com/in/bdhrumil)[X](https://x.com/fyidhrumil)

## Frequently Asked Questions

### What is the most popular sample database?

Northwind and AdventureWorks are the most referenced for SQL Server, Sakila for MySQL, and DVD Rental or Pagila for PostgreSQL. Chinook is the most common cross-engine choice.

### What is the difference between Sakila and Pagila?

Sakila is the official MySQL DVD rental sample; Pagila is its PostgreSQL port, with extras such as partitioned payment tables and a JSONB schema variant.

### Is there a large sample database for performance testing?

Yes. Employees has 2.8 million salary rows in a 167 MB export, and TPC-H's dbgen generates any size you set with the scale factor.

### Can I use a sample database on a hosted Postgres like Neon or Supabase?

Yes. Load it with psql and the host's connection string. Neon notes that all datasets in its sample repository fit within the 500 MB free-tier branch limit.

### Why does my sample dump fail in a GUI SQL editor?

Dumps that use COPY ... FROM stdin stream data through psql and fail in GUI editors with "No source stream defined". Run them with psql -f instead.

### Are sample databases free to use commercially?

Most are under open licenses (Chinook, Pagila, Employees) or Microsoft's sample license (AdventureWorks, Wide World Importers). Check the license file in each repository before shipping one inside a product.

Read next

*   [SQL COUNTIF: HOW TO COUNT ROWS THAT MATCH A CONDITION →](https://www.aifordatabase.com/blog/sql-countif/)
*   [NORMALIZED DATABASE: 1NF, 2NF, 3NF WITH REAL ROWS →](https://www.aifordatabase.com/blog/normalized-database/)
*   [ALIASES IN SQL: COLUMN, TABLE AND SUBQUERY REFERENCE →](https://www.aifordatabase.com/blog/aliases-in-sql/)

Source: https://www.aifordatabase.com/blog/sample-database/
