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

Case Analysis of MySQL transaction

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this "MySQL transaction case Analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "MySQL transaction case Analysis" article.

MySQL transactions are mainly used to deal with data with large amount of operations and high complexity. For example, in the personnel management system, if you delete a person, you need to delete not only the basic information of the person, but also the information related to that person, such as mailboxes, articles, etc., so that these database operation statements constitute a transaction.

Mode 1

START TRANSACTION or BEGIN start a new transaction COMMIT commit the current transaction ROLLBACK roll back the current transaction

This is a well-known way to start a transaction in the same way as start transaction and begin.

Mode 2

SET autocommit = 0

By default, autocommit = 1, which commits the transaction automatically. Autommit is session-level, which means that the current connection has changed the autocommit and has no effect on other connections. After autocommit is set, all sql for this connection is in the form of transactions, such as each commit commit.

From the screenshot, you can see that there is a transaction executing, because set autocommit = 0 position is set, so the result of the later update operation modification will not be found by other session (RR level).

At this point, you need to manually execute the commit yourself.

Note that the autocommit has not been changed, and the autocommit value is still 0, which means that the subsequent sql of the session needs to be manually commit.

The above is about the content of this article "MySQL transaction case Analysis". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

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

Development

Wechat

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

12
Report