HomeMySQL Page 8 - Using Transactions In MySQL (Part 1)
Time Out - MySQL
One of the most-requested MySQL features - transactions - is finally available in MySQL 4.0. In this first segment of a two-part article, learn about the theory behind the transactional model, find out how it can make your SQL applications more robust, and find out how to implement a transactional environment with MySQL's InnoDB table handler.
And that's about it for the moment. Over the last few pages, I introduced you to transactions in MySQL, explaining the theory behind the transactional model and showing you how to implement a transactional environment with MySQL's InnoDB tables. I also demonstrated one of MySQL's quirks - automatic COMMITs and ROLLBACKs in particular situations - and showed you how to control automatic commits with the AUTOCOMMIT variable.
In the second part of this article, I'll be exploring the MySQL transactional model in a multi-user scenario, illustrating some of the data corruption problems that raise their ugly heads in this environment and showing you how you can use MySQL's isolation levels to reduce their likelihood. I'll also show you how to leverage off the transaction model to build more robust SQL applications, with a sample Perl/DBI application, and explain how to use transactions with non-transactional MyISAM tables. All that and more, next time...so make sure you come back!
Note: All examples in this article have been tested on MySQL 4.0.14. Examples are illustrative only, and are not meant for a production environment. Neither Melonfire nor DevShed provide warranties or support for the source code described in this article.