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

FWIW: Setting "safe-updates=1" in ~/.my.cnf will require UPDATE and DELETE statements in the client to have a WHERE clause which references a key. It's not perfect protection, but it will save you from a lot of mistakes.

That's awesome,

My worst DELETE fail however was:

  DELETE * FROM table WHERE [long condition that resolves to true for all records]
Now i write SELECT or SELECT COUNT(*) over and over again until i see the data i expect and then change it to a DELETE/UPDATE.

It's not my personal habit but some folks I know turn off auto commit and BEGIN a transaction every time they enter an interactive SQL sessions. They then default to ROLLBACK at least once before COMMITing them.

That and having a user with read-only permissions or a read replica

Is there a collection of data safety tips like this somewhere? I never knew this existed. What else am I missing?

hmm, that's kinda cool. I'm in a MS shop and I don't know if SMSS has the same feature. My manager just looked at me and said "welp, go restore the table and be more careful next time." I was a new DBA at the time, still, kinda new.

USE BEGIN TRANS as mentioned above

Applications are open for YC Winter 2020

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