In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following mainly brings you the two main methods of MYSQL transaction processing. I hope these contents can bring you practical use, which is also the main purpose of this article. All right, don't talk too much nonsense, let's just read the following.
There are three points to pay attention to when using transactions:
1. Only databases or tables that use the Innodb database engine in MySQL support transactions.
2. Transaction processing can be used to maintain the integrity of the database and ensure that batches of SQL statements are either executed or not executed.
3. Transactions are used to manage insert,update,delete statements
There are two main methods of MYSQL transaction processing:
1. Implement it with BEGIN, ROLLBACK and COMMIT.
BEGIN starts a transaction
ROLLBACK transaction rollback
COMMIT transaction confirmation
2. Directly use SET to change the automatic submission mode of MySQL:
SET AUTOCOMMIT=0 forbids automatic submission
SET AUTOCOMMIT=1 enables auto-submission
For example:
SET AUTOCOMMIT = 0 asdjoi213hjsh',' COMMIT insert INTO km_xtyh (YHID,YHMC) VALUE ('asdjoi213hjsh',' Li Si')
Interpretation:
First, auto commit is turned off, and then the transaction is opened with "BEGIN". After that, although the insert statement is used, there is no "COMMIT" operation and no real submission. The data is only temporarily stored in the database (note: at this time, there is already a "Li Si" data in the database). If the "COMMIT" statement is executed, the data will be permanently inserted into the database.
If you do not execute "COMMIT" and execute another statement "ROLLBACK", the record will not exist in the database and the data will not be inserted successfully.
For the above two main methods of MYSQL transaction processing, do you think it is very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like 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.