News for hackers. Stuff that matters.
Re:An UPDATE without a WHERE, or something close to it by DoneWithAllThat on Friday October 29, 2021 @03:20PM (#29042507)
My approach is to type the “limit conditions” first, then go to the start of the line and do as you say (predicate the command with the comment string). So in the case of sql it might be something like starting with:

  WHERE foo=bar LIMIT 1;
Then ctrl-a, and fill in the rest:

  —- UPDATE name=“new name” WHERE foo=bar LIMIT 1;
Then take a moment, read over what I typed, and hit ctrl-a again and remove the comment string.

Ideally I’m doing this in an editor (not the db shell) as well, and when I’m done pass the saved file in on the commandline. I try to type as little as possible in the db shell unless I’m logged in as a read only user.

I also set my db shell to display the current username and database so it’s always right in front of me. And I never, ever use command history in shells to construct new commands. I swear that bit me more frequently than I got it right when I used to. It’s like a footgun with an extra footgun attachment.

Re:An UPDATE without a WHERE, or something close to it by jesterpm on Friday October 29, 2021 @05:03PM (#29043509)
I take a similar approach. I usually want to see what I'm about to change before I change it, so I'll SELECT * FROM ... WHERE ... , then go back in the command history and delete the SELECT FROM.
Re:An UPDATE without a WHERE, or something close to it by meowface on Friday October 29, 2021 @08:12PM (#29044901)
Same. (Also for DELETEs.) I would guess this is what a high percentage of people do.