Engine: live

SQLite, inside

How a SQLite database file is laid out, how SQL becomes bytecode, and what every instruction and setting means, with tools that run in your browser.

File viewerDrop a .db file and see its header, a map of every page and any page decoded to the byte, with column names. Nothing is uploaded.EXPLAIN visualizerType SQL and see the bytecode program it compiles to, with jumps drawn, and the query plan as a tree.The file formatPages, b-trees, cells, records, varints, overflow, the freelist, the WAL and the rollback journal, with diagrams.

Reference

All 191 VDBE opcodes, each with the official description and, for 170 of them, a real example program. Common ones: OpenRead, Column, ResultRow, Next, SeekGE, IdxGT, MakeRecord, Insert, Transaction, Halt.

All 74 pragmas, with what each returns on a real database: journal_mode, page_size, foreign_keys, integrity_check, user_version, table_info.

Start here

  1. Open the sample database in the viewer and click page 1: that is the schema table, and its first 100 bytes are the header.
  2. Click a table's root page in the schema list, then B-tree, to see how its rows are spread over pages.
  3. In the EXPLAIN visualizer, compare SELECT * FROM tracks WHERE album_id = 12 (which uses an index) with WHERE ms = 12 (which does not).