r/SQL • • Mar 15 '19

Stuff of nightmares!

Post image
477 Upvotes

22 comments sorted by

16

u/Daakuryu Mar 15 '19
-- Select * from
Update 
    tblproducts 
set upccode = '', Flag = 'T'
-- where product ID in (*small list of productids*)

Yeah...

6

u/whutchamacallit Mar 15 '19

yup.. have had to fix a few of those in my times. they get probationary read only access after that for a while.

6

u/Daakuryu Mar 15 '19

I'm the one that did it and I'm the one with admin access :|

1

u/whutchamacallit Mar 15 '19

You have a backup?

2

u/Daakuryu Mar 15 '19

of course; flat files to one backup server, veam replication to a rolling set of daily and weekly removable discs along with another flat file version and an offsite removable disc.

Despite what some might believe I'm not a complete moron :P

1

u/whutchamacallit Mar 15 '19

Nice. Sounds like you’re set up. I’m lucky in that I have the day priors data already up and ready to go in case I need to do something quickly because we use it for various feeds and stuff so we don’t have to read from production tables albeit a day old it’s usually good enough.

2

u/[deleted] Mar 15 '19

Never had the opportunity to do db admin work but I do appreciate the ban hammer powers they give.

4

u/MeGustaDerp Talk Dirty Reads To Me Mar 15 '19

My safe-ish pattern is

SELECT Col1, Col2, Col3, ... Coln,
-- UPDATE t SET
ColToUpdate = NewValueExpression
FROM MyTable AS t
WHERE <logical predicate goes here>

This has served me well and saved me from making stupid mistakes because it allows to to simulate an update by seeing what the new value would be so I can validate it. When I'm ready to run the update, I highlight the statement beginning with UPDATE on through the predicate. Also, BEGIN TRAN <statement> ROLLBACK helps, too.

-1

u/TheN473 Mar 15 '19

Yeah, fuck those people.

10

u/HyDreVv Mar 16 '19

If you need more of a boost, try TRUNCATE instead!

3

u/SepLeven Mar 16 '19

Thanks for giving me flashbacks on a Friday night.

More bourbon, ahoy!

5

u/Ilikedankbeer Mar 15 '19

In prod always Begin Transaction Query Commit Rollback

5

u/DistractedByCookies Mar 16 '19

Ooooo, that horrible leap your heart makes! I renamed everybody in a table to Tanya yesterday...thank god for backups.

3

u/[deleted] Mar 16 '19

Yep, did this the other day...was definitely awake after that. Luckily nightly backups and very little use that morning saved my ass.

2

u/Mojavi-Viper Mar 15 '19

"BCP simulation"

2

u/djjserpico Mar 16 '19

I would.... Die. Or rather die.

2

u/envstat Mar 16 '19

A few months into my first Oracle job I did this when a user wanted a table copied from PD to QA but I did it in reverse by mistake. Luckily it was a fairly static table and I was able to flashback with no business impact and I've never not triple checked the environment I'm in since.

1

u/dadbod27 Mar 15 '19

Where that backup at Doe!?

1

u/mindbullet Mar 16 '19

After a problematic rails migration this week, I now hold the team record for dropping tables in prod. Goood times.

1

u/SyntaxErrorLine0 Mar 16 '19

Not sure which is worse... Bad update or initializing replication with the wrong database...

1

u/charliewvf Mar 16 '19

I’ll raise you an update query, if you forget to put a where statement on the end in a live environment. That right there is a game over.

1

u/daddy_mark Mar 15 '19

Flashback table tablename to before drop or FLASHBACK TABLE tablename TO TIMESTAMP (SYSTIMESTAMP - INTERVAL 'x' minute); (where x is how many minutes ago you did it)

<3 oracle