4 ms·
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 t
by DoneWithAllThat 5y ago
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.
- jesterpm 5y agoI 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.
- meowface 5y agoSame. (Also for DELETEs.) I would guess this is what a high percentage of people do.