In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces whether there is any transaction in mysql, it has certain reference value, friends who need it can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
There are transactions in mysql, but only databases or tables that use the Innodb database engine support transactions. Transaction processing can be used to maintain the integrity of the database, it submits or revokes operation requests to the system as a whole, that is, this set of database commands are either executed or not executed.
Database transaction (Transaction) is a mechanism, an operation sequence, which contains a set of database operation commands. The transaction submits or cancels the operation request to the system as a whole, that is, this set of database commands are either executed or not executed, so the transaction is an indivisible logical unit of work.
When performing concurrent operations on a database system, transactions are used as the smallest control unit, which is especially suitable for database systems where multiple users operate at the same time. For example, airline booking systems, banks, insurance companies and securities trading systems.
In MySQL, only databases or tables that use the Innodb database engine support transactions.
Transactions can be used to maintain the integrity of the database, ensuring that batches of SQL statements are either executed or not executed.
Transactions are used to manage insert,update,delete statements
Transactions have four characteristics, namely, Atomicity, Consistency, Isolation, and Durability, which are usually referred to as ACID.
1. Atomicity
A transaction is a complete operation. The elements of a transaction are indivisible (atomic). All elements in the transaction must be committed or rolled back as a whole. If any element in the transaction fails, the entire transaction will fail.
In the case of a bank transfer transaction, if the transaction is committed, the data for these two accounts will be updated. If, for some reason, the transaction terminates before the two accounts are successfully updated, the balance of the two accounts will not be updated, any changes to the account balance will be undone, and the transaction cannot be partially committed.
two。 Consistency
When the transaction completes, the data must be in a consistent state. That is, the data stored in the database is in a consistent state before the transaction begins. In the course of an ongoing transaction. The data may be in an inconsistent state, for example, some of the data may be modified. However, when the transaction completes successfully, the data must return to its known consistent state again. Changes made to the data through the transaction cannot damage the data, or the transaction cannot make the data storage unstable.
Take bank transfer affairs as an example. The total balance of all accounts is in a consistent state before the transaction begins. In the course of the transaction, the balance of one account has been reduced, while the balance of the other has not been modified. As a result, the total amount of all account balances is inconsistent. After the transaction is completed, the total balance of the account returns to a consistent state again.
3. Isolation
All concurrent transactions that modify data are isolated from each other, indicating that transactions must be independent and should not depend on or affect other transactions in any way. A transaction that modifies data can access the data before another transaction that uses the same data starts, or after another transaction that uses the same data ends.
In addition, when a transaction modifies data, if any other process is using the same data at the same time, the modification to the data will not take effect until the transaction is successfully committed. The transfer between Zhang San and Li Si and between Wang Wu and Zhao er will always be independent of each other.
4. Persistence
The persistence of a transaction means that the result of a transaction is permanent regardless of whether the system fails or not.
After a transaction completes successfully, the changes it makes to the database are permanent, even if the system fails. That is, once the transaction is committed, any changes made by the transaction to the data are permanently retained in the database.
The ACID principle of a transaction ensures that a transaction must be either a successful commit or a failed rollback. Therefore, its modifications to the transaction are recoverable. That is, when a transaction fails, its modifications to the data will return to the state it was before the transaction was executed.
Thank you for reading this article carefully. I hope the editor will share any business in mysql to help you. At the same time, I also hope you will support us, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!
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.