DataBrighten

    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.

    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.