# SQLite Bytecode Explorer

Visualize and understand the virtual machine instructions SQLite generates for your SQL queries

### How SQLite Executes Queries

SQLite compiles every SQL statement into a program for its built-in Virtual Database Engine (VDBE). The VDBE is a register-based virtual machine — each instruction (opcode) operates on numbered registers (like `r[2]`) rather than a stack. When you call `sqlite3_prepare_v2()`, SQLite parses your SQL and generates this bytecode program. Then `sqlite3_step()` executes it one instruction at a time.

Use `EXPLAIN` before any SQL statement to see its bytecode. This tool runs `EXPLAIN` for you and annotates each opcode with a human-readable explanation.

Schema Setup (optional — define tables/indexes so EXPLAIN can reference them)
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT, age INTEGER); CREATE TABLE orders (id INTEGER PRIMARY KEY, user_id INTEGER REFERENCES users(id), product TEXT, amount REAL, created DATE); CREATE INDEX idx_orders_user ON orders(user_id); CREATE INDEX idx_orders_date ON orders(created);
These CREATE TABLE / CREATE INDEX statements set up the database schema so that EXPLAIN output reflects real query plans.
SQL Query SELECT users.name, orders.product, orders.amount FROM users JOIN orders ON users.id = orders.user_id WHERE users.age > 25 ORDER BY orders.amount DESC;
Loading SQLite WASM...