SQL practice: Transactions: The Undo Button

Chapter 28 · 6 questions · included in full access

  1. Question 1 · easy

    Inside BEGIN/ROLLBACK, raise all Accessory prices by 10%, check with a SELECT, then roll back. Confirm afterwards that nothing changed.

    Solve it in your browser
  2. Question 2 · easy

    Do the same but with COMMIT instead, then put the prices back with a second UPDATE. (Notice how much more careful you have to be.)

    Solve it in your browser
  3. Question 3 · medium

    Inside a transaction, insert a new order and then roll it back. Confirm the order is gone.

    Solve it in your browser
  4. Question 4 · medium

    Explain why a stock transfer between branches should be one transaction rather than two separate statements.

    Solve it in your browser
  5. Question 5 · hard

    Inside BEGIN/ROLLBACK, delete all Cancelled orders, count what's left, then roll back.

    Solve it in your browser
  6. Question 6 · hard

    Start 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.

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing