A transaction is a user-defined sequence of database operations that is either done or not, and is a non-partitioned unit of work.
Statements that define transactions
BEGIN TRANSACTION;
Commit,----all actions to commit a transaction
rollback;----ROLLBACK: A failure occurred during a transaction cloud, the transaction cannot continue, and the system revokes all completed operations on the data in the transaction, rolling back to the state at the beginning of the transaction.
ACID Properties of transactions
Atomicity: atomicity
A transaction is a logical unit of work for a database, and operations included in a transaction are either done or not
Consistency: Consistency
The result of a transaction must be to make the database transition from one consistent state to another.
When the database contains only the results of a successful transaction submission, the database is in a consistent state. If a database system fails in operation and some transactions have not yet been completed, some of the modifications made to the data by these outstanding transactions have been written to the physical database, when the database is in an incorrect state or in an inconsistent state.
A business in a bank, a person who transfers from a account to a B account can be defined as a transaction, including two operations: an operation to withdraw 10000 yuan from a account, an operation to add $10000 to the B account. These two operations are either full, or do not do, so that the database will remain consistent, if only one operation, the logic of fire operations, reduce or increase 1000 yuan.
Isolation: Isolation
The execution of one transaction cannot be interfered with by other transactions, the internal operation of a transaction and the data used are isolated to other transactional transactions and cannot interfere with each other concurrently.
Persistent permanence
Once a transaction is committed, the changes to the data in the database are permanent. The next operation or failure should not have any effect on its execution results.
Database-Database transactions