5 ms·
If you're doing manual updates to a production DB, using START TRANSACTION and then checking the outcome of your changes before you use COMMIT stops typos becom
by davweb 9y ago
If you're doing manual updates to a production DB, using START TRANSACTION and then checking the outcome of your changes before you use COMMIT stops typos becoming catastrophes.
- neoeldex 9y agoThere's some caveats with this approach, since your DB has to keep track of the split state since you've started the transaction, it's quite a lot busier. So don't keep transactions open for any long stretches of time ;)
- j_s 9y agoIn case it's not obvious: new auto increment IDs are skipped forever whenever a transaction is rolled back. This isn't really an issue at all but can upset those with OCD-ish tendencies.
- corobo 9y agothose with OCD-ish tendencies best hope they never lose any customers then.
- btschaegg 9y agoThis. There's so much in software development that relies on guarantees that can only be upheld by behavior like this that I _sincerely_ doubt that anyone having issues with skipped rows is in the right place. There are arguments for and against any technique, but this one seems really ridiculous to me, especially if you consider what any "countermeasure" would do to the code (which is usually much more important than the data in the long run!).
- j_s 9y agoUPDATE tbl SET deleted=1