Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read rows without commit

User_19BPUJul 27 2012 — edited Jul 27 2012
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2012
Added on Jul 27 2012
14 comments
481 views