SQL - Transactions and Data IntegrityWhy do phantom reads occur even when a transaction reads the same query twice under REPEATABLE READ isolation?ABecause REPEATABLE READ causes lost updatesBBecause REPEATABLE READ allows dirty readsCBecause REPEATABLE READ does not prevent non-repeatable readsDBecause REPEATABLE READ does not lock range scans, allowing new rows to appearCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand REPEATABLE READ lockingREPEATABLE READ locks rows read but does not lock the range of rows scanned, so new rows can be inserted and appear on repeated queries.Step 2: Identify cause of phantom readsPhantom reads happen because new rows appear in the range, which REPEATABLE READ does not prevent.Final Answer:Because REPEATABLE READ does not lock range scans, allowing new rows to appear -> Option DQuick Check:Phantom reads allowed by range scan gaps [OK]Quick Trick: REPEATABLE READ misses range locks, causing phantom reads [OK]Common Mistakes:Thinking REPEATABLE READ allows dirty readsConfusing phantom reads with non-repeatable readsAssuming lost updates cause phantom reads
Master "Transactions and Data Integrity" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Advanced Window Functions - LEAD function for next row access - Quiz 10hard CASE Expressions - CASE in WHERE clause - Quiz 4medium CASE Expressions - Nested CASE expressions - Quiz 15hard CASE Expressions - CASE with aggregate functions - Quiz 7medium CASE Expressions - CASE in WHERE clause - Quiz 11easy Database Design and Normalization - First Normal Form (1NF) - Quiz 8hard Database Design and Normalization - Why normalization matters - Quiz 3easy Indexes and Query Performance - When indexes help and when they hurt - Quiz 5medium Indexes and Query Performance - Index impact on INSERT and UPDATE - Quiz 7medium Window Functions Fundamentals - OVER clause with PARTITION BY - Quiz 15hard