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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
SQL snippets
Cosmo
Sign Up Now
or Subscribe for future quizzes