Skip to content
CodeKruPro

What does ROLLBACK leave behind?

QuizMediumAsked in: Amazon

Account 1 holds 1000. What is its balance after this runs?

BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 99;  -- no account 99: 0 rows changed
ROLLBACK;
  • 1000
  • 500
  • 0
  • It depends on whether the second update changed a row

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in