Created
August 20, 2020 12:36
-
-
Save gbarreiro/b2c4fe4009a9688d20b2a61008311df4 to your computer and use it in GitHub Desktop.
MySQL cheatsheet: create a transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Enabling and disabling automatic transactions | |
SET AUTOCOMMIT = 1; -- each SQL sentence is a transaction; i.e. it's automatically comitted into the actual DB (enabled by default) | |
SET AUTOCOMMIT = 0; -- SQL sentences are not automatically commited into the DB, so you must do it manually with the COMMIT instruction | |
COMMIT; -- commits a transaction | |
-- Running a transaction inside a stored procedure | |
START TRANSACTION; | |
-- ... instructions of the transaction ... | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment