MySQL Commit and Rollback

MySQL Commit and Rollback:

(1) The COMMIT Statement commits changes to the database, and the ROLLBACK Statement undoes any changes made by the statement and returns the database to the state it was in when the transaction began.

(2) In MySQL, on the top click on the Edit button and then select Preferences.

Open MySQL Preferences

(3) Under SQL Execution, Untick “New connections use auto commit mode” and then click ok. After that close MySQL Workbench and then again open it so that necessary changes should take place. We disable the auto commit so that we can check the Rollback query in MySQL.

Untick new connection use auto commit mode

Sample Table:

MySQL Commit and Rollback sample table

(4) Example of MySQL COMMIT: Written content in the below image shows how you have to run a query.

MySQL Commit Codeunit

(5) Example of MySQL ROLLBACK: For running the query same procedure is followed as shown in the above image.

MySQL Rollback codeunit

(6) Below Image shows an example of No ROLLBACK:

no rollback mysql codeunit

(7) Now we use DELETE Command as shown below.

Commit use with delete command in Mysql

In the above image, if we use ROLLBACK after that the deleted id will reappear but if we use COMMIT then ROLLBACK does not work as shown below.




No Rollabck MySQL Query

Install MySQL on Windows
Create a Database in MySQL
Create Table in MySQL
MySQL Logical Operators
MySQL Limit and Offset Clause
MySQL Order By and Distinct Clause
MySQL– Wikipedia

Comments (No)

Leave a Reply