wasAsked.

What is isolation and ACID properties?

Agiliad Technologies Pvt Ltd · Role not specified · technical

Published

Asked in 2026 · SQL

Community answers

Posted by wasAsked editorial collection

ACID properties describe what a reliable database transaction guarantees. A — Atomicity - All operations in a transaction succeed together, or none of them take effect. - Example: a money transfer debits one account and credits another; if the credit fails, the debit is rolled back. C — Consistency - A transaction moves the database from one valid state to another, respecting all rules: constraints (primary keys, foreign keys, CHECK constraints), triggers and cascades. Invalid data is rejected and the transaction rolls back. I — Isolation - Concurrent transactions do not interfere with each other in unexpected ways; each behaves as if it were running alone to a degree defined by the isolation level. D — Durability - Once a transaction commits, its changes survive crashes and power failures, because they are written to the transaction log (write-ahead logging) before the commit is acknowledged. Isolation in detail Isolation levels balance correctness against concurrency by preventing certain anomalies: - Dirty read: reading another transaction's uncommitted changes. - Non-repeatable read: reading the same row twice and getting different values. - Phantom read: re-running a query and getting new rows. Levels (SQL standard, as implemented in SQL Server) - Read Uncommitted: dirty reads allowed (fastest, least safe; same as NOLOCK hints). - Read Committed (default): no dirty reads; other anomalies possible. With READ_COMMITTED_SNAPSHOT enabled, readers see the last committed version instead of waiting for locks. - Repeatable Read: rows you read cannot be changed by others until you finish; phantoms still possible. - Serializable: full isolation as if transactions ran one after another; uses range locks; most blocking. - Snapshot: reads a consistent version of data as of the start of the transaction using row versioning; writers do not block readers; update conflicts cause errors that must be retried. Practical guidance - Use the default (often Read Committed with row versioning) for most workloads. - Handle concurrency explicitly where it matters: optimistic concurrency with rowversion columns, conditional updates, or higher isolation for specific critical transactions. - Keep transactions short to reduce locking and deadlocks. - Avoid NOLOCK in business logic, because it can return uncommitted or even duplicated or missing rows.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics