Database / SQLite Interview questions
What is the PRAGMA statement used for?
PRAGMA is SQLite's mechanism for querying or modifying internal engine settings and behavior
— configuration knobs that aren't part of standard SQL but control how SQLite itself operates for the
current connection or database.
PRAGMA foreign_keys = ON; -- enable foreign key enforcement PRAGMA journal_mode = WAL; -- switch to write-ahead logging mode PRAGMA table_info(person); -- inspect a table's column definitions PRAGMA integrity_check; -- verify database file consistency
Some pragmas are per-connection settings that reset each time you reconnect (like
foreign_keys), while others persist as part of the database file itself (like
journal_mode = WAL). Because there's no separate configuration file or server settings panel the
way client-server databases have, pragmas are how essentially all of SQLite's tunable behavior is accessed.
More Related questions...