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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.