HeadlinesBriefing favicon HeadlinesBriefing.com

SQLite's Three Journal Types Explained

DEV Community •
×

SQLite's rollback journal handles crash recovery, but two lesser-known journals ensure broader correctness. The statement journal rolls back partial effects of a single SQL statement that fails midway, keeping the user transaction active. It's a temporary file deleted after execution, storing no crash-recovery metadata.

For multi-database transactions, SQLite uses a master journal to guarantee global atomicity. When committing changes across multiple attached databases, each has its own rollback journal. The master journal coordinates these child journals, ensuring all or nothing commits. Without it, a crash could leave databases in an inconsistent state.

This legacy journaling architecture provides layered safety. Rollback journals protect against crashes, statement journals handle mid-statement failures, and master journals maintain atomicity across databases. With storage and journaling covered, the next focus shifts to runtime behavior: transaction types and locking modes.