COMMIT ends the current database transaction and makes all data modifications performed during the transaction permanent and visible to other sessions. After a successful COMMIT, locks acquired by the transaction are released, and the transaction context is cleared. If the session is in autocommit mode, each individual statement is implicitly committed and an explicit COMMIT has no effect.Key behaviors:- Durability: Once committed, changes survive crashes and restarts.- Visibility: Other connections can see the committed data immediately.- Savepoints: COMMIT releases all savepoints defined in the transaction.- Read only transactions: A COMMIT still finalizes the transaction even if no data was modified.Caveats:- Cannot COMMIT while inside an aborted transaction; issue ROLLBACK instead.- Long-running transactions that wait before COMMIT can hold locks and block other users.- Some databases automatically commit DDL statements, so COMMIT may be redundant after certain operations.
SQL-92
The transaction remains open. Locks stay in place, other sessions cannot see your changes, and eventually the database may abort the transaction if the session disconnects.
Most databases implicitly commit DDL statements before and after they run. DML changes (INSERT, UPDATE, DELETE) rely on explicit COMMIT when not in autocommit mode.
Yes. Use SAVEPOINT to mark a point, then ROLLBACK TO SAVEPOINT for partial rollback before issuing a final COMMIT.
Usually no. COMMIT writes changes to disk which can be costlier than discarding them with ROLLBACK, but the difference is minimal for small transactions.