Here’s a free tip. When you’re making ad hoc changes to a database directly from the database client, it is a good idea to stick
LIMIT 1 on your
DELETE statements if your intent is to only update one row. Even if you want to update many rows, I still recommend a dry run with
LIMIT 1 first.
Then if you make an error in your boolean logic or leave something out of the
WHERE clause, the wreckage will be limited. It’s much easier to deal with the loss or unwanted alteration of one record than a whole database.
Of course, wrapping your ad hoc queries inside a transaction is also a brilliant idea. I recommend that approach as well assuming it’s available.