Phantom reads

Phantom reads

A phantom read occurs when, in the course of a transaction, two identical queries are executed, and the collection of rows returned by the second query is different from the first.
This can occur when range locks are not acquired on performing a SELECT ... WHERE operation.
This anomaly is a special case of Non-repeatable reads when Trans.1 repeats a ranged SELECT ... WHERE query and, between both operations, Trans.2 creates new rows (in the target table) which fulfill that WHERE clause.
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;

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
сніпети з SQL
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести