From the course: SQL for Testers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Transactions
- [Instructor] One of the things that are pretty common in SQL are transactions. Let's take a quick look at how they work. So to start a transaction, you just need to type BEGIN TRANSACTION and then a semicolon. And then once we've begun a transaction, we can start typing in the queries that are going to be part of that transaction, just like we normally would. So we can say here INSERT INTO cart VALUES and then give it some values, so let's say user one is going to have product ID two and also user one is going to have product ID three. And then, we can do a SELECT * FROM cart. And let's go ahead and run this whole thing. So we're going to start the transaction and then we're going to do these queries in that transaction. So we run that and we get back what we kind of expect. We've added these values into the cart table and when we select from the cart table, we see those values. Now, at this point, it just kind of looks like a normal SQL interaction, right? But there's something…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.