Transaction is the basic unit of concurrency control. A transaction is a sequence of operations. These operations are either executed or not executed. It is an inseparable unit of work. For example, for bank transfer: If you deduct money from one account and add money to another account, either or both of these operations are executed. Database transactions must have
Transaction is the basic unit of concurrency control. A transaction is a sequence of operations. These operations are either executed or not executed. It is an inseparable unit of work. For example, for bank transfer: If you deduct money from one account and add money to another account, either or both of these operations are executed. Database transactions must have
Transaction is the basic unit of concurrency control.
A transaction is a sequence of operations. These operations are either executed or not executed. It is an inseparable unit of work. For example, for bank transfer: If you deduct money from one account and add money to another account, either or both of these operations are executed.
Database transactions must have ACID properties. ACID is the abbreviation of Atomic (Atomicity), Consistency (Consistency), Isolation (Isolation), and Durability (Durability.
Atomicity: indicates that the entire database transaction is an inseparable unit of work. The transaction is successful only when all operations in the database are successfully executed. If any SQL statement in the transaction fails to be executed, the successfully executed SQL statement must also be revoked, the database status should be returned to the status before the transaction is executed.
Consistency: database transactions cannot undermine the integrity of relational data and business logic consistency. For example, for a bank transfer transaction, whether the transaction succeeds or fails, you should ensure that the total deposits of Tom and Jack in the ACCOUNTS table after the transaction ends is 2000 yuan.
Isolation: In a concurrent environment, when different transactions manipulate the same data at the same time, each transaction has its own complete data space. Modifications made by a concurrent firm must be isolated from those made by any other concurrent firm. When a transaction views data updates, the status of the data is either the status before another transaction modifies it, or the status after another transaction modifies it,Transactions do not view data in the intermediate state..
Persistence: the update made to the database must be permanently saved as long as the transaction ends successfully. Even if the system crashes, after the database system is restarted, the database can be restored to the State at the end of the transaction.
The ACID feature of transactions is implemented by relational database management systems (RDBMS. Database Management System collectionUse logs to ensure the atomicity, consistency, and durability of transactions. The log records the updates made by the transaction to the database. If an error occurs during the execution of a transaction, you can cancel the updates made to the database by the transaction according to the log, returns the database to the initial state before the transaction is executed.
Database Management SystemUse locks to isolate transactions. When multiple transactions update the same data in the database at the same time, only the transaction holding the lock can update the data. Other transactions must wait until the lock is released for the previous transaction, other transactions have the opportunity to update the data.
Source: http://www.cnblogs.com/younes/archive/2010/09/09/1822436.html