nerdexam
Oracle

1Z0-873 · Question #34

When working with InnoDB, for which of the following reasons should you use the FOR UPDATE locking modifier?

The correct answer is C. You intend to SELECT a set of rows, then modify those rows. With FOR UPDATE, InnoDB locks each selected row with an exclusive lock. This is useful if you intend to select and then modify a set of rows, because it prevents other transactions from reading or writing the rows until the first transaction releases the locks, which happens…

MySQL Storage Engines

Question

When working with InnoDB, for which of the following reasons should you use the FOR UPDATE locking modifier?

Options

  • AYou intend to run more than ten UPDATE statements in one transaction.
  • BYou intend to execute an UPDATE statement on any row.
  • CYou intend to SELECT a set of rows, then modify those rows.

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    13% (4)
  • C
    83% (25)

Explanation

With FOR UPDATE, InnoDB locks each selected row with an exclusive lock. This is useful if you intend to select and then modify a set of rows, because it prevents other transactions from reading or writing the rows until the first transaction releases the locks, which happens when the transaction finishes.

Topics

#InnoDB#SELECT FOR UPDATE#pessimistic locking#transaction management

Community Discussion

No community discussion yet for this question.

Full 1Z0-873 Practice