Analytics

Sunday, March 24, 2013

Transaction Rollback Commit

All changes of data in an Oracle database can only be done within a transaction. A transaction must either be committed or rolled back.

Data changed within a transaction is not visible to another session until it is commited.

COMMIT :Make changes done in transaction permanent.
ROLLBACK :Rollbacks the state of database to the last commit point.

Transaction Rollback and commit

SQL> create table t ( x number(1) );

Table created.

SQL> insert into t values ( 1 );

1 row created.

SQL> insert into t values ( 2 );

1 row created.

SQL>
SQL> rollback;

Rollback complete.

SQL> select * from t;

no rows selected

SQL> insert into t values ( 1 );

1 row created.

SQL> insert into t values ( 2 );

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t;

         X
----------
         1
         2

No comments:

Post a Comment