为保证业务的完整性,当一条语句出现错误,则此步骤全部回退
### 终端一
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)