everytime I see these memes I just think if something like this would happen in real life, the company would deserve it. should not be that easy to destroy productive environments, and if it is, it just means company is likely understaffed and under qualified.
I've done something similar before. But I didn't delete, I updated a field on every row. In a way much worse, our applications would just crash if I deleted everything. Instead it will give incorrect information to our fulfillment centers and send the wrong things to people.
Figured I was fired, but I didn't panic, at first. I called operations, and demanded they step away from everything right now like it was a damn bomb, then messaged my peers to turn off *everything*. I put out a Teams message to the entire company, telling them to stop working. Then called the CFO and said we needed a restore asap. It was fixed in like 30 minutes, and I ended up getting praised for handling it so well. Not the ending I expected lol
First week as a junior in my first job I got the login to all the production servers. Did some minor db adjustments as well that first week. Never deleted anything I shouldn’t have the two years I worked there but I was terrified at all times.
I worked at a big tech company like 8 years ago. Ranked top 100 in the Fortune 500 list. I won't say who.
A company wide email went out and apparently someone in IT accidentally ran "rm -rf" at root and deleted about 4 TB of data before the company caught it.
They obviously had backups but it took them like 5 hours to restore everything.
If your org can't take five minutes to not give everyone write access to prod then they deserve what's coming to them. This isn't an unknown exploit lying in wait, they is basic database administration 101.
Now you're just making up scenarios based on a stupid reddit post. I'm speaking more generally and addressing your quickness to judge. Shit happens sometimes and many small businesses simply don't have the resources. If you're in this game long enough, you'll have your turn looking for a little understanding and grace.
No, you are. Just don't give everyone blanket write access and have backups. It isn't hard and has been talked about to death. This isn't the 00s anymore, have some fucking standards.
It makes more sense in certain environments, especially if you have rollback and backups. Though, i usually don’t tell juniors about flashback until they have their first heart-stoping mistake in qa
I mean, this can happen. In some IDE like datagrip you can just select part of a query and execute it, and if you miss a line you can destroy everything. But, usually, I check the number of rows affected and then I commit when I'm totally sure. It just became natural
I never use this feature, precisely for this reason.
Generally, I also run a SELECT COUNT(*) against the same WHERE clause to ensure that I'm deleting the data I intended to.
On very large data sets, the WHERE clause might actually be a cause for performance issues if there's a lot of data to delete, so instead I might have one query to fetch the primary key of the rows I need to remove, then a second query to delete based on those primary keys.
Couple minor tips if you're barebacking the production database and using highlight running often.
Get into the habit of never putting the WHERE on a different line.
DELETE FROM ProductionTable WHERE Field = 'xyz'
Use alias and joins to reduce your own ability to run a partial, yet valid update.
instead of UPDATE ProductionTable SET Field = 'newval' WHERE Field = 'oldval'
spend a little more time and do this, so no single line will work without the entire execution.
update x set x.Field = y.NewValue from ProductionTable x join ( select Id, 'newval' as [NewValue] from ProductionTable where Field='oldval' ) y ony.Id=x.Id
This might work for extremely simple queries, but anything of slight complexity and you have long unreadable lines. A delete is not always run on the condition of a single field, it can be against many, against the results of a subquery, etc.
What I've found that can work better though, and would fit in with your suggestion, is to delete against the primary key. You'll run a first query to get the primary keys of all involved rows, and then delete based on those keys. It's not perfect, and doesn't cascade across joined tables where you'd also want to remove data, but it does get around the performance issues of large deletes based on joins.
I've had to do some pretty crazy things with SQL. Perfomance is always something that is negligle on your local machine, but once something hits production, you really need to start watching those milliseconds!
Aside from SSMS, I think all SQL clients these days wrap everything inside a transaction by default for prod environments. Part of the tool bar shows how many uncommitted queries you've stacked up and there's a button to intentionally commit them.
This lad looks to be on a Mac, so he's not using SSMS. Also you likely wouldn't give him access to prod.
Just think it's meant to be funny. Jokes often fall down a little if you look too closely at them.
With a transaction, so you can rollback the query.
If the dev knew enough to use a transaction, they'd also know enough not to comment out the guard clause.
Also with more rigid constraints over deletions.
This was the one thing I was hoping the person I was replying to would say. It's the only real protection against this sort of thing really.
But especially with database backups that this engineer should have immediately used.
Yes, and it has to be a tested backup. I've literally seen this kind of thing happen more than a few times (thankfully never caused by me), and in the majority of those cases, there were no tested backups, and data was out of date.
+ It should be in general harder for the language to mistake a chunk of working statement for its entirety. + Good language design would make it easier to follow good practices than bad ones + Navigation/Selection is a separate concern from actually modifying the values. I should be brutally trivial to convert a query that selects a specific element to a query that deletes it. The navigation step should also come before the action, since that's the logical imperative order: Find X, remove X. SQL gets this backwards. + Ideally the database software should make it easier to do historical data, if you had history, then undoing this would be trivial. Of course, there are some very rare cases where you really do want do erase something for good, but those are not most cases. That's how git works, so we for some bizzare reason treat code much more carefully than actual data. + It's also kind of bizzare that we have two entirely separate languages, pretty much never in the same paradigm, to manipulate data. Our own general purpose programming language and SQL. They fundamentally solve the same problem. And no ORMs aren't really a good solution, since those are usually just a different way to write SQL programs, they have their own syntax and semantics compared to how you would usually manipulate your regular datastructures. + Finally, it also failed to be a standard language.
Agreed to almost all of this, but nitpicks/comments:
That's how git works, so we for some bizzare reason treat code much more carefully than actual data
It's much easier to do this with code than with data because code is almost always many orders of magnitude smaller than data. git defaults to keeping everything forever, which would be a totally impractical approach to all but the most trivial data sets. Also, code is probably generally more valuable an asset than data, although that may have changed with recent data regulation/legislation.
It's also kind of bizzare that we have two entirely separate languages, pretty much never in the same paradigm, to manipulate data
Eh, I dunno. Try to do what even a medium-complexity SQL query does using a general-purpose programming language and it quickly gets really awkward. If you try to functionalise away or hide the complexity you'll end up either reinventing SQL or writing an ORM.
How would you know there are not backups or test environments? it still takes time to roll back. And someone working on prod should know better. You don't just execute sql like that. Not even with a transaction. You do this supervised.
Omg I felt that... its quite literally an extreme speed run of the 5 stages of grief, hopefully you can curb it at denial with a recent back up but if you can't... what a nightmare
I am working for over 4 years with databases as a Data engineer and i really cant see how that could happen in any place with an ounce of decent architecture
I work in computer networks at a large government network and my equivalent is adding a prefix to some policy-map and suddenly noticing the error dashboard go up in flames...
Usually followed by "Why are all the CCTV cameras down?"
i don't know shit about db management and i still know to run a transaction backup before doing any queries and use your selection criteria alone the first time to make sure you get the response you are looking for before committing.
this can happen to any junior too. It's impossible in current world unless you're a very organized and big company with administrators micromanaging every policy to give access to a junior without involving some prod stuff. Rule 1: you have backups. Rule 2: you teach him to run transactions (or automatically run them) Ideally rule 3: You don't give him access to production
As per video: If you don't run transaction for every production potentially destructive operation you're a dumbass (and ofc have backups
I wasn't called the Drop King for no reason. Fortunately it was only a test environment (20 people were working on it) and also the admins were able to restore the db tables.
I worked with a guy who always acted like he was smarter than everyone else - passively aggressively laughing at a question, or being terse in slack because you should already know. He dropped a prod db like two months after I left
I actually did that once (worse it was via drizzle with confirmation asking if I am sure, and even worse I read the message, realized my query was wrong but became a dyslexic rtrd and still somehow chose the execute option)
Good thing I was able to restore the most recent backup quick before anyone noticed
Me neither, but so many colleges where I would recommend them for doing so, as how many hours I have spent troubleshooting because they either did not commit or do t realize that their transaction also can have implicit commits and whatever they tested before hand is now prod.
This actually almost happened to me once. I had a ‘where 1;’ at the end of an update query and executed it but luckily the table was huge and didn’t have proper indexing so the client got stuck on the pre-select it does, just in time for me to notice and kill the process 😅
Who tf is gonna let to make a direct query or any action in the production base having more than 14 kk users. The joke is for those whose qualification is similar to meme character
455
u/fusionove May 20 '26
everytime I see these memes I just think if something like this would happen in real life, the company would deserve it. should not be that easy to destroy productive environments, and if it is, it just means company is likely understaffed and under qualified.
126
u/mkluczka May 20 '26
14.5M rows in one second?
88
u/No-Grape-9106 May 20 '26
Its been years since I touched SQL and even I would know to use a transaction (with rollback).
If this happens then you kinda deserve it.
43
u/AliceCode May 20 '26
This literally makes no sense. Why would you be making unsupervised SQL edits to the production database?
13
u/SameAgainTheSecond May 20 '26
THATS WHY SEMICOLONS IN SQL
DONT "FIX" SQL BY REMOVING THE SEMI
9
u/VertigoOne1 May 20 '26
BEGIN TRAN. Moron
8
u/stools_in_your_blood May 20 '26
Yes he should use a tx, yes he should be more careful, yes there should be a backup ready to go...
...BUT: this is a flaw in the design of SQL. Requiring a WHERE clause on DELETE and UPDATE would eliminate this class of mistake.
6
u/NickleLP May 20 '26
5
u/Matthew_Summons May 20 '26
That’s why we use transactions
3
u/rost5000 May 20 '26
No transactions, no backups, no test environments, no liquidbase.
So you deserve it.
3
u/magicmulder May 20 '26
It's actually funny how PMs sometimes see an error before Sentry drops me an email. 😃
Also, INSERT INTO users SELECT * FROM users AS OF TIMESTAMP SYSDATE - 20/86400. Thank Oracle later.
4
u/imeme1969 May 20 '26
2
u/ChaseboundGames May 20 '26
It's the moment your query takes longer than a few seconds to run on prod.... Ahhh shit the where!!!!!
2
u/akarolia47 May 20 '26
Am I the only one who expected it to end with an edit of him jumping - sorry flying passed the window👀
2
u/kjeft May 20 '26
Begin; first. Always.
2
u/lukerm_zl May 20 '26
BEGIN;
2
u/minowlin May 21 '26
SELECT
thing I just didFROMthe universeANDplease make it go away1
u/Oceans_77 May 20 '26
Omg I felt that... its quite literally an extreme speed run of the 5 stages of grief, hopefully you can curb it at denial with a recent back up but if you can't... what a nightmare
1
u/Old_Tourist_3774 May 20 '26
I am working for over 4 years with databases as a Data engineer and i really cant see how that could happen in any place with an ounce of decent architecture
1
u/Alexllte May 20 '26
Dev on prod, what could go wrong?
1
u/rob132 May 20 '26
The call from the project manager is unrelated.
The call from the director of IT is not.
1
u/Prod_Meteor May 20 '26
Project manager or the head of department?
1
u/conall88 May 20 '26
transactions, savepoints, and dryruns are a thing everyone should know about.
https://jarirajari.wordpress.com/2025/07/01/dry-run-for-postgresql/
1
u/Case_Blue May 20 '26
I work in computer networks at a large government network and my equivalent is adding a prefix to some policy-map and suddenly noticing the error dashboard go up in flames...
Usually followed by "Why are all the CCTV cameras down?"
1
u/garo675 May 20 '26
Unintentionally did this on the dev DB in my internship when trying to fix a test case
1
u/seuadr May 20 '26
i don't know shit about db management and i still know to run a transaction backup before doing any queries and use your selection criteria alone the first time to make sure you get the response you are looking for before committing.
1
u/IceCapZoneAct1 May 20 '26
open window
jump out of the building
problem solved
1
u/Frequent_Policy8575 May 20 '26
And this is why you do everything in a transaction. Firebird had its issues but requiring everything to be in a transaction was genius.
1
u/CoolCat1337One May 20 '26
not possible
some FK would prevent this for sure.
1
u/dankshot35 May 20 '26
bruh just press cmd + z
1
u/elderberries-sniffer May 20 '26
BLOODY
1
u/Awkward-Cat-4702 May 20 '26
huh, not my proudest: "been there, done that."
but... yeah...
1
u/Apart-Touch9277 May 21 '26
This is why I don’t have auto commit turned on.
1
u/Used_Fish5935 May 21 '26
THATS why god gave us transactional databases
1
u/ARPA-Net May 21 '26
transactions...
1
u/PrinzJuliano May 21 '26
Most rdbms will not allow a statement without a proper where condition (hence 1=1)
1
u/tracagnotto May 21 '26
this can happen to any junior too. It's impossible in current world unless you're a very organized and big company with administrators micromanaging every policy to give access to a junior without involving some prod stuff.
Rule 1: you have backups.
Rule 2: you teach him to run transactions (or automatically run them)
Ideally rule 3: You don't give him access to production
As per video:
If you don't run transaction for every production potentially destructive operation you're a dumbass (and ofc have backups
1
u/ragingsloth7 May 21 '26
I wasn't called the Drop King for no reason. Fortunately it was only a test environment (20 people were working on it) and also the admins were able to restore the db tables.
1
u/agneum May 21 '26
BEGIN TRAN
1
u/cedrickvstheworld May 21 '26
always begin transaction when manually interacting with db. Also your devops guy should have setup daily backups
1
u/burnerfordileesi May 21 '26
I worked with a guy who always acted like he was smarter than everyone else - passively aggressively laughing at a question, or being terse in slack because you should already know. He dropped a prod db like two months after I left
1
u/Cosmic_Frenchie May 22 '26
Scariest nightmare
1
u/Sad-Maintenance-8523 May 22 '26
BEGIN;
1
u/Secret-Wonder8106 May 22 '26
I actually did that once (worse it was via drizzle with confirmation asking if I am sure, and even worse I read the message, realized my query was wrong but became a dyslexic rtrd and still somehow chose the execute option)
Good thing I was able to restore the most recent backup quick before anyone noticed
1
u/[deleted] May 22 '26
always Transaction and rollback first... always.
1
u/debtcoder-dev May 22 '26
Why was he filiming himself?
1
u/Mundane_Upstairs3241 May 22 '26
Time to test out the backup recovery boss
1
u/MrChrysoprase May 23 '26
I thought he would take advantage of the window.
1
u/shadjor May 23 '26
And this is why I would never have an auto commit.
1
u/crstk May 23 '26
Just restore from backup
1
u/Glum_Cheesecake9859 May 24 '26
1
u/jfeijo May 24 '26
Enable commit and rollback.
1
u/Hairy-Affect-3734 May 24 '26
lucky we backed that shit up
1
u/35point1 May 24 '26
This actually almost happened to me once. I had a ‘where 1;’ at the end of an update query and executed it but luckily the table was huge and didn’t have proper indexing so the client got stuck on the pre-select it does, just in time for me to notice and kill the process 😅
1
u/leonidaspt May 25 '26
Just call the DBA
1
u/DBeaver_official May 28 '26
DBeaver saves you from things like that easily (by showing a warning before running
UPDATEorDELETEqueries without aWHEREclause)1
u/[deleted] May 20 '26
Oh, stupid indian humor. Something new.
0
u/Bersy-23 May 20 '26
Who tf is gonna let to make a direct query or any action in the production base having more than 14 kk users. The joke is for those whose qualification is similar to meme character