Introduction of transaction control statements in MySQL 5.7s
A START TRANSACTION or BEGIN statement starts a transaction
The COMMIT statement commits the transaction so that the changes to the data take effect permanently
The ROLLBACK statement rolls back the transaction and cancels changes to the data
The SET autocommit statement disables or enables the default transaction auto-commit feature for the current session
-- example
Mysql > START TRANSACTION
Query OK, 0 rows affected (0.00 sec)
Mysql > SELECT @ A:=SUM (deptno) FROM test
+-+
| | @ A:=SUM (deptno) |
+-+
| | 150 |
+-+
1 row in set (0.00 sec)
Mysql > UPDATE test SET deptno=@A WHERE deptno=10
Query OK, 1 row affected (0.05sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql > commit
Query OK, 0 rows affected (0.01 sec)
-- turn off the auto-commit function of the current session transaction
Mysql > SET autocommit=0
Query OK, 0 rows affected (0.00 sec)
Mysql > show variables like'% commit%'
+-+ +
| | Variable_name | Value |
+-+ +
| | autocommit | OFF |
| | innodb_commit_concurrency | 0 | |
| | innodb_flush_log_at_trx_commit | 1 | |
+-+ +
3 rows in set (0.00 sec)