MySQL can manage the behavior of a transaction with the help of the following two modes −
Autocommit On
It is the default mode. In this mode, each MySQL statement (within a transaction or not) is considered as a complete transaction and committed by default when it finishes. 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)
Autocommit Off
It is not the default mode. In this mode, the subsequent series of MySQL statements act like a transaction, and no activities are committed until an explicit COMMIT statement is issued. It can be started by setting the session variable AUTOCOMMIT to 0 as follows −
SET AUTOCOMMIT = 0 mysql> SET AUTOCOMMIT = 0; Query OK, 0 rows affected (0.00 sec)