Example of SAVEPOINT and “ROLLBACK TO..”

Examples of using “SAVEPOINT” and “ROLLBACK TO”

SQL> select * from scott.test;

no rows selected

SQL> insert into scott.test values (1, 2);

1 row created.

SQL> savepoint trans_1;

Savepoint created.

SQL> insert into scott.test values (3, 4);

1 row created.

SQL> savepoint trans_2;

Savepoint created.

SQL> insert into scott.test values (5, 6);

1 row created.

-- it will rollback upto the trans_1 so the 2 insert statements
SQL> rollback to trans_1;

Rollback complete.

SQL> select * from scott.test;

A B
———- ———-
1 2

1 row selected

One comment

Leave a Reply