Database isolation Dirty Read Magic Read and non-repeatable read

Source: Internet
Author: User

I. Isolation levels and phenomena

There are 4 levels of database isolation

Read uncomitted, unauthorized reading

Read Committed, authorized to read

REPEATABLE Read, repeatable reading

Serializable, serialization

There are 3 types of inconsistencies that may occur

Dirty Read

Non-REPEATABLE READ

Phantom reading

Two, 3 kinds of phenomena

Dirty read, is read dirty data, another transaction modified data but not submitted, we read this uncommitted data is dirty data, this phenomenon is dirty read;

Take a chestnut, balance. The field value is 100, the other transaction is modified to 200, the uncommitted time we read 200, and then the transaction is rolled back, the actual value should be 100, but we read 200;

Non-repeatable read, that is, for a data, I repeat the value of the time when it changed, that is, two reads were modified by another transaction;

Another chestnut, I read the Balance field value of 100, I made a judgment (such as whether it is greater than 0), and then I read it again when it becomes 200; for 100 this value I did not read repeatedly, that is, the occurrence of non-repeatable reading;

Phantom reading, is to read again found a new record or less records, thinking that there is an illusion;

The last chestnut, when I read the data without the Balance field, I want to add balance to 0 o'clock, prompting me to exist in this field; I read this record for the second time, and I thought the first time I read it, there was an illusion;

Most of the scenes I read the first time after reading (perhaps modified a piece of data after reading), locked the one I read the data, but another transaction changed the table of other data, I read the second time I thought the first read a hallucination (it may be the first time to modify the whole table, another transaction changed only one data, I thought I hadn't succeeded in modifying the data);

Third, isolation level

Dirty Read Non-REPEATABLE READ Phantom reading
Read UNCOMMITTED May occur May occur May occur
Read committed May occur May occur
REPEATABLE READ May occur
REPEATABLE READ

Database isolation dirty Read and non-repeatable read

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.