Tuesday, October 14, 2014

Using SAVEPOINT in Oracle Database.


SQL> SAVEPOINT TEST;

Savepoint created.

SQL> CREATE TABLE TEST_DATAA( ID NUMBER);

Table created.

SQL> SELECT * FROM TEST_DATAA;

no rows selected

SQL> SAVEPOINT TEST;

Savepoint created.

SQL> INSERT INTO TEST_DATAA VALUES(10);

1 row created.

SQL> INSERT INTO TEST_DATAA VALUES(10);

1 row created.

SQL> SELECT * FROM TEST_DATAA;

        ID
----------
        10
        10

SQL> SAVEPOINT TEST;

Savepoint created.

SQL> INSERT INTO TEST_DATAA VALUES(20);

1 row created.

SQL> ROLLBACK TO TEST;

Rollback complete.

SQL> COMMIT;

Commit complete.

SQL> SELECT * FROM TEST_DATAA;

        ID
----------
        10
        10

SQL>  SAVEPOINT TEST;

Savepoint created.

SQL> INSERT INTO TEST_DATAA VALUES(20);

1 row created.

SQL> SAVEPOINT TEST;

Savepoint created.

SQL> INSERT INTO TEST_DATAA VALUES(30);

1 row created.

SQL> ROLLBACK TO TEST;

Rollback complete.

SQL> COMMIT;

Commit complete.

SQL> SELECT * FROM TEST_DATAA;

        ID
----------
        10
        10
        20

SQL>

No comments:

Post a Comment