What is a transaction?
A transaction is a whole that consists of one or more SQL statements, and if all statements execute successfully then the modification will take effect, if one SQL statement will sell +1, the next +1, and if the second fails, then sales will undo the +1 operation of the first SQL statement. The modification is added to the database only if all the statements in the transaction are executed successfully.
Features of the transaction:
Atomic Nature
Atomicity means that the firm has an operation or all succeeds, or all fails to roll back, so the operation of the transaction must be fully applied to the database if it succeeds, if the operation fails it will have any effect on the database.
Consistency
Consistency means that a transaction must transform a database from one consistent state to another, meaning that a transaction must be in a consistent state after execution.
Take the transfer, assuming that user A and User B are altogether 5000, then no matter how the money between A and B two users together should be 5000, which is the consistency of the transaction.
Isolation of
Isolation is when multiple users access the database concurrently, such as when working with the same table, the database opens a transaction for each user and is not disturbed by other operations
, the concurrent transactions are isolated from each other.
Durability
Persistence means that once a transaction is committed, changes to the data in the database are permanent.Mysql中支持事务的引擎在mysql中用的最多 的存储引擎有:INNODB , BDB ,MYISAM, MEMORY,其中 INNODB ,BDB 支持事务,其他的不支持事务。
What is a database transaction?