Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Modifying Data with SQL Handling Errors When Manipulating Data Introduction to Transactions

Autocommitting:

What do you mean by some systems don't have autocommit turned on and thus we need to begin and commit after each statement. I remember you talked ABOUT IT IN the transactions section. The problem is I don't get why you would need to begin if you did not have to turn off autocommit cause it doesn't exist.

2 Answers

In PostgreSQL, all statements are automatically executed as transactions. You only need to use BEGIN and COMMIT when explicitly defining transaction blocks in a script.

In MySQL, every statement is written to disk sequentially because autocommit is turned on by default. You must implicitly turn off autocommit by wrapping your statements with START TRANSACTION and COMMIT.

It's also worth mentioning that MySQL only has 1 storage engine that supports transactions, InnoDB, which is now the default engine (used to be MyISAM prior to version 5.5).

Steven Parker
Steven Parker
231,271 Points

It looks like you already asked this same question twice before, here and here.

But not all databases have an autocommit feature that you can turn on and off. This information only applies to those which do. And if it is turned off, any changes you make will not be permanent until you give the commit command.