Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the terms of the ACID feature of the database

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "what are the ACID feature terms of the database". In the daily operation, I believe that many people have doubts about the ACID feature terms of the database. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "what are the ACID feature terms of the database?" Next, please follow the editor to study!

ACID is: Atomicity, Consistency, Isolation, and Durabilily.

1. Atomicity

Atomic attributes are used to identify whether the transaction is completed completely, any update of a transaction is to be completed on the system, and if something goes wrong and the transaction cannot complete all its tasks, the system will return to the state before the transaction started.

Let's take another look at the example of bank transfer. If an error occurs during the transfer, the entire transaction will be rolled back. Only when all parts of the transaction are executed successfully, the transaction is written to disk and the change is made permanent.

To provide the ability to roll back or uncommit uncommitted changes, many data sources use logging mechanisms. For example, SQL Server uses a prewritten transaction log that is written to the transaction log before applying (or committing) the data to the actual data page. However, some other data sources are not relational database management systems (RDBMS), and they manage uncommitted transactions in a completely different way. This technique should be used to manage transactions as long as the data source can undo all uncommitted changes when the transaction is rolled back.

two。 Consistency

Transactions implement consistency in system integrity, which is achieved by ensuring that any transaction of the system ends up in a valid state. If the transaction completes successfully, all changes in the system will be applied correctly and the system will be in a valid state. If an error occurs in the transaction, all changes in the system are automatically rolled back and the system returns to its original state. Because the transaction is open

At the beginning, the system is in a consistent state, so now the system is still in a consistent state.

Let's go back to the example of a bank transfer, where the account is in a valid state before the account is converted and the funds are transferred. If the transaction completes successfully and the transaction is committed, the account is in a new valid state. If the transaction goes wrong, the account returns to its previous valid state after termination.

Remember, the transaction is not responsible for implementing data integrity, but only for ensuring that the data returns to a consistent state after the transaction commits or terminates. The task of understanding data integrity rules and writing code to achieve integrity usually falls on developers, who design according to business requirements.

When many users use and modify the same data at the same time, transactions must maintain the integrity and consistency of their data. So we take a closer look at the next feature in the A C I D feature: isolation.

3. Isolation

Transactions are executed in an isolated state so that they appear to be the only operations performed by the system at a given time. If there are two transactions that run at the same time and perform the same function, the isolation of the transaction ensures that each transaction is thought to be the only transaction in the system that is using the system.

This attribute is sometimes called serialization, and to prevent confusion between transaction operations, requests must be serialized or serialized so that only one request is used for the same data at a time.

It is important that when a transaction is executed in an isolated state, the state of the system may be inconsistent, and ensure that the system is in a consistent state before ending the transaction. However, in each individual transaction, the state of the system may change. If the transaction is not running in isolation, it may access data from the system, and the system may be in an inconsistent state. By providing things.

Isolation can prevent this kind of incident from happening.

In the case of the bank, this means that in this system, other processes and transactions do not see any changes caused by our transactions until our transactions are completed, which is important in the case of termination. If there is another process that processes the account balance accordingly, and it can see the change caused by it before our transaction is completed, then the decision of this process may

Based on the wrong data, because our transaction may be terminated. This explains why the changes made by the transaction are not visible to the rest of the system until the transaction is completed.

Isolation not only ensures that multiple transactions cannot modify the same data at the same time, but also ensures that the changes generated by transaction operations are not visible to another transaction until the changes are committed or terminated, and that concurrent transactions have no effect on each other. This means that all data that needs to be modified or read is locked in the transaction and cannot be released until the transaction is completed. Most databases, such as SQL Server and other RDBMS, are isolated by using locking, and individual data items or datasets involved in a transaction use locking to prevent concurrent access.

4. Persistence

Persistence means that once the transaction executes successfully, all changes in the system will be permanent. There should be some checkpoints to prevent the loss of information if the system fails. Even if the hardware itself fails, the state of the system can still be rebuilt by recording the tasks completed by the transaction in the log. The concept of persistence allows developers to think that completed transactions are a permanent part of the system no matter what happens later in the system.

At this point, the study of "what are the terms of the ACID features of the database" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report