Oof. Been there, done that, 0 stars; would not recommend.
Programming
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
I don't know if it makes you feel better but Tom Scott had a similar experience: https://youtu.be/X6NJkWbM1xk
This is about the one thing where SQL is a badly designed language, and you should use a frontend that forces you to write your queries in the order (table, filter, columns) for consistency.
UPDATE table_name WHERE y = $3 SET w = $1, x = $2, z = $4 RETURNING *
FROM table_name SELECT w, x, y, z
Ctrl+z bro
Jk, sounds tough
Unrelated, but use placeholders instead of interpolation right into the query.
See: Little Bobby Tables. https://xkcd.com/327/
Things like this make me glad I can only query my db.
If it's Microsoft SQL you should be able to replay the transaction log. But you should be doing something like daily full backups and hourly incremental or differential backups to avoid this situation in the first place.
I know it's too late to be helpful now, but I always write the WHERE first, because you are not the first person to have done this...
SQL scouts credo: I will never use indexes, I will always use column names.
I‘m using DataGrip (IntelliJ) for any manual SQL tomfoolery. I have been where you are. Luckily for me, the tool asks for additional confirmation when doing any update/delete without where clause.
Also, backups are a must, for all the right reasons and for any project.
I learned this lesson too