Four features and isolation levels for "Mysql" transactions

Source: Internet
Author: User
Four types of features:

Atomicity (atomicity): All operations in a transaction are treated as a collation, either complete or all rolled back.

Consistency (consistency): The data in the database is logically consistent before and after the operation. For example: 1w yuan transfer to different people, turn out and should be equal to 1w yuan, the balance should be 0.

Isolation (Isolation): Transactions should not interfere with each other and perceive each other.

Persistence (Durability): The operation on the database is committed once (even if the database fails, this commit should be completed) and will not change until the next transaction operation data.

Isolation level of the transaction:

Personal feelings can be understood in response to the security level of the transaction:

1.Read UNCOMMITTED (READ UNCOMMITTED)--no isolation, dirty reads can occur: Dirty reads refers to transaction a access to the uncommitted data of transaction B, then transaction B is rolled back, and transaction a resumes execution with uncommitted data.

2.Read committed (Read Committed)-the verse is readable after a transaction is committed, so it is not dirty to read, but the non-repeatable read problem can still occur: when a transaction reads the same data multiple times, because the commit of another transaction causes the data to change, the data that is read before and after is inconsistent.

3. REPEATABLE READ (Repeatable Read)-this level avoids dirty reads and non-repeatable reads, but may have a virtual read problem: For example, A=1, transaction 1 changes it to 2, transaction 2 accesses to a=2, and transaction 3 changes a back to 1. Transaction 2 operation ends Discovery A=1.

4.erializable (serialization): Serial execution between transactions to avoid dirty reads, non-repeatable reads, and the occurrence of virtual reads.

Performance drops at one of four isolation levels. In most cases, you can do this at the read Committed isolation level.

The default isolation level in the MySQL database is repeatable read (repeatable read).

Four features and isolation levels for "Mysql" transactions

Related Article

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.