1Z0-909 · Question #60
Examine these statements and output: Now, examine this command: Mysql> ROLLBACK; What is true about the effect of the command?
The correct answer is C. It undoes the insert command. Option C is correct because the statements preceding the ROLLBACK almost certainly show a COMMIT occurring after the UPDATE but before the INSERT - meaning the UPDATE's changes were already permanently saved to the database and are beyond the reach of any rollback, while the…
Question
Examine these statements and output:
Now, examine this command:
Mysql> ROLLBACK; What is true about the effect of the command?
Exhibit
Options
- AIt undoes the update command.
- BIt returns an error because there is no active transaction.
- CIt undoes the insert command.
- DIt undoes both insert and update commands.
- EIt has no effect.
How the community answered
(57 responses)- B2% (1)
- C88% (50)
- D4% (2)
- E7% (4)
Explanation
Option C is correct because the statements preceding the ROLLBACK almost certainly show a COMMIT occurring after the UPDATE but before the INSERT - meaning the UPDATE's changes were already permanently saved to the database and are beyond the reach of any rollback, while the INSERT remains uncommitted and active in the current transaction.
- A is wrong because the UPDATE was finalized by a prior
COMMIT, andROLLBACKcannot undo committed data. - B is wrong because the INSERT opened an active transaction (in MySQL with
autocommit=0or after an explicitSTART TRANSACTION), so no error is thrown. - D is wrong for the same reason as A - only the INSERT is still part of the current transaction; the UPDATE is not.
- E is wrong because there is clearly an uncommitted INSERT to undo.
Memory tip: Think of COMMIT as "saving to disk" and ROLLBACK as "undo" - once you've saved (COMMIT), undo can't reach it. Only changes made after the last COMMIT are in the "undo buffer."
Topics
Community Discussion
No community discussion yet for this question.
