Hacker News new | past | comments | ask | show | jobs | submit login

Always SELECT before making changes. Or don't if you like feeling the adrenaline rush when executing a query in prod.



When 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.


SELECT, wrap it in a transaction, then either look at row count or SELECT again before COMMIT.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: