drop table t;
create table t(a int, primary key(a));
begin;
insert into t(a) values(1);
SAVEPOINT s;
insert into t(a) values(2);
ROLLBACK to SAVEPOINT s;
commit;
表中只有1个元素,值是1
drop table t;
create table t(a int, primary key(a));
begin;
insert into t(a) values(1);
SAVEPOINT s;
insert into t(a) values(2);
insert into t(a) values(2);
ROLLBACK to SAVEPOINT s;
commit;
表中没有元素,因为异常,事务回滚,保存点的异常向上传播到主事务,主事务也回滚