How to create a transaction in MySQL
Answer:
A simple transaction in MySQL looks like the following:
mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO my_table VALUES (1, 2, 3);
Query OK, 1 row affected (0.02 sec)
mysql> ROLLBACK;
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO my_table VALUES (4, 5, 6);
Query OK, 1 row affected (0.01 sec)
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)
At the end of the queries, the row (4, 5, 6) was inserted into the table, but not (1, 2, 3).