Reputation: 6057
It seems like you can achieve all you need with transactions using only BEGIN; ROLLBACK and COMMIT;. Are there certain scenarios that require using autocommit? Does calling BEGIN; set autocommit to false? Does calling COMMIT; set autocommit to true?
Upvotes: 1
Views: 847
Reputation: 37374
autocommit can be set per session or globally. No scenario that require autocommit (not all RDMS support auto-commit mode). In my opinion, the reason why autocommit is presented and true by default is because MyISAM engine does not support transactions at all, so to alleviate porting applications written for MyISAM they mimic the same behaviour.
Does calling BEGIN; set autocommit to false? Does calling COMMIT; set autocommit to true?
From mysql documentation
To disable autocommit mode for a single series of statements, use the START TRANSACTION statement: ...
With START TRANSACTION, autocommit remains disabled until you end the transaction with COMMIT or ROLLBACK. The autocommit mode then reverts to its previous state.
Upvotes: 2