Mysql commit and rollback, savapoint_MySQL

Source: Internet
Author: User
Mysql commit, rollback, and savapoint attack path-


After installing mysql

Set autocommit = true;

The SQL statement cannot be rolled back every time it is executed.

Now we want to test commit

We can

Use test;

(Use the test database)


Set autocommit = false;

If you do not execute


Data is stored in the memory at most and will not be written to the database.

Once we commit; then the database will be submitted to the database.

Of course

Before commit, we can rollback; before returning to the database to commit

However, this rollback is equivalent to rolling back all of your previous operations, which means that the previous operations are useless.

So we usually get an archive at the point we want to save, just like the Restore Point in windows.

For example, after I finish this SQL statement


Savepoint p1;
Restore point p1 is created;

Then, execute the next SQL statement to delete


I executed

Rollback to t1;

In this way, you can return to the archiving point of t1, just like playing a game! Unhappy with the previous progress

Of course, after you execute commit!

You cannot implement rollback! REMEMBER !!!!!!!!!!!!!

As a Cainiao!

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