You can also end a transaction without committing the changes with the ROLLBACK command. The result is that the database state is rolled back to how it was before you issued the START TRANSACTION command.
The following example shows how you can recover from a disastrously wrong DELETE statementremember to always include the WHERE clauseif it occurs within a transaction:
mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec)
mysql> DELETE FROM products; Query OK, 3 rows affected (0.03 sec)
mysql> ROLLBACK; Query OK, 0 rows affected (0.01 sec)
If you then query the products table, you will see that it still contains records.