MySQL can manage transaction behavior through the following two modes:
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)
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!