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