Read rows without commit
Hi,
A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction and not yet committed.
For example,
Transaction 1 -
/* Query 1 */
SELECT age FROM users WHERE id = 1;
/* will read 20 */
Transaction 2
/* Query 2 */
UPDATE users SET age = 21 WHERE id = 1; // here there is no commit
/* No commit here */
Transaction 1
/* Query 1 */
SELECT age FROM users WHERE id = 1;
/* will read 21 */
Since there is no commit how come the when the transaction1 again reads the data it will get the updated value as 21 instead of 20. I am not getting this whether in Oracle without commit also the record will be updated when we issue the update command? Then what is the need for a separate commit? Please clarify.
Thanks.