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

Mysql transaction processing (transfer)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Mysql transaction (to) [@ more@] by default, MySQL runs in autocommit mode. This means that when you finish performing an update, MySQL will immediately store the update on disk.

If you use transaction safety tables (such as InnoDB, BDB), you can set MySQL to non-autocommit mode with the following command:

SET AUTOCOMMIT=0

After that, you must use COMMIT to store your changes to disk, or use ROLLBACK if you want to ignore changes made since your transaction.

If you want to convert from AUTOCOMMIT mode for a series of statements, you can use START TRANSACTION or BEGIN or BEGIN WORK statements:

START TRANSACTION

SELECT @ A:=SUM (salary) FROM table1 WHERE type=1

UPDATE table2 SET summmary=@A WHERE type=1

COMMIT

START TRANSACTION was added in MySQL 4.0.11; this is the recommended way to start a special (ad-hoc) transaction because it is ANSI SQL syntax.

Note that if you are using a non-transactional security table, the changes are stored immediately and are not constrained by the state of the autocommit mode.

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

Database

Wechat

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

12
Report