Reserve the write lock up front.

Section: Transactions and savepoints

Begin an IMMEDIATE transaction

sql
sql
BEGIN IMMEDIATE;
Explanation

Useful when you know the transaction will write and want to fail early if the database is busy.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Transactions and savepoints
Start a transaction
Bundle multiple statements atomically.
OpenIn sheetsqlsame section
Roll back a transaction
Undo uncommitted changes.
OpenIn sheetsqlsame section
Use a savepoint
Create a nested rollback point within a transaction.
OpenIn sheetsqlsame section
Enable WAL journaling
Switch the database to write-ahead logging mode.
OpenIn sheetsql1 tag match
Set a busy timeout
Wait briefly when the database is locked.
OpenIn sheetsql1 tag match
Run a WAL checkpoint
Merge WAL contents back into the main database file.
OpenIn sheetsql1 tag match