In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article shares information about the characteristics of database transactions. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
The four characteristics of database transactions are: 1, atomicity, transactions are the logical unit of work of the database, the operations in the transaction are either all done or not done;2, consistency, a transaction must be in a consistent state before and after execution;3, isolation;4, persistence, once a transaction is committed, his changes to the data in the database should be permanent.
If a database claims to support transactional operations, then the database must have the following four characteristics:
Atomicity (Atomicity)
Atomicity means that all operations contained in a transaction either succeed or fail to roll back. This is the same concept as the function of transactions introduced in the previous two blogs. Therefore, if the operation of a transaction succeeds, it must be fully applied to the database. If the operation fails, it cannot have any impact on the database.
Consistency (Consistency)
Consistency means that a transaction must transform the database from one consistent state to another, that is, a transaction must be in a consistent state before and after execution.
For example, if the money of user A and user B adds up to 5000, then no matter how the transfer between A and B is made and how many times the account is transferred, the money of the two users should add up to 5000 after the transaction is over. This is the consistency of the transaction.
3. Isolation
Isolation refers to when multiple users access the database concurrently, such as operating the same table, the transactions opened by the database for each user cannot be interfered by the operations of other transactions, and multiple concurrent transactions should be isolated from each other.
That is, the effect is that for any two concurrent transactions T1 and T2, T2 either ends before T1 begins, or begins after T1 ends, in the view of transaction T1, so that each transaction does not perceive that any other transaction is executing concurrently.
A database provides multiple levels of isolation about transactions, as described later.
Durability (Durability)
Persistence means that once a transaction is committed, changes to the data in the database are permanent, and the committed transaction is not lost even if the database system encounters a failure.
For example, when we use JDBC to operate the database, after submitting the transaction method, prompt the user that the transaction operation is completed. When our program is executed until we see the prompt, we can determine that the transaction is submitted correctly. Even if there is a problem with the database at this time, we must complete the execution of our transaction completely. Otherwise, we will see a major error indicating that the transaction is completed, but the database has not executed the transaction because of failure.
Thank you for reading! What characteristics of database transactions are shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge. If you think the article is good, you can share it so that more people can see it!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.