tinySQL SQL Playground (demo)

July 9, 2026 · View on GitHub

A practical SQL playground that seeds sample data into an in-memory (or file-backed) tinySQL database and lets you explore it interactively or via a SQL script.

Features

  • Seed mode – Creates users, orders, order_audit, sales, articles, and docs sample tables.
  • Feature tour – Runs a guided tour of joins, PIVOT/window functions, JSON, triggers, full-text search, vector search, CTEs, temp tables, UPDATE/DELETE.
  • Script mode – Executes any SQL script file (.sql) statement by statement.
  • Interactive REPL – Drops into a live SQL shell after setup.
  • Timer – Optionally prints per-statement execution time.
  • Persistent storage – Point at a file-based DSN to persist data across runs.

Build

go build -o demo .

Usage

demo [OPTIONS]

Options:
  -dsn string       Storage DSN (default: in-memory)
                      mem://?tenant=default
                      file:/tmp/mydb.db?tenant=main&autosave=1
  -seed             Populate sample tables (default: true)
  -script FILE      Execute SQL statements from FILE
  -interactive      Start interactive SQL shell after setup
  -timer            Print execution time for every statement
  -quiet            Suppress DDL/DML confirmation output

Examples

Built-in feature tour (default)

./demo

Runs the full feature tour against freshly seeded sample data.

Execute a SQL script

./demo -script my_queries.sql

Executes every statement in my_queries.sql against the seeded tables.

Interactive playground

./demo -interactive

Seeds sample data and opens a REPL where you can enter any SQL:

tinySQL playground — type SQL ending with ';' to execute, '.quit' to exit.
  .tables   list tables      .help   show this message

sql> SELECT name, email FROM users WHERE active = TRUE;
name   email
-----  -----------------
Alice  alice@example.com
Bob    NULL
(2 row(s))

sql> .quit
Bye.

Persistent database

./demo -dsn "file:/tmp/mydb.db?tenant=main" -interactive

The database is saved to /tmp/mydb.db; run again without -seed to keep existing data:

./demo -dsn "file:/tmp/mydb.db?tenant=main" -seed=false -interactive

Skip seeding, run a script on an existing database

./demo -dsn "file:/tmp/mydb.db?tenant=main" -seed=false -script report.sql

Time every statement

./demo -timer -script heavy_queries.sql

Sample data

After seeding, six tables are available. The most commonly used are:

users (id INT, name TEXT, email TEXT, active BOOL)

idnameemailactive
1Alicealice@example.comtrue
2BobNULLtrue
3Carolcarol@example.comNULL

orders (id INT, user_id INT, amount FLOAT, status TEXT, meta JSON)

iduser_idamountstatus
1011100.5PAID
102175.0PAID
1032200.0PAID
104220.0CANCELED

order_audit records inserted order IDs through an AFTER INSERT trigger; sales, articles, and docs power the PIVOT/window, full-text, and vector search steps in the feature tour.