Transactional characteristics and isolation level

First, the transaction characteristics

1. atomicity

Atomicity of transactions that is required to ensure that the transaction is an atomic operation, or submitted with all succeed or all fail together rollback, the transaction can not be a part of the complete

2. Consistency

Transactional consistency, that is always a database from one consistent state to another consistent state that is abnormal or whether a machine failure occurs, the transaction if there is no final submission, the transaction will not have been executed statement generated database influences

3. Isolation

Operation made before a transaction commits successfully, to other transactions is not visible

4. endurance

Once the transaction successfully submitted, that the changes made to the database data will be permanently saved to the database

Second, the isolation level

1. uncommitted read (READ UNCOMMITTED)

Operations in the transaction performed, even if not submitted, are also visible to other transactions (a transaction can read uncommitted transactions other events, become a dirty read)

2. Read Committed (READ COMMITTED)

A transaction, see the changes made before less than other uncommitted transactions, but other transactions once submitted, this transaction will be visible modify it. Therefore, when you execute the same query in a transaction, you may get different results (the middle of the modified transaction data submitted by the success of the investigation), called non-repeatable read

3. Repeatable Read (REPEATABLE READ)

Repeatable read is the default isolation level mysql, never the solution of the problem of dirty read, the result of a transaction level to ensure that the same query multiple times unchanged. But created new problems "phantom reads", that is, other transactions and re-insert the query data within the transaction scope, then it will produce phantom read that query results will be more of the newly inserted data. Innodb mvcc decision by the solution of this problem

4. serialization (SERIALIZABLE)

The highest isolation level, the transaction serialization execution, never the solution of the problem of phantom read, but had a great impact on performance

Published 17 original articles · won praise 1 · views 646

Guess you like

Origin blog.csdn.net/c_c_y_CC/article/details/104620511