SQLite sample databases for practice
SQLite is a database in a single file with no server to install, which makes it the quickest way to start practising SQL. It is built into Python, phones and most browsers. Here are 13 practice databases as SQLite scripts, each with six questions whose answers were produced by SQLite 3.37.2.
Sales orders
Superstore-style retail orders with sales, cost, discount and profit.
SQLiteOnline store
Four related tables (customers, products, orders, order items) for JOIN practice.
SQLiteEmployees
An HR table: departments, titles, hire dates, salaries and managers.
SQLiteCustomers
A customer list with segments, order counts, lifetime spend and activity.
SQLiteInventory
Stock levels, reorder points and stock value across four warehouses.
SQLiteStudent grades
Test scores, averages, letter grades and attendance for grades 9-12.
SQLiteWebsite traffic
Daily sessions, users, bounce rate and conversions by channel.
SQLiteMarketing campaigns
Budget, spend, impressions, clicks, CPA and ROAS per campaign.
SQLiteCall center
Calls with queue, reason, wait and handle time, resolution and CSAT.
SQLiteRestaurant orders
Order lines with menu items, tickets, order type and payment.
SQLiteInvoices
Invoices with due dates, payment dates, tax, status and days late.
SQLiteBank transactions
One fictional account: debits, credits, categories and a running balance.
SQLiteMessy customers
A customer list with duplicates, blanks, mixed dates and text in number columns.
SQLite SQL in these exercises
The questions are the same on every engine; what changes is the syntax. These are the SQLite-specific parts you will meet:
- strftime('%Y-%m', date) turns a date into year-month text.
- strftime('%Y', date) returns text, so it is cast to INTEGER.
- julianday(b) - julianday(a) gives the number of days between two dates.
- LIMIT n at the end returns the first n rows.
- SQLite has no boolean type: yes/no columns hold 1 and 0.
- || joins strings.
- substr(text, start, length) cuts out part of a string.
- Multiplying by 1.0 forces decimal division instead of integer division.
- AVG works on integers and decimals directly.
- Window functions need SQLite 3.25 or later.
- LENGTH counts characters.
- Text comparison is case-sensitive by default, so 'A@x.com' and 'a@x.com' count as two values.
Other engines
PostgreSQL · MySQL · SQL Server · DuckDB
The data is fictional and released under CC0. AdventureWorks, Northwind and Sakila are well-known sample databases from their vendors; we do not copy them here.