In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Let me tell you a little bit about the main functions of MySQL transactions. Have you learned about similar topics before? If you are interested, let's take a look at this article. I believe it will be of some help to you after reading the main functions of MySQL transactions.
MySQL transaction function 1. Brief introduction of affairs
A transaction is a continuous set of database operations as if it were a single unit of work. In other words, it will never be a complete transaction unless each individual operation within the group is successful. If any operation in the transaction fails, the entire transaction will fail.
two。 Transaction atomicity: in transaction manipulation, either all or no consistency is performed: in a transaction, data is guaranteed to change from one consistent state to another: each transaction does not interfere with each other. the execution together can also be persistent: after the transaction is committed, the impact of the data is permanent. Transactions use (1) autocommit mysql > set autocommit=1; / / enable transaction autocommit, set autocommit=0 forbids autocommit (2) manually commit mysql > begin; / / transaction start statement mysql > SQL statement; / / execute SQL statement mysql > rollback; / / rollback transaction mysql > commit; / / commit transaction
Note: rollback can only roll back the manipulation before the current transaction is committed, and all current transactions are invalidated if they are successfully committed.
(3) automatic rollback case after begin manually exits the database (such as Ctrl+C, quit, exit) the CVM is powered off (4) example: transfer
1. Transfer 1000 to the other party, the account number is incorrect
two。 Enter the transferred amount
3. Submit confirmation
Begin
Create database hehe
Create table hehe.a (number int,user char (4), menony int (4))
Insert into hehe.a values ('1century, last month, month, week, week, month, week, week, week
Insert into hehe.a values ('2 years, months, weeks, months, weeks, days, weeks, days, years, months, years, months, years, and years.)
Commit; / / normal submission
Transaction operation
Begin; / / start
Update hehe.a set menony='0' where user='a'
Rollback; / / rollback operation
Begin
Update hehe.a set menony='0' where user='a'
Update hehe.a set menony='1010' where user='b'
Commit; / / submit
Rollback; / / cannot be undone because the system has been submitted
What do you think of the main functions of MySQL transactions? what do you think of this article and whether it has gained anything? If you want to know more about it, you can continue to follow our industry information section.
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.