标签:save nod 语句 com 导致 数据 修改 rom value
mysql> create table user(id int(8)); # 创建测试表
Query OK, 0 rows affected (0.03 sec)
mysql> select * from user;
Empty set (0.00 sec)
mysql> begin; # 开启事务
Query OK, 0 rows affected (0.00 sec)
mysql> insert into user values(6); # 插入数据
Query OK, 1 row affected (0.00 sec)
mysql> select * from user;
+------+
| id |
+------+
| 6 |
+------+
1 row in set (0.00 sec)
mysql> rollback; # 回滚, 并结束事务
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user; # 事务开启的后插入的数据已经不存在
Empty set (0.00 sec)
mysql> begin; # 开启事务
Query OK, 0 rows affected (0.00 sec)
mysql> insert into user values(7);
Query OK, 1 row affected (0.00 sec)
mysql> commit; # 提交并结束事务
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user;
+------+
| id |
+------+
| 7 |
+------+
1 row in set (0.00 sec)
mysql> rollback; # 尝试回滚
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user; # 回滚失败,数据已经提交
+------+
| id |
+------+
| 7 |
+------+
1 row in set (0.00 sec)
-----------------------------------
mysql> select * from user;
+------+
| id |
+------+
| 7 |
+------+
1 row in set (0.00 sec)
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into user values(8);
Query OK, 1 row affected (0.00 sec)
mysql> select * from user;
+------+
| id |
+------+
| 7 |
| 8 |
+------+
2 rows in set (0.00 sec)
mysql> savepoint test; # 设置保存点
Query OK, 0 rows affected (0.00 sec)
mysql> insert into user values(9);
Query OK, 1 row affected (0.00 sec)
mysql> select * from user;
+------+
| id |
+------+
| 7 |
| 8 |
| 9 |
+------+
3 rows in set (0.00 sec)
mysql> rollback to test; # 回滚到保存点,但事务并没有结束
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user; # 回滚成功
+------+
| id |
+------+
| 7 |
| 8 |
+------+
2 rows in set (0.00 sec)
标签:save nod 语句 com 导致 数据 修改 rom value
原文地址:https://www.cnblogs.com/ivy-blogs/p/11764031.html