‹ BACK

Phantom reads Example

Phantom reads Example

Trans.1 Trans.2
SELECT * FROM users
WHERE age BETWEEN 10 AND 30;
INSERT INTO users(id,name,age) 
VALUES ( 3, 'Bob', 27 );
COMMIT;
SELECT * FROM users
WHERE age BETWEEN 10 AND 30;
COMMIT;
Note that Trans.1 executed the same query twice. If the highest level of isolation were maintained, the same set of rows should be returned both times, and indeed that is what is mandated to occur in a database operating at the SQL SERIALIZABLE isolation level. However, at the lesser isolation levels, a different set of rows may be returned the second time.
phantom-read transactions isolation SQL-SERIALIZABLE

To check your knowledge the following tests are recommended:
Check your sql sql skills.