Forgot to add a WHERE clause in my UPDATE query for Prod DB, that contained 100K+ Records.


  • 3
  • 2
    @bioDan Googling steps to revert... 😥
  • 12
    My advice is always: build as select in the first place and check result. Then replace the select. Not that I follow that rule 😂
  • 2
    @danzig666 that's good advice

    I also got into the habit of writing queries in reverse. WHERE & LIMIT come first. Now it's second nature
  • 2
    In sqlserver usually I type Begin transaction before any ad-hoc update operations on prod, then I test it, if it works I type commit

    Sometimes I forget the commit and lock up the database all day haha
  • 1
    Me too, @encore!

    But, general rule... Backup, backup, backup! Before literally ANYTHING!
  • 2
    By the way, this post was 11hrs ago apparently - how did things turn out??
  • 1
    . (I wanna know the end.)
  • 1
    Happened to me once. I had chance that the IT guy made a backup right before I started.
  • 4
    I am safe guys... No-one knows....
    Luckily my query was just after the cron backups that are scheduled every month....
    I was hairline close to being fired for loosing one month's data...
    PS-Please don't tell my lead about this, nobody knows... ^_^
Add Comment