为保证业务的完整性,当一条语句出现错误,则此步骤全部回退
### 终端一
begin; 开启
insert into students (sname) value ("sss");
commit; 只有commit才表示执行成功
### 终端二
mysql> select * from students;
+----+-------+
| id | sname |
+----+-------+
| 1 | Gage |
| 2 | sss |
+----+-------+
### 终端一
begin; 开启
insert into students (sname) value ("sss");
rollback; 人为异常,事务回退
insert into students (sname) value ("kksk"); 测试语句
### 终端二
mysql> select * from students;
+----+-------+
| id | sname |
+----+-------+
| 1 | Gage |
| 2 | sss |
| 4 | kksk |
+----+-------+
mysql> show variables like "%iso%";
+-----------------------+-----------------+
| Variable_name | Value |
+-----------------------+-----------------+
| transaction_isolation | REPEATABLE-READ |
+-----------------------+-----------------+
1 row in set, 1 warning (0.01 sec)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有