×
☰ See All Chapters

MySQL COMMIT

A SQL statement that runs successfully is different from a committed transaction. Executing successfully means that a single statement was:

  • Parsed 

  • Found to be a valid SQL construction 

  • Run without error as an atomic unit. For example, all rows of a multi-row update are changed. 

However, until the transaction that contains the statement is committed, the transaction can be rolled back, and all of the changes of the statement can be undone. A statement, rather than a transaction, runs successfully.

The COMMIT command is the transactional command used to save changes made by any number of transactions since the last COMMIT or ROLLBACK command. If AUTOCOMMIT set to false and the transaction not committed, the changes will be visible only for the current connection. After COMMIT statement commits the changes to the table, the result will be visible for all connections.

The syntax for this command is

commit [ work ];

WORK is a keyword that is completely optional; its only purpose is to make the command more user-friendly.

 


All Chapters
Author