autocommit
By default, MySQL runs each statement in its own transaction (autocommit=1). Disable it or use explicit START TRANSACTION to group statements.
By default, MySQL runs each statement in its own transaction (autocommit=1). Disable it or use explicit START TRANSACTION to group statements.
-- Check autocommit
SELECT @@autocommit;
-- Disable for session
SET autocommit = 0;
UPDATE products SET price = 9.99 WHERE id = 5;
UPDATE products SET price = 14.99 WHERE id = 6;
COMMIT;
-- Re-enable
SET autocommit = 1;
-- Explicit START TRANSACTION also disables autocommit temporarily
Most application frameworks disable autocommit and manage transactions at the application level.