Programming · Flashcard

An UPDATE runs with no WHERE clause. What happens?

  • AEvery row is updated, with no warning at all
  • BThe statement is rejected, since UPDATE requires a WHERE
  • COnly the first row is updated, as a safety default
  • DNothing changes until a WHERE clause is supplied

Why this is the answer

A missing WHERE means every row matches, and the server does it without comment — which is why this is the classic production incident and why clients such as psql offer no protection. Wrapping the statement in a transaction and checking the row count before COMMIT is the habit that saves you.

Official docs
Study in Gnoseed →