Please explain and elaborate 1Dirty reads 2 Nonrepeatable re
Please explain and elaborate 1.Dirty reads 2. Non-repeatable reads 3. Phantom reads for resource locking.
Solution
Answer:
Dirty Read : Here a transaction reads that data which is been written by any other transaction that is not committed yet. Here is the example :
Transaction X begins :
UPDATE STUDENT SET MARKS = 95 WHERE STUDENT ID = \'1337\' ;
Transaction Y begins :
SELECT * FRON STUDENT
Now the transaction Y sees the data which is updated by X, but those updates have not yet been committed.
2. Non-repeatable reads :- This happens when in same transaction , same query gives different results. It happens when the same transaction repeatedly retrieves the data.
Example :
Transaction A begins :
SELECT* FROM STUDENT WHERE STUDENT ID = \'1337\';
Transaction B begins
UPDATE STUDENT MARKS= 98 WHERE STUDENT ID = \'1337\';
Here the transaction B updates the rows viewed by A before transaction A commits.
3. Phantom reads : -
It occurs where in a transaction execute same query more than once.
