Transactions and Savepoints : Transaction Rollback Commit « Table « Oracle PL / SQL






Transactions and Savepoints

    
SQL>
SQL>
SQL> CREATE TABLE emp (
  2     empID INT NOT NULL PRIMARY KEY,
  3     Name      VARCHAR(50) NOT NULL);

Table created.

SQL> INSERT INTO emp (empID,Name) VALUES (1,'Tom');

1 row created.

SQL> INSERT INTO emp (empID,Name) VALUES (2,'Jack');

1 row created.

SQL> INSERT INTO emp (empID,Name) VALUES (3,'Mary');

1 row created.

SQL> INSERT INTO emp (empID,Name) VALUES (4,'Bill');

1 row created.

SQL> INSERT INTO emp (empID,Name) VALUES (5,'Cat');

1 row created.

SQL> INSERT INTO emp (empID,Name) VALUES (6,'Victor');

1 row created.

SQL>
SQL> SAVEPOINT BeforeAddingBademp;

Savepoint created.

SQL> INSERT INTO emp (empID, Name) VALUES (99, 'Bad emp');

1 row created.

SQL> ROLLBACK TO BeforeAddingBademp;

Rollback complete.

SQL>
SQL> COMMIT;

Commit complete.

SQL>
SQL>
SQL>
SQL> drop table emp;

Table dropped.

   
    
    
    
  








Related examples in the same category

1.Transaction Rollback and commit
2.atomicity: roll back and commit
3.Rollback a delete
4.TRANSACTION CONTROL
5.set transaction use rollback segment SEGMENT_NAME
6.show autocommit
7.Transactions and Error Handling
8.SET TRANSACTION READ WRITE
9.Rollback to savepoint in exception handler
10.alter rollback segment SEGMENT_NAME online