1. Four characteristics of a transaction (ACID)
Analyzed by the transfer business.
A. atomicity
The operational steps of a transaction are inseparable, either all succeed or all fail. A to B transfer, a If the debit, B must increase the balance, A and B account changes at the same time, or failure.
B. Consistency
Transactional consistency means that the database must be in a consistent state before and after a transaction is executed. This attribute is called transactional consistency. If the state of the database satisfies all the integrity constraints, the database is said to be consistent.
For example, integrity constraint a+b=10, a transaction changes A, then B should change as well.
C. Isolation
Concurrent transactions are isolated from each other. That is, the operations within a transaction and the data being manipulated must be blocked from being seen by other transactions attempting to modify it. The execution of multiple concurrent transactions that manipulate the same shared object can cause an exception if there is no control over the concurrent cross-executing transactions.
D. Persistence
Persistence means that updates to committed transactions cannot be lost when a system or media failure occurs. That is, once a transaction commits, the DBMS guarantees that its changes to the data in the database should be permanent, that is, the update to the committed transaction can be restored. Persistence is ensured through database backup and recovery.
2. Start and end of a transaction
A. Start of a transaction using the start Transaction command
B. End of transaction using a commit or rollback command (rollback can roll the transaction back to the state before the transaction begins)
MySQL Learning (a) business