描述
回滚(ROLLBACK)事务操作:
表示事务已经结束;
回滚所有事务操作;
释放事务锁。
示例
START TRANSACTION;
Query OK, 0 rows affected (0.00 sec)
SELECT * FROM EMPSALARY WHERE ename='scott';
+-------+-------+------+
| ename | empno | sal |
+-------+-------+------+
| SCOTT | 7788 | 5000 |
+-------+-------+------+
1 row in set (0.00 sec)
UPDATE empsalary SET sal=5500 WHERE ename='scott';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM EMPSALARY WHERE ename='scott';
+-------+-------+------+
| ename | empno | sal |
+-------+-------+------+
| SCOTT | 7788 | 5500 |
+-------+-------+------+
1 row in set (0.00 sec)
ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
SELECT * FROM EMPSALARY WHERE ename='scott';
+-------+-------+------+
| ename | empno | sal |
+-------+-------+------+
| SCOTT | 7788 | 5000 |
+-------+-------+------+
1 row in set (0.00 sec)