Cari Blog Ini

17 Juli 2012

Concurrent Transaction Behavior in SQL Server

* Dirty read
A read that contains uncommitted data.
A dirty read occurs when one transaction modifies data
and a second transaction reads the modified data
before the first transaction has committed the changes.
That data is not yet a permanent part of the database and could possibly be rolled back.

* Non-repeatable read
When one transaction reads a row,
then a second transaction modifies the same row,
and then the first transaction reads that row again, getting different results.

Because the first transactions repeated reads retrieve different data,
the results are not repeatable within that transaction.


* Phantom read
A read that occurs when a transaction attempts to retrieve a row
that does not exist when the transaction begins
but that is inserted by a second transaction before the first transaction finishes.

If the first transaction again looks for the row,
it will find that the row has suddenly appeared.
The same situation could occur with a row delete;
a row that was existing later disappears.
This is called a phantom row.


Source:
Microsoft SQL 2005 Administrator's Companion,
Chapter 17 - Transaction and Locking
Page 487