Skip to content

Instantly share code, notes, and snippets.

@gbarreiro
Created August 20, 2020 12:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbarreiro/b2c4fe4009a9688d20b2a61008311df4 to your computer and use it in GitHub Desktop.
Save gbarreiro/b2c4fe4009a9688d20b2a61008311df4 to your computer and use it in GitHub Desktop.
MySQL cheatsheet: create a transaction
-- 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