Transaction Processing on MySql
- Supported only for INNODB tables!
- By default, each mysql statement is automatically committed, i.e. made a permanent part of the database. There are two ways to change this default behavior in MySql:
- You can turn this behavior off by SET AUTOCOMMIT = 0. Note: That is a zero.
- If autocommit is off, all changes have to be explicitly committed, using the commit command. Only then do the changes become a permanent part of the database.
- Issuing a rollback command, instead of a commit, undoes all the changes made to the database since the previous commit.
- Or, you can leave AUTOCOMMIT unchanged, and issue a START TRANSACTION command, which starts a transaction.
- All changes made to the database during the transaction are tentative and can either be:
- undone with the rollback command.
- or made permanent with the commit command.
- Either of those commands ends the transaction