July 6, 2011

Phantom Rows in SQL Server


This situation comes when we are doing simultaneous INSERT, UPDATE and DELETE on a table.

Let suppose we have a table with structure
STUDENT (Roll, Name, Marks, Grade)

Now two person at the same time say Peter and Jim trying to UPDATE and INSERT data respectively.

Peter:

UPDATE STUDENT
SET
Grade = ‘A’
WHERE
Marks = 90


Jim:

INSERT INTO STUDENT
(Roll, Name, Marks)
VALUES
(11,’Sam’, 90)

This situation is called phantom rows.
Due to concurrency this particular record will not get affected.

No comments:

Post a Comment