// sqlite · wal, redo & durability

journal_mode

How SQLite keeps transactions atomic: a rollback journal or a write-ahead log (WAL).

Padrão
delete
Range
DELETE, TRUNCATE, PERSIST, MEMORY, WAL, OFF
Restart needed
Não
Default checked on
SQLite 3.5x

O que faz

DELETE (the default) writes original pages to a -journal file and deletes it at commit. WAL appends changes to a -wal file instead, so readers do not block the writer and the writer does not block readers; there is still only one writer at a time.

Valor padrão

delete. DELETE for file databases (a stock SQLite 3.5x build); in-memory databases report memory.

Check the current value

PRAGMA journal_mode;

SELECT * FROM pragma_journal_mode;   -- table-valued form, usable in queries

Change it

PRAGMA journal_mode = WAL;   -- stored in the database file

No restart. The value is stored in the database file, so every later connection gets it.

When to change it

Use WAL for almost any application database with concurrent readers, such as a web app or a desktop app with background work. It is the one journal mode that persists in the file.

What can go wrong

WAL needs shared memory, so it does not work on network file systems, and the -wal and -shm files must travel with the database. OFF and MEMORY can corrupt the database if the process crashes mid-transaction.

Questions about journal_mode

What is the default value of journal_mode in SQLite?

delete. DELETE for file databases (a stock SQLite 3.5x build); in-memory databases report memory.

Does changing journal_mode require a restart?

No. No restart. The value is stored in the database file, so every later connection gets it.

When should I change journal_mode?

Use WAL for almost any application database with concurrent readers, such as a web app or a desktop app with background work. It is the one journal mode that persists in the file.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check journal_mode on your own server

SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.