Sample databases for SQL practice
13 practice databases, each as a ready-to-run script for SQLite, PostgreSQL, MySQL, SQL Server and DuckDB: 65 scripts in all, with six questions per database written in each dialect.
SQLite
SQLite is a database in a single file with no server to install, which makes it the quickest way to start practising SQL.
enginePostgreSQL
PostgreSQL is the open-source database most often used for new applications and data work, with strict types, real booleans and dates, and a rich set of functions..
engineMySQL
MySQL is the open-source database behind many websites, including WordPress.
engineSQL Server
Microsoft SQL Server is the database many companies run for business systems and reporting, and the free Developer and Express editions run on Windows, Linux and Docker.
engineDuckDB
DuckDB is an in-process analytics database: like SQLite it needs no server, but it is built for fast GROUP BY and window queries over large tables, and it reads CSV and Parquet files directly..
Every database and engine
| Database | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
|---|---|---|---|---|---|
| Sales orders | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Online store | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Employees | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Customers | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Inventory | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Student grades | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Website traffic | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Marketing campaigns | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Call center | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Restaurant orders | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Invoices | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Bank transactions | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
| Messy customers | SQLite | PostgreSQL | MySQL | SQL Server | DuckDB |
How they were tested
Each script was loaded with the engine's own command-line tool (sqlite3, psql, mysql and sqlcmd; DuckDB through its Python package) into an empty database, the row counts were checked, and all six questions were run. The tested versions were SQLite 3.37.2, PostgreSQL 15.18, MySQL 8.4.13, SQL Server 2022 16.0.4325.4 and DuckDB 1.5.6. A database is published only when all five engines return the same answers.
The data is fictional: the same seed-42 tables as our sample datasets, so you can practise the same question in Excel, pandas and SQL and compare. Released under CC0.