Database transaction (Database Transaction)

1. Transaction

(1) transaction (transaction database, Database Transaction) is a logical unit of execution of a database management system, consisting of a limited operation sequence data.

(2) a transaction database typically contains a sequence of database read / write operations. There is a transaction generally involves the following two purposes:

         1> provides a method to recover from a failure state to a normal sequence of operations for the database, the database also provides a method for maintaining coherency even if still in an abnormal state.

         2> When a plurality of applications for concurrent access to the database may be provided a method of isolation among these applications, in order to prevent interference between the operation of each other.

When a transaction is submitted to the DBMS ( database management system ), the DBMS ( database management system ) need to ensure that all operations of the transaction are successfully completed and the results are stored permanently in the database, if the transaction in any operation is not completed successfully, all operations in the transaction needs to be rolled back , back to the state before the transaction execution; at the same time, the implementation of the transaction has no effect on the database or other transaction, all transactions are as if in a separate operation.

But in reality, a high risk of failure. During the execution of a transaction in the database, it is possible to encounter a transaction fails, the database system / operating system failure, or even a case of storage media failure and so on. This requires a DBMS transaction fails to perform the restore operation, the database will restore its state to a consistent state (data consistency guaranteed state). In order to achieve the state to restore the database to a consistent state functions, DBMS usually need to maintain a transaction log to a database of all transaction data to track the impact of the operation.

(. 3) the ACID properties

   The sequence of operations of the database is a database transaction is not appointed. Database transaction has the following four characteristics, customarily referred to as the ACID properties.

        Atomicity (Atomicity) : the transaction is performed as a whole, in the operation of the database contained therein either all executed or none are executed.

        Consistency (Consistency) : Services should ensure that the state of the database from one consistent state to another consistent state. Meaning consistent state of data in the database should meet the integrity constraints.

        Isolation (Isolation) : concurrent execution of multiple transactions, executing a transaction does not affect the execution of other transactions.

        Persistent (Durability Rev) : transaction has been submitted modifications to the database should always be kept in the database.

Guess you like

Origin www.cnblogs.com/jycx/p/11004767.html