When a command is executed in MySQL, it is usually directly determined to commit. This means that the user does not have to be aware of the matter, and all commands will be automatically commit. In particular, when the storage engine is MyISAM, it does not support transactional processing, and as long as the command is executed, all command departments are committed.
The default auto-commit feature is called autocommit. The auto-commit feature is set to on state by default. However, if the storage engine is InnoDB, when the start transaction or BEGIN command (MySQL transaction-delete rollback) is executed, it will not be automatically committed and will not be committed until the commit command is explicitly executed. Before this, you can perform the rollback command to roll back the update operation.
The user can force the Auto-submit feature to OFF. This way, the user executes the SQL statement and will not be committed, but executes the commit command before committing, executing the rollback command back to the soil.
The following is the specific syntax for resetting the auto-commit feature to on and off.
Set the auto-commit function to ON
- SET autocommit=0;
Set the auto-commit feature to OFF
- SET autocommit=1;
We will show what kind of changes will occur after the auto-submit feature is set to OFF. Set to OFF, we insert a piece of data into the table user and see if we can roll it back.
Set the auto-commit feature to off, and the result is as follows.
- Mysql> SET autocommit=0;
- Query OK, 0 rows Affected (0.00 sec)
View data in the table user
- Mysql> SELECT * from user \g
- 1. Row **************
- Mid:1
- Name:zhangsan
- scx:0
- Word:null
- 2. Row **************
- Mid:2
- Name:wangwu
- Scx:1
- Word:null
- 2 rows in Set (0.00 sec)
MySQL control (off, on) auto-submit feature (2)
Article source page Programming http://www.uphtm.com, reprint please specify Source: http://www.uphtm.com/database/188.html
MySQL control (turn off, turn on) auto-submit feature