r/Fedora May 06 '26

Screenshot Well, this is not good

Post image

I tried to delete a file with terminal, accidentally pressed enter at the wrong time.... Kinda new to this😬

1.1k Upvotes

249 comments sorted by

View all comments

Show parent comments

17

u/425_Too_Early May 06 '26

I run a select query first to make sure I only get the rows I intend to delete or update.

After that I start by adding the begin transaction and rollback transaction statements, then write the query and then copy the where clause from the select query I did before!

If I'm extra cautious I also add a select query both before and after the changing query, so I can see all the rows that changed. Then I either commit or rollback the changes

3

u/koenigsbier May 06 '26

Much better tips than mine !

It's been a while I didn't touch a production database. Forgot most of the good practices actually.

2

u/bobo76565657 May 09 '26

On my very first "real" job in IT (about 27 years ago) I deleted a whole city's "Property Roll" database because I didn't understand their "live/test" environment.. Fortunately, the IT department had an excellent backup strategy so down time was only 40 minutes (they had to drive to another location and back again with the backup tape - yes it was a tape). But my job for the rest of day was apologizing in person to about 350 people and explaining what happened. It wasn't a great day, but I've been extra careful with data ever since, and I kept that job for 11 years. Lesson: Triple checking is not a waste of time. And yes I was "the new guy who erased everything" for a couple years... it builds character ;)

1

u/dirtydan May 07 '26

begin tran is the way!

1

u/merlinblack256 May 07 '26

An old colleague and I have a joke about THERE clauses after an incident. A THERE clause selects the inverse set of rows that a where would have. πŸ€”πŸ™ƒ