4 ms·
Always SELECT before making changes. Or don't if you like feeling the adrenaline rush when executing a query in prod.
by is_true 5y ago
Always SELECT before making changes. Or don't if you like feeling the adrenaline rush when executing a query in prod.
- SketchySeaBeast 5y agoSELECT, wrap it in a transaction, then either look at row count or SELECT again before COMMIT.
- sokoloff 5y agoWhen doing interactive maintenance/querying (which I discouraged, but we all know it happens even if only in “break glass” scenarios), I would generally select * --update <blah blah> [or delete] from <blah blah> where <blah blah> which allowed me to execute the entire query as a select (or if I accidentally hit "run the whole buffer" it was safe), but then allowed me to highlight and run just the update (or delete) statement and ensure I had the same where clause as determined by my select statement pre-flighting.