Explanation: Transactions are sequences of operations performed as a single logical unit of work.
- Why It Matters: Using
COMMIT
andROLLBACK
ensures data integrity. Commits save changes, while rollbacks revert to the last commit if an error occurs. - Example:
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id = 1;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
Leave a Reply