Database transaction acid Characteristics __ Database

Source: Internet
Author: User
ACID Properties

The four characteristics of transactions (transaction) in the database management system (interpreted according to the initials): atomicity ( atomicity), consistency (consistency), isolation (isolation), Persistence (Durability)

The so-called transaction, it is a sequence of operations, these operations are either executed, or not executed, it is an indivisible unit of work . (a set of instructions or operations that perform a single logical function is called a transaction) detailed 1. atomicity

Atomicity means that a transaction is an indivisible unit of work , and that the operations in the transaction either occur or do not occur.

The example of "A to B transfer " can be used to illustrate the explanation

In the DBMS, a single SQL is a separate transaction by default, and the transaction is committed automatically . Only an explicit use of the start transaction opens a transaction to put a block of code into execution in a transaction. 2. Consistency

Consistency means that the integrity constraints of a database are not compromised until the transaction is started and after the transaction has ended . This is to say that database transactions cannot break the integrity of relational data and the consistency of business logic .

If a transfer to B, regardless of the success of the transaction operation, the total amount of their deposits unchanged (this is the consistency of the business logic, as to the integrity of the database relationship constraints to better understand).

Safeguard mechanism (also from two aspects): The database level will be in a transaction before and after the data will meet the constraints you set ( unique constraints, FOREIGN KEY constraints, check constraints , etc.) and trigger settings; The internal data structures of the database, such as the B-tree index or the two-way list, must be correct. Business consistency is generally guaranteed by developers and can be transferred to the database level. 3. Isolation

when multiple transactions are accessed concurrently, transactions are isolated and one transaction should not affect the effect of other transactions.

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 concurrent transactions must be isolated from modifications made by any other concurrent transaction. When a transaction views a data update, the state of the data is either the state before which it was modified by another transaction, or the state after which it was modified by another transaction, and the transaction does not see the data in the middle State .

The most complex problems of a transaction are caused by transactional isolation. Complete isolation is unrealistic, and complete isolation requires that the database perform only one transaction at a time, which can severely affect performance.

For transaction isolation levels in isolation (impact between transactions), see corresponding blog 4. Persistence

This is a feature that is best understood: persistence, meaning that changes made to the database by the firm after the transaction is completed are persisted in the database and are not rolled back. (the completed transaction is a permanent part of the system, and the impact on the system is permanent, and the modification is maintained even if a fatal system failure occurs)

write ahead Logging : Wal (Write-ahead logging) technology is used in SQL Server to guarantee the ACID properties of the transaction log, written to the log before data is written to the database. The log record is then changed to memory.

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.