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

How does MySQL manage the behavior of transactions?

WBOY
WBOYforward
2023-08-22 20:45:141287browse

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)

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete