COMMIT is a transaction control command in MySQL that permanently saves all changes made during the current transaction. Once committed, the changes become visible to other sessions and cannot be undone.
// Basic syntax of COMMIT
COMMIT;
// Start a transaction and make changes
START TRANSACTION;
INSERT INTO orders (customer_id, order_date, total_amount)
VALUES (1, '2025-01-10', 2500);
// Save all changes permanently
COMMIT;
After executing COMMIT, the inserted order is permanently stored in the database. Even if the connection closes or an error occurs later, this data will remain saved.
AUTOCOMMIT is disabled when using manual commits