4 Properties of Transactions : ACID
Atomicity , Consistency , Isolation , Durability _ _
Atomicity: refers to the impact of certain sql sentences , either all or none of them occur .
Consistency : The data before and after the transaction is kept reasonably consistent in business .
Isolation : During the process of a transaction , other transactions can not see any effect of this transaction .
Persistence : Once a transaction occurs , it cannot be cancelled . It can only be offset by compensatory transactions .
Transactions and Engines :
The myisam engine does not support transactions , the innodb and BDB engines do .
Transaction usage flow :
Simpler :
start transaction start transaction
execute query xxxx
Commit transaction / rollback transaction.commit /rollback
set session transaction isolation level [read uncommitted | read committed | repeatable read |serializable]
read uncommitted: Read uncommitted transaction content , obviously not atomic , called "dirty read".
read committed: During the process of one transaction , the operation of another transaction cannot be read , but the impact of another operation that ends the transaction can be read .
Repeatable read: Repeatable read , that is, in the process of a transaction , all information comes from the information at the moment when the transaction starts , and is not affected by other committed transactions . ( Most systems use this isolation level )
Serializeable is serialized , all transactions must be numbered and executed one by one in order , which eliminates the possibility of conflicts . This way the isolation level is the highest , but the waiting for transactions to wait for each other is long . In practice , it is not a lot .
Set the level of the transaction
set session transaction isolation level read uncommitted;