SQL practice: Transactions: The Undo Button
Chapter 28 · 6 questions · included in full access
Question 1 · easy
Solve it in your browserInside BEGIN/ROLLBACK, raise all Accessory prices by 10%, check with a SELECT, then roll back. Confirm afterwards that nothing changed.
Question 2 · easy
Solve it in your browserDo the same but with COMMIT instead, then put the prices back with a second UPDATE. (Notice how much more careful you have to be.)
Question 3 · medium
Solve it in your browserInside a transaction, insert a new order and then roll it back. Confirm the order is gone.
Question 4 · medium
Solve it in your browserExplain why a stock transfer between branches should be one transaction rather than two separate statements.
Question 5 · hard
Solve it in your browserInside BEGIN/ROLLBACK, delete all Cancelled orders, count what's left, then roll back.
Question 6 · hard
Solve it in your browserStart a transaction with BEGIN. Insert a customer named 'Savepoint Retail' with city 'Mumbai' and customer_type 'Retail'. Create a SAVEPOINT named step_one. Then insert another customer named 'Bad Record' with city 'Goa' and customer_type 'Retail'. Roll back to step_one using ROLLBACK TO SAVEPOINT step_one, and finally COMMIT the transaction.
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing