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

Why Use Transactions?

A transaction is a group of Database Manipulation Language statements that occur as a unit. Either the entire transaction takes place and is committed to the database, or none of the attempted changes is saved.

Transactions enable you to ensure data integrity when performing multiple database operations. Consider a product database that includes the number of each item in stock. When a customer places an order, a record is inserted into the orders table for each product ordered, and the corresponding stock levels are decreased.

Both of these changes to the database need to take place in a single transaction. Otherwise, two possible pitfalls could be encountered.

If the items are added to a customer’s order before the stock ...

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