Home > Database > Mysql Tutorial > How does MySQL manage the behavior of transactions?

How does MySQL manage the behavior of transactions?

WBOY
Release: 2023-08-22 20:45:14
forward
1240 people have browsed it

How does MySQL manage the behavior of transactions?

MySQL can manage transaction behavior through the following two modes:

Auto-commit on

This is the default mode. In this mode, each MySQL statement (whether within a transaction or not) is treated as a complete transaction and is committed by default when completed. It can be started by setting the session variable AUTOCOMMIT to 1, as follows:

SET AUTOCOMMIT = 1
mysql> SET AUTOCOMMIT = 1;
Query OK, 0 rows affected (0.07 sec)
Copy after login

Turn off autocommit

This is not the default mode. In this mode, the subsequent series of MySQL statements are processed like a transaction, and no activity is committed until an explicit COMMIT statement is issued. It can be started by setting the session variable AUTOCOMMIT to 0 as shown below −

SET AUTOCOMMIT = 0
mysql> SET AUTOCOMMIT = 0;
Query OK, 0 rows affected (0.00 sec)
Copy after login

The above is the detailed content of How does MySQL manage the behavior of transactions?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template