标签:tab lis get target 创建 事务 color 操作 created
当执行rollback时,通过指定保存点可以回退到指定的点。
回退事务的几个重要操作
1.设置保存点 savepoint a
2.取消保存点a之后事务 rollback to a
3.取消全部事务 rollback
注意:这个回退事务,必须是没有commit前使用的;
如果事务提交了,那么无论你刚才做了多少个保存点,都统统没有。 如果没有手动执行commit,而是exit退出会话了,那么会自动提交 。
开始实验:创建savepoint还原点
SQL> set time on
SQL> create table test(aa varchar(9));
Table created
SQL> insert into test values(1);
1 row inserted
SQL> savepoint a1;
Savepoint created
SQL> select * from test;
AA
---------
1
SQL> insert into test values(2);
1 row inserted
SQL> savepoint a2;
Savepoint created
SQL> select * from test;
AA
---------
1
2
SQL> insert into test values(3);
1 row inserted
SQL> savepoint a3;
Savepoint created
SQL> select * from test;
AA
---------
1
2
3
SQL> insert into test values(4);
1 row inserted
SQL> savepoint a4;
Savepoint created
SQL> select * from test;
AA
---------
1
2
3
上面设置了4个保存点。
SQL> rollback to a3;
Rollback complete
SQL> select * from test;
AA
---------
1
2
3
SQL> rollback to a1;
Rollback complete
SQL> select * from test;
AA
---------
1
SQL> rollback to a2;
rollback to a2
ORA-01086: savepoint ‘A2‘ never established in this session or is invalid
SQL> rollback;
Rollback complete
SQL> select * from test;
AA
---------
SQL>
标签:tab lis get target 创建 事务 color 操作 created
原文地址:https://www.cnblogs.com/sgphappy2007/p/10459648.html