For updates, and deletes on the other hand I try to start with the where clause. Learnt the lesson after running a update query once before i typed the where to cause something like 40k worth of damage
DELETE FROM
Customers WHERE
Name='Gude' AND
Area='Tama'
;
Much harder to leave off half the clause doing this kind of thing.It doesn't save me time, but a lot of nerves.
SELECT *
-- DELETE
FROM Sales
WHERE Customer = 1
Next, selecting the whole query and executing it. If results are satisfactory - selecting only the DELETE part. select * -- delete
from sales
where customer = 1
so it's even harder to accidentally highlight the 'delete' part.Although I've switched to DBeaver for a year now, and it automatically pops up a warning when it detects a DELETE query without a WHERE, which is very nice.
Then if you make an error you can always ROLLBACK. If it looks OK -- COMMIT.
Similarly `git push ... -f` etc.
Everything is non-destructive without an explicit COMMIT.
--safe-updates
to avoid queries running without WHERE clause.