Ten: a transaction in MySQL

Source: Internet
Author: User

Objective:

Because there is not much time and effort, it is not possible to delve into the transactions in the database, such as

However, some basic knowledge of the transaction, still need to be firmly mastered, to understand the basic knowledge of the transaction, in the actual development can understand the various persistence layer framework of transaction processing

A: Is it a business?

The following is the result of Baidu Encyclopedia

   

In development, for a series of CRUD operations that require data for a business logic, we can call it a transaction

Understanding transactions in this way requires understanding the four main features of transactions: atomicity, consistency, isolation, persistence

Two: Four characteristics of Business--acid 2.1: atomicity

All operations on the data in a transaction, belong to a unit, indivisible, only success or failure, it is impossible for an operation to succeed an operation failed

2.2: Consistency

Before and after the transaction, data consistency, under the established rules of the transaction process, must strictly follow the established rules of the operation of data, non-destructive rules

Consistency tasks for maintaining data should be done by programmers

For example, before the data modification for 10.00 changed to 5.5 to meet the consistency should be 5.50 (this is my own understanding)

2.3: Isolation

In the case of concurrent transactions, multiple transactions are isolated from each other and do not affect each other

2.4: Persistence

After the transaction is committed correctly, changes to the data will be permanent

Three: Isolation level of a transaction

Read operations that are reflected in concurrent transactions

Transactions have four isolation levels: read-uncommitted, read COMMITTED, repeatable read, SERIALIZABLE

3.1: Dirty Read

Read from transaction A to transaction B modified but uncommitted data

3.2: Non-repeatable reading

A dirty read was resolved, but the data after the commit of transaction B could be read in transaction a (resulting in a different result than performing the same read multiple times in transaction a)

3.3: Repeatable READ

Fixed non-repeatable reads, but transaction B reads the same operation before and after committing the transaction, and finds that the results are different, as if the previously read data were an illusion

3.4: Serialization Four: Classification of transactions

4.1: Flat Business (FLAT TRANSACTION)

4.2: Flat transaction with SavePoint (FLAT TRANSACTION with savpoints)

4.3: Chained transaction (Chained TRANSACTION)

4.4: Nested transaction (Nested Transaction) InnoDB not supported

4.5: Distributed Transaction (distributed Transaction)

V: the transaction in MySQL

InnoDB is the default storage engine for MySQL databases and supports transactional operations

Originally want to own personally test, different transaction isolation level on the impact of data read, think or forget it, understand it can be

MySQL default transaction ISOLATION level is REPEATABLE READ---repeatable READ

  

Ten: a transaction in MySQL

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.