advancedtransactions MySQL MariaDB SQL Server PostgreSQL SQLite
Set Transaction Isolation Level
Control how much a transaction can see concurrent changes made by other transactions.
Created Last updated 0/5 supported engines validation-green1 example2 scenarios
Docker-validated Not currently validation-green
Example 1
Run a read transaction at SERIALIZABLE isolation
The transaction reads the account total under a stronger consistency mode. This matters when other sessions may be changing the same logical dataset concurrently.
BEGIN IMMEDIATE;
SELECTSUM(balance) AS total_balance
FROM
accounts;
COMMIT;
Expected result
total_balance
300
SQLite uses BEGIN IMMEDIATE to take a write-reserved lock rather than the standard isolation-level syntax.
Useful when
Where this command helps.
running a critical read-modify-write sequence
preventing inconsistent reads during a multi-statement transaction
Explanation
What the command is doing.
Transaction isolation determines which concurrency anomalies a transaction can observe, such as dirty reads, non-repeatable reads, and phantom rows. Common levels include READ COMMITTED, REPEATABLE READ, and SERIALIZABLE. The exact defaults and behavior vary by engine, but the command is useful before a transaction that needs stronger consistency than the database default.