About four isolation levels in the database

Source: Internet
Author: User

1.read UNCOMMITTED

You can see uncommitted data (dirty reads), for example: You believe what people say, but maybe he just says it and doesn't actually do it.

2.read committed

Reads the submitted data. However, data results that may be read multiple times are inconsistent (non-repeatable read, Phantom Read). The reading and writing view is: Read the row data, can write.

3.repeatable Read (MySQL default isolation level)

Can be read repeatedly, but with Phantom read. Read-write view: The data rows read are not writable, but new data can be added to the table. In MySQL, new data for other transactions is not visible and does not produce phantom reads. The multi-version concurrency control (MVCC) mechanism is used to solve the phantom reading problem.

4.serializable

Readable, non-writable. Like a lock in Java, writing data must wait for the end of another transaction.


"Dirty read:" When transaction one is uncommitted, transaction two queries the transaction for an updated data, at which time transaction two reads a transaction that holds the data in memory.

"Non-repeatable READ:" Transaction one in the query data, query two times different, between the two times, transaction two updated data, resulting in inconsistent data.

"Phantom reads:" The number of records in the query table for a transaction is different, because the two intermediate transactions two add or remove data row data, resulting in inconsistent record rows.





About four isolation levels in the database

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.