Skip to main content
InterviewHubPRO
Section Overview
Q15

Question 15 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

30%
MySQL & InnoDB (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are the four ANSI SQL Transaction Isolation Levels in MySQL?

senior LevelCode ExampleSystem DesignDatabases & SQLMySQL

In Simple Words:

  1. READ UNCOMMITTED: Dirty reads allowed (reads uncommitted changes from other transactions).
  2. READ COMMITTED: Reads only committed data. Non-repeatable reads possible.
  3. REPEATABLE READ (MySQL Default): Consistent reads within the transaction. Prevents dirty reads and non-repeatable reads; uses Next-Key Locks to prevent phantom reads!
  4. SERIALIZABLE: Highest isolation. Automatically converts plain SELECT queries into SELECT ... FOR SHARE lock queries.
text
Isolation Levels & Anomalies:
┌──────────────────┬────────────┬─────────────────────┬──────────────┐
│ Isolation Level  │ Dirty Read │ Non-Repeatable Read │ Phantom Read │
├──────────────────┼────────────┼─────────────────────┼──────────────┤
│ READ UNCOMMITTED │ YES        │ YES                 │ YES          │
│ READ COMMITTED   │ NO         │ YES                 │ YES          │
│ REPEATABLE READ  │ NO         │ NO                  │ NO (in InnoDB)│
│ SERIALIZABLE     │ NO         │ NO                  │ NO           │
└──────────────────┴────────────┴─────────────────────┴──────────────┘