```html

Oracle COMMIT — FAQs

1. What is COMMIT in Oracle?

COMMIT permanently saves all changes made in the current transaction.

COMMIT;

2. What happens after COMMIT?

  • Changes become permanent.
  • Locks held by the transaction are released.
  • The transaction ends.

3. Does COMMIT save INSERT, UPDATE, and DELETE?

Yes. It makes all DML changes in the current transaction permanent.

4. Can COMMIT be rolled back?

No. Once committed, ROLLBACK cannot undo those changes.

5. What is the difference between COMMIT and ROLLBACK?

COMMIT ROLLBACK
Saves changes permanently Undoes uncommitted changes
Ends transaction Ends transaction
Releases transaction locks Releases transaction locks

6. Does COMMIT affect other users?

Yes. After COMMIT, other sessions can see the committed changes according to Oracle's read-consistency rules.

7. Does COMMIT release locks?

Yes. Transaction-level locks are released when the transaction commits.

8. Is COMMIT required after SELECT?

No. SELECT does not require COMMIT.

9. Is COMMIT required after INSERT/UPDATE/DELETE?

If you want the changes to be permanent and visible to other transactions, yes.

10. What happens if I close the session without COMMIT?

Uncommitted DML changes are normally rolled back when the session terminates.

11. Does DDL automatically COMMIT in Oracle?

Yes. Oracle implicitly commits before and after most DDL statements such as CREATE, ALTER, and DROP.

12. Does COMMIT commit only the last statement?

No. It commits all uncommitted DML changes in the current transaction.

13. Can I use COMMIT inside a trigger?

Normally, no. A trigger cannot issue COMMIT or ROLLBACK directly.

14. What is COMMIT; vs COMMIT WORK;?

They are effectively equivalent in normal Oracle usage.

15. Can COMMIT be used in PL/SQL?

Yes, when transaction control is appropriate:

BEGIN
    UPDATE employees
    SET salary = salary * 1.10;

    COMMIT;
END;
/

16. What is COMMIT AND CHAIN?

It commits the current transaction and immediately starts a new transaction with certain transaction characteristics carried forward.

COMMIT AND CHAIN;

17. Can COMMIT cause data loss?

COMMIT itself does not delete data. But after committing, you cannot use ROLLBACK to undo those changes.

18. What is the safest rule for COMMIT?

Commit when a logical unit of work is complete, not after every individual DML statement.

Key Interview Point

COMMIT permanently saves all uncommitted DML changes in the current transaction, ends the transaction, and releases transaction-level locks. Once a transaction is committed, ROLLBACK cannot undo those changes.

```

No comments:

Post a Comment