The split second feeling of EXECUTE an UPDATE and SET value without putting WHERE clause.

I froze for a moment with cold sweat that I don't know what to do. My mind went blank.

Thank God it is just the entire list of customer details that is not relate to money issue.

Anyone can suggest the best practice for this type of accident UPDATE / DELETE?
Does using BEGIN TRANS ROLLBACK is safer way to execute?

  • 3
    Transaction is good,

    For mass update, I usually copy the table(s) and test there first.
  • 1
  • 0
    Do a class, where update() by default ends query with LIMIT 1. I do that for DELETE at least.
  • 1
    I always start with the select
  • 1
    @ShotgunSurgeon yeah, same. Starting of with a select, to verify if it's giving the correct results first, then adjusting to set the values I want to set.

    I cleared a field for a whole table even with a WHERE clause. Because in MySQL, something equal to 0 isn't the same as being equal to "0".

    And of course, Transactions for the win :)
Add Comment