Skip to content
SQLite

PRAGMA Statements

Configure SQLite behavior and inspect the database.

#pragma#configuration#wal

Code

sqlite
-- Foreign keys (off by default)
PRAGMA foreign_keys = ON;
PRAGMA foreign_keys;            -- show current value

-- WAL mode for better concurrency
PRAGMA journal_mode = WAL;
PRAGMA wal_autocheckpoint = 1000;

-- Performance tuning
PRAGMA synchronous = NORMAL;    -- FULL | NORMAL | OFF
PRAGMA cache_size = -20000;     -- 20MB negative = kibibytes
PRAGMA temp_store = MEMORY;
PRAGMA mmap_size = 268435456;   -- 256MB memory-mapped I/O

-- Introspection
PRAGMA table_info(users);
PRAGMA index_list(posts);
PRAGMA database_list;
PRAGMA integrity_check;