REPEATABLE READ
- SQL course
- Advanced
- Lesson 57/81
- 4 min
Learn repeatable reads.
REPEATABLE READ
REPEATABLE READ ensures re-reading a row gives the same value. It prevents non-repeatable reads.
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;No non-repeatable read, phantom exists.
REPEATABLE READ — details
Phantom read: new rows may be added, the same query may return more rows.
For example, if you count orders twice with COUNT(*), the second count can differ when another transaction inserts a new order in between.
Practice REPEATABLE READ
Set the isolation level to REPEATABLE READ.
Starter code
-- high level
SETSample solution
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;Expected output
İzolasyon ayarlandı
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does REPEATABLE READ prevent?
- Dirty read
- Everyone
- Phantom read
- Non-repeatable read Correct answer
Explanation: REPEATABLE READ prevents non-repeatable reads.
2 REPEATABLE READ
SET TRANSACTION ISOLATION LEVEL ____
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
Explanation: REPEATABLE READ is the right answer.
3 REPEATABLE READ: match the terms
| Term | Meaning |
|---|---|
non-repeatable |
prevented |
phantom |
exists |
high |
safe |
same value |
consistent |