一、事务
从一种状态到另一种状态:
比如转账:一个人的钱多了或者少了
1.COMMIT
2.ROLLBACK
3.SAVEPOINT
SELECT * from ms_brda1
(1)select count(*) from ms_brda1
(2)delete from ms_brda1 where brid=158475
select count(*) from ms_brda1
(3)savepoint a;
select count(*) from ms_brda1
(4)delete from ms_brda1 where brid=158477
select count(*) from ms_brda1
(5)savepoint b;
(6)rollback to savepoint a;
(7)rollback to savepoint b;
(8)rollback ;
(1)
(2)
(3)savepoint a;
(4)
(5)savepoint b;
(6)rollback to savepoint a;
(7)rollback to savepoint b;
上面的情况是因为没分清楚先后顺序
先设置的“保存点A”,然后设置的“保存点B”
你已经回滚到A了,已经越过B了,再想回到B是不可以的
但是可以先回到B再回到A,
(8)rollback ;
而rollback是回到最初的状态
即
这样是因为deleted与select需要手动commit
所以可以rollback到最初的状态