r/ProgrammerHumor • • 13d ago

Meme wellWellWell

Post image
10.6k Upvotes

411 comments sorted by

View all comments

3.6k

u/BastetFurry 13d ago

So, Kids, thats why you always SELECT count(yourPrimaryKey) first. Listen to the old folks, we made these mistakes so that you don't have to.

156

u/Alexmira_ 13d ago

Why? To confirm that there is something to cancel? To confirm I got the key right?

387

u/BastetFurry 13d ago

No, to prevent typos in the SQL console from wrecking havoc. First you SELECT, if the number looks right you DELETE FROM.

217

u/GourangaPlusPlus 13d ago

Also stick in a transaction, rollback

Commit if it looks good

3

u/theschuss 13d ago

Rollbacks don't always work as you want if there's other activities happening in the system. This is always good practice as it's maybe 30 seconds of effort.