Dirty reading, non-repeatable reading, virtual reading and four isolation levels

Source: Internet
Author: User

Dirty Read dirty reads: This event occurs when a transaction reads data that has not yet been committed. For example: Transaction 1 modifies a row of data, and Transaction 2 reads the modified row before Transaction 1 has committed the modification operation. If Transaction 1 rolls back the modification operation, the data read by Transaction 2 can be seen as never existed.


Non-repeatable Read non-repeatable reads: This event occurs when a transaction reads the same row of data two times, but each time the data gets different. For example: Transaction 1 reads a row of data, and then Transaction 2 modifies or deletes the row and commits the modify operation. When Transaction 1 attempts to reread the row, it gets a different data value (if the row is updated) or discovers that the row no longer exists (if the row is deleted).


Virtual Read Phantom read: This event occurs if a row of data that meets the search criteria appears in a subsequent read operation, but the row data is not part of the original data. For example: Transaction 1 reads some rows that satisfy a certain search condition, and Transaction 2 inserts a new line that matches the search criteria for Transaction 1. If Transaction 1 re-executes the query that produced the original rows, it will get a different row.

Read_uncommitted: Dirty read, non-repeatable read, Phantom Read (no lock when reading data)
Read_committed: A non-repeatable read, Phantom read problem "locks the rows being read. Add a read lock before reading the data and release the lock after reading
Repeatable_read: The Phantom reads "Lock all rows read." Before reading the data, add a read lock, do not release the lock after reading, until the transaction rollback or commit to release the lock "
SERIALIZABLE: Ensure that all the circumstances do not occur. "Lock table." Before reading the data, locking (called the conditional Lock), does not release the lock after reading, until the transaction rollback or commits to release the lock "

Dirty reading, non-repeatable reading, virtual reading and four isolation levels

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.