Issue a BEGIN statement to suspend auto-commit mode, then issue the queries that make up the transaction.
mysql>
mysql> CREATE TABLE t (i INT) TYPE = InnoDB;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO t (i) VALUES(1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO t (i) VALUES(2);
Query OK, 1 row affected (0.00 sec)
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM t;
+------+
| i |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
mysql>
mysql> drop table t;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category