Running SQL in Zerethon IDE
What Run does in the SQL Playground, setup files, result tables, limits, query plans and tests.
Runs in Zerethon IDE · SQLite 3
Official SQL documentation ↗
- Run (Ctrl/⌘+Enter) creates a new, empty in-memory SQLite database, runs every
setup/*.sqlfile (sorted by name), importsdata/*.csv, then runs the entry file —main.sqlby default. Make another file the entry with the ▶ button next to it in the explorer. - Results are tables (at most 200 rows shown each); statements that change data show how many rows they changed. The first error stops the run and shows the file and line.
- A statement is stopped after 5 seconds and a run after 10. There is one database per run:
ATTACH, extensions and database files are not available, and it is never a real server. - When a query fails with “no such table”, the editor offers to create a
setup/file for the missing tables. EXPLAIN QUERY PLAN SELECT …is shown as a tree, so you can see whether an index is used.- Run tests (Ctrl/⌘+Shift+Enter) runs every
test_*.sqlfile on its own fresh database (aftersetup/anddata/). A test file passes when none of its statements fails.
test_school.sql
-- A failed check stops the file: the CHECK constraint rejects ok = 0.
CREATE TEMP TABLE checks (name TEXT NOT NULL, ok INTEGER NOT NULL CHECK (ok = 1));
INSERT INTO checks VALUES ('4 students', (SELECT count(*) = 4 FROM students));
INSERT INTO checks VALUES ('Linus has no courses',
(SELECT count(*) = 0 FROM enrollments WHERE student_id = 4));
SELECT 'All ' || count(*) || ' checks passed.' AS result FROM checks;
Tip: Format uses sql-formatter with the SQLite dialect.