Not sure if this qualifies, since it wasn't caused so much by coding, but by not checking a command I had typed in before hitting return...
IIRC, I was 18 or 19 years old, working as a developer for my first real employer. My "supervisor" was the lead developer for this shop (small mom-n-pop type dev shop), which developed a small insurance claims management system for our Arizona's public health care system (AHCCCS).
One of our clients at that time was using our system in a "heads down" fashion, entering claims manually on RS232 serial VT100-emulation terminal sessions on 386 PCs (showin' my age!). We had three database tables involved for these claims; a claim table, a transaction table, and a line item table.
At the time, we had nothing like a live and test environment; in many cases, testing and development was done on the production system (big mistake, I realize in hindsight). So, I was given the keys to the kingdom to develop this system, which involved me doing some kind of data manipulation to these tables. However, since I couldn't use the live data, I had to use a copy of the tables. So my steps were:
- Copy the three tables to new names, which were referenced in my code.
- Try the code out.
- Check the data in the tables - was it right?
- If not right, delete the testing tables, go back to step 1
- If right - yay, I am done!
Step four was the "gotcha"; the tables had names like "CLAM_CLAM" (claims), "CLAM_TRAN" (transactions), and "CLAM_BENE" (benefits or line items); to this day I can still remember their names!
Anyhow, my test tables I called something like "TEST_CLAM", "TEST_TRAN", and "TEST_BENE". Well, I got to step four after many rounds of testing all day, and instead of typing "DELETE TEST_????", I typed "DELETE CLAM_????", on one of the tables (can't remember which, off-hand).
Well - as soon as I hit return, I realized what I had done; all my co-workers heard was me moaning loudly "NOOOOOOOOOOOOO!!!!!", and before anyone could ask me what was wrong, all phones in our office started ringing; every...single...one. This included my supervisor's, as well as the owner/president of the company. I had single-handedly caused our client's entire claims entry division for that part of the company (which at the time was one of the largest insurance providers in Arizona) to stop. Not only that, but I had managed to delete all the claims from that day, back for a couple of years.
After the dust had settled, and both me and my boss got chewed out (I imagine he got the worst of it - ie, why was he letting a kid delete records on a production system), we managed to recover from backups all of the data up to that day's work. To recover the rest of the data (that day's work), my boss and I sat down, designed and wrote a recovery tool that used the other two tables (that I hadn't deleted) to re-create the data in the deleted table, and what couldn't be recovered (which was a very minor amount of the total), the client had to re-key in from their paper claims. We didn't go home that night until well after midnight.
We laughed and joked about it afterward; our inside gag afterward was one of us would type the delete command, the other would check the entry, if it looked right, one of us would hold the keyboard while the other stuck his finger over the delete key, and lift the keyboard to "press the key".
The lessons I took from that day were "have a testing system" (and nowadays a staging area as well), and "when working on a production system, always, always, always double check what you are doing, before completing the command or action". To this day, I am glad I had to learn that early in my career as a software developer, and that my boss and his boss (the owner) was cool with it, and we recovered the data.
These lessons have followed me thru my career, and have also been helpful in electronics and such (helps to keep the magic smoke in place).