Autocommit Mode

By default, the system variable AUTOCOMMIT is set to 1, which instructs MySQL to process each database-manipulation statement issued immediately as a single transaction. This is the behavior you have already seen, with an INSERT, UPDATE, or DELETE committed to the database as soon as you issue the command.

Consider this simple UPDATE statement:

UPDATE PRODUCTS
SET price = 5.99
WHERE code = 'MINI';

When autocommit mode is turned on, the previous statement is executed as if you had entered the following:

BEGIN TRANSACTION;

UPDATE PRODUCTS
SET price = 5.99
WHERE code = 'MINI';

COMMIT;

By setting the value of AUTOCOMMIT to 0, you disable this feature so that you have to use COMMIT to store any changes made—or use ROLLBACK to discard ...

Get Sams Teach Yourself MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.