Sample Database Resources: 12 Free Datasets for SQL Practice

· 8 MIN

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
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.

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.

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.

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?

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
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 and selecting from multiple tables without JOIN.

Is There a Sample SaaS or Ecommerce Database?

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

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 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 downloadedEngineCommand
.sql scriptPostgreSQLpsql -d mydb -f file.sql
.tar or custom dumpPostgreSQLpg_restore -d mydb file.tar
.sql scriptMySQLmysql -u root -p < file.sql (add --commands on 9.5+ if it uses SOURCE)
.bak backupSQL ServerRESTORE DATABASE ... FROM DISK = '...'
.sql scriptSQLitesqlite3 file.db < file.sql
.csv filesAnycreate 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 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 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.

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.

Ready to try AI for Database?

Query your database in plain English. No SQL required. Start free today.