From the course: Advanced PostgreSQL

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Rolling back transactions

Rolling back transactions - PostgreSQL Tutorial

From the course: Advanced PostgreSQL

Rolling back transactions

In this movie, we'll see how you can rollback a transaction. We've seen how we can use the commit keyword to commit the changes in our transaction to our table. Rollback will rollback changes. I'm going to insert a new record into the bank accounts table for Jack. Jack contains $1,000 in this account. I'm going to run both of these statements so that after we perform the insertion, we can see the new records in the table. I have Charlie and Dora as before with $99000 and $25,100 and you can see Jack here at the very bottom with $1,000 in this bank account. I'm now going to use a transaction to perform a withdrawal and deposit operation. But before I commit the transaction, I'm going to roll back the changes that I have made. Let's execute this code one command at a time. On line four, I have the begin command. Go ahead and execute it. This will start our transaction. Next, I have an update command that withdraws $1,500 from Jack's bank account. Run this command and then select and…

Contents