Characteristics of database Transactions acid

Source: Internet
Author: User

A transaction (Transaction) is the basic unit of concurrency control.

The so-called transaction, which is a sequence of operations that are either executed or not executed, is an inseparable unit of work. For example, bank transfers work: Debit from one account and add another account, both of which are either executed or not executed.

Database transactions must have acid characteristics, and acid is an abbreviation for atomic (atomicity), consistency (consistency), isolation (isolation), and durability (persistence).

Atomicity: Refers to the entire database transaction is an inseparable unit of work. The entire transaction succeeds only if all operations in the library are successful, and any SQL statement execution fails in the transaction, the SQL statement that has executed successfully must also be revoked, and the state of the database should be returned to the state before the transaction was executed.

Consistency: The database transaction does not break the integrity of the relational data and the consistency of the business logic. For example, for a bank transfer transaction, whether the transaction succeeds or fails, it should be ensured that the total deposit of Tom and Jack in the accounts table after the transaction ends is $2000.

Isolation: In a concurrency environment, when different transactions manipulate the same data at the same time, each transaction has its own full data space. Modifications made by a concurrent transaction must be isolated from modifications made by any other concurrent transaction. When a transaction views the data update, the data is in the state it was in before the other transaction modifies it, or the state after the other transaction modifies it, and the transaction does not view the data in the middle State .

Persistence: The update that it makes to the database must be persisted as long as the transaction completes successfully. Even if a system crash occurs, the database can be restored to the state at the end of the transaction when the database system is restarted.

The (ACID) nature of a transaction is implemented by a relational database management system (RDBMS, database System). The database management system uses logs to ensure the atomicity, consistency, and durability of transactions . The log records the updates that the transaction makes to the database, and if a transaction has an error during execution, it can undo the updates that the transaction has made to the database based on the log, returning the database to the initial state before the transaction was executed.

The database management system adopts the lock mechanism to realize the isolation of the transaction . When multiple transactions update the same data in the database at the same time, only transactions that hold the lock are allowed to update the data, and other transactions must wait until the previous transaction releases the lock, and other transactions have the opportunity to update the data.

Characteristics of database Transactions acid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.