1.

What are COMMIT, ROLLBACK and SAVEPOINT statements in PL/SQL?

Answer»
  • These are the three transaction specifications that are available in PL/SQL.
  • COMMIT: Whenever any DML operations are performed, the data gets manipulated only in the database buffer and not the ACTUAL database. In order to save these DML transactions to the database, there is a need to COMMIT these transactions.
    • COMMIT transaction action does saving of all the outstanding changes since the last commit and the below steps take place:
      • The RELEASE of AFFECTED rows.
      • The transaction is marked as complete.
      • The DETAILS of the transaction would be stored in the data dictionary.
    • Syntax: COMMIT;
  • ROLLBACK: In order to undo or erase the changes that were done in the CURRENT transaction, the changes need to be rolled back. ROLLBACK statement erases all the changes since the last COMMIT.
    • Syntax: ROLLBACK;
  • SAVEPOINT: This statement gives the name and defines a point in the current transaction process where any changes occurring before that SAVEPOINT would be preserved whereas all the changes after that point would be released.
    • Syntax: SAVEPOINT <savepoint_name>;


Discussion

No Comment Found