O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required