Step 14
4 min read

COMMIT

Learn how to save your transaction - make changes permanent!

What is COMMIT?

COMMIT saves all changes made in a transaction. Makes them permanent.

Simple analogy: Like clicking "Save" button after editing a document.

Basic Syntax

BEGIN; -- Your changes here COMMIT;

Simple Example

BEGIN; UPDATE students SET grade = 'A' WHERE student_id = 1; COMMIT; -- Grade is now saved permanently

Before and After COMMIT

Before COMMIT:

  • Changes are temporary
  • Other users do not see changes
  • Can still cancel with ROLLBACK

After COMMIT:

  • Changes are permanent
  • Everyone sees the changes
  • Cannot undo

Real Example

BEGIN; UPDATE products SET price = 99.99 WHERE product_id = 1; UPDATE products SET stock = 50 WHERE product_id = 1; COMMIT; -- Both changes saved permanently

Summary

COMMIT = Save changes permanently

  • Like "Save" button
  • Makes changes visible to everyone
  • Cannot undo after COMMIT

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses