2 ms·
You can also do changes in the transaction and check that it did what you expected before committing.
by megous 8y ago
You can also do changes in the transaction and check that it did what you expected before committing.
- PowerfulWizard 8y agoThat is smart, I would add "limit 2" to a single row update, so if it returns 2 rows updated I know it was wrong.
- SOLAR_FIELDS 7y agoFair warning about this: if your transaction isolation level in your database is set to serialized hanging out in mid transaction while you verify your changes will block other calls to the table(s)! I always recommend that you are wrapping calls in transactions if you are touching prod data. I only left the WHERE clause of my update query off once in my life before I started doing that.
- megous 7y agoIf you fear this, you can put it into script like this: BEGIN; UPDATE... SELECT for verification ROLLBACK; And then just change ROLLBACK to COMMIT, after you're sattisfied. There's no need to do it interactively.