SQLite PRAGMA Statements
Database configuration with PRAGMA
Database Info
PRAGMA database_list; # list attached databases
PRAGMA table_info(users); # table structure
PRAGMA index_list(users); # list table indexes
PRAGMA foreign_key_list(orders); # list foreign keys
Foreign Keys
PRAGMA foreign_keys = ON; # enable foreign keys
PRAGMA foreign_keys = OFF; # disable foreign keys
PRAGMA foreign_keys; # check status
Journal Mode
PRAGMA journal_mode = DELETE; # default mode
PRAGMA journal_mode = WAL; # write-ahead logging (faster)
PRAGMA journal_mode = MEMORY; # in-memory journal
PRAGMA journal_mode = OFF; # no journal (risky)
Synchronous
PRAGMA synchronous = FULL; # safest (default)
PRAGMA synchronous = NORMAL; # good balance
PRAGMA synchronous = OFF; # fastest (risky)
Cache Size
PRAGMA cache_size = 10000; # set cache size (pages)
PRAGMA cache_size; # get cache size
Auto Vacuum
PRAGMA auto_vacuum = NONE; # no auto vacuum (default)
PRAGMA auto_vacuum = FULL; # full auto vacuum
PRAGMA auto_vacuum = INCREMENTAL; # incremental vacuum
Integrity Check
PRAGMA integrity_check; # check database integrity
PRAGMA quick_check; # faster integrity check