On 1/15/16, Olivier Vidal <vidal.olivier at mac.com> wrote: > > Hello all, > > I would like to be sure I understand the difference between an IMMEDIATE > transaction and a DEFERRED transaction, in WAL mode.
BEGIN IMMEDIATE claims a write lock on the database file immediately, so that no other process or thread can come along and start a second write transaction until after the one you just started finishes. BEGIN DEFERRED (the default) waits for the first actual change to the database (a subsequent DELETE, INSERT, or UPDATE) before acquiring the write lock. That means that even though the "BEGIN" was successful, the next write operation might fail with an SQLITE_BUSY error if another thread or process jumps in line ahead of you and acquires the write lock. -- D. Richard Hipp drh at sqlite.org