This is a situation that can occur at lower isolation levels, which Oracle actually does not support.
First, a different term, which most people have heard of is a dirty read. User A is in the midst of changing a given record and User B is allowed to read those changes (that 'dirty' record) before they are committed. Well, what if User A does a rollback? Then User B read altered data that was never committed. Take this to the next step. What if User A is inserting a record and User B is allowed to read that record? Now what if User A does a rollback? User B has read a record that was never 'really' inserted into the database because it was never committed. They have performed a 'phantom' read.
A phantom read occurs if a transaction re-executes a query returning a set of rows that satisfies a search condition and finds that another committed transaction has inserted additional rows that satisfy the condition.
A dirty read occurs if a transaction reads data that has been written by another transaction that has not been committed yet.
Phantom reads are possible in Oracle, dirty reads not.
You can change the isolation level of the transaction to prevent phantom reads.
No relationship, obviously, to Java phantom refrences (which are used to effectively delay garbage collection of objects which you MIGHT want to re-use later, but which can be recreated if unavailable).
BTW - thanks for the excellent descriptions - phantom reads and dirty reads have been pretty muddled in my brain.
Bookmarks