Field Manual PHP / Laravel reference
← SQL

Isolation

Isolation controls how concurrent transactions observe/interfere with each other.

What it is

Isolation controls how concurrent transactions observe/interfere with each other.

When to use it

Choose locking or conditional updates based on invariants and engine behavior.

Syntax

-- SQLite writer serialization:
BEGIN IMMEDIATE;
-- bounded writes
COMMIT;

Example

-- PostgreSQL example, not SQLite:
BEGIN ISOLATION LEVEL SERIALIZABLE;
SELECT balance_cents FROM accounts WHERE id = 7;
-- Apply business changes; retry the whole transaction on serialization failure.
COMMIT;

Common mistakes

SQLite has no SELECT FOR UPDATE row locks; serializable transactions may fail and require bounded retry.

Related topics

Browse SQL