MySQL control (turn off, turn on) auto-submit feature

Source: Internet
Author: User

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

    1. SET autocommit=0;

Set the auto-commit feature to OFF

    1. 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.

    1. Mysql> SET autocommit=0;
    2. Query OK, 0 rows Affected (0.00 sec)

View data in the table user

    1. Mysql> SELECT * from user \g
    2. 1. Row **************
    3. Mid:1
    4. Name:zhangsan
    5. scx:0
    6. Word:null
    7. 2. Row **************
    8. Mid:2
    9. Name:wangwu
    10. Scx:1
    11. Word:null
    12. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.