MySQL (22): Transaction Management transaction Rollback

Source: Internet
Author: User

1. When working on a transaction, if it is found that the current transaction operation is unreasonable, as long as the transaction has not been committed, it can be rolled back to cancel the current transaction, followed by a detailed explanation of the transaction's rollback.

2. In order to demonstrate the rollback operation, on the basis of the previous note case, at this time a account has 1000 yuan, B account also has 1000 yuan, open a transaction, through the UPDATE statement to the a account of 100 yuan to the B account, the specific statement, as follows:

StartTransaction;UpdateAccountSet  Money= Money- - whereName='a';UpdateAccountSet  Money= Money+ - whereName='b';

After successful execution of the above statement, use the SELECT statement to query A and B accounts, as follows:

At this point a account if do not want to transfer the B account, because the transaction has not yet committed, or can be rolled back, as follows:

MySQL (22): Transaction Management transaction Rollback

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.