MyNameIsRichard,
@MyNameIsRichard@lemmy.ml avatar

It’s a good way to wake yourself up in the morning

toxic_cloud,

Doctors HATE this one simple trick! Lose up to 100% of MyChart data - and KEEP it off!

Can help reduce blood pressure, high cholesterol, weight, height, gender, name and more to NULL! Wake up feeling NULL and NULL!

Sunforged,

Legit have nightmares about this.

derfl007,

oopsie daisy moment

saltnotsugar,

This is what we in the industry refer to as a “big oof.”

ultratiem, (edited )
@ultratiem@lemmy.ca avatar

But it’s only, like, a handful of rows 🙃

IHawkMike,

I thing the technical term for this is an RGE.

(Resume Generating Event)

Fuck_u_spez_,

Must be a technical term.

jabberati,
@jabberati@social.anoxinon.de avatar

BEGIN TRANSACTION is your friend

argo_yamato,

Had something like that happen to a local dev database (thankfully). A dev next me blurts out “how to I rollback an update in SQL server”? He was used to Oracle and how easy it is to rollback something. Had to explain that commit just happens in SQL server regardless of whether or not you put that commit line in.

SzethFriendOfNimi,

Transactions are your friend here

Begin transaction;

Then

Your sql here

Double/triple check the messages/console for results. Look good?

Commit;

Worried?

Rollback;

Just be sure to mind your transaction logs for long running queries and by all things holy be sure you’re not doing this to a live db with a ton of transactions since you’re basically pausing any updates until the commit or rollback on the affected tables

xmunk,

This makes it safer but like… don’t run queries on production outside emergencies ever.

That transaction frame, depending on your specific DB, may cause severe performance side effects.

Look, the safe approach is to write it into something, PR it, get it reviewed, and then run it as part of a structured deployment process.

SzethFriendOfNimi,

Absolutely. It should have been tested and verified.

JoMiran,
@JoMiran@lemmy.ml avatar

Me: “Ok. What’s the big deal.”

Also me: “Less than a million affected. That’s nothing.”

Still me: “Rule 1: Never let pesky details get in the way of a funny meme.”

Ultimately me: 😱😂 “That guy is in for a rough Monday!”

xmunk,

For everyone’s sanity, please restrict access to the prod DB to like two people. No company wants that to happen to them, and no developer wants to do that.

HugeCounterargument,

Me applying for any database access ever: “read only. I do not want write. READ ONLY.”

breadsmasher,
@breadsmasher@lemmy.world avatar

Datagrip has an option, and likely other database IDEs do as well - “Connect as READONLY”. Makes me feel a little safer

Yearly1845,

deleted_by_author

  • Loading...
  • finestnothing,

    I don’t use readonly with dbeaver, but I do have the prod servers set to automatically make transactions and have to hit a button to commit. Almost certain it asks confirmation that I want to make the changes to prod which is nice too (I rarely have to touch our sql server prod)

    lobut,

    Just a funny story. All of our devs and even BAs used to have prod access. We all knew this was a bad idea and put in a process of hiring a DBA.

    I think in the first two weeks the DBA screwed up prod twice. I can’t remember the first mess up but the second he had a lock on the database and then went to lunch.

    We eventually hired two awesome DBAs to replace that one but oh boy.

    Lionel,

    Imagine being hired to help prevent people from fucking something up, only to fuck that thing up in your first week—not once, but twice. You’d think after the first time it wouldn’t happen again…

    rwhitisissle,

    I would say you can expand that on the following criteria: 1) a lot of people can have read access, but only a few should have write access, and read access should be restricted to specific tables without PII. 2) The people with write access should go through a Change Approval process: they submit the SQL they’re going to run and someone else approves or denies it before it can be done. 3) Every piece of SQL that modifies a table should be annotated with a comment and the ticket number in it in which that change was approved. 4) You should be able to rollback any committed change within an hour of it happening.

    Rhinoshock,

    In T-SQL:

    BEGIN TRANSACTION

    {query to update/delete records}

    (If the query returned the expected amount of affected rows)

    COMMIT TRANSACTION

    (If the query did not return the expected amount of affected rows)

    ROLLBACK TRANSACTION

    Note: I’ve been told before that this will lock the affected table(s) until the changes made are committed or rolled back, but after looking it up it looks like it depends on a lot of minor details. Just be careful if you use it in production.

    joemo,

    Transactions are the safe way of doing it.

    You can also return * to see the changes, or add specific fields.

    Like for example:

    Begin; Update users Set first_name=‘John’ Where first_name=‘john’ Returning *;

    Then your Rollback; Or Commit;

    So you’d see all rows you just updated. You can get fancy and do a self join and see the original and updated data if you want. I like to run an identifying query first, so I know hey I should see 87 rows updated or whatever.

    Haven’t had any issues with table locks with this, but we use Postgres. YMMV.

    tweeks,

    If for example a client application is (accidentally) firing doubled requests to your API, you might get deadlocks in this case. Which is not bad per se, as you don’t want to conform to that behaviour. But it might also happen if you have two client applications with updates to the same resource (patching different fields for example), in that case you’re blocking one party so a retry mechanism in the client or server side might be a solution.

    Just something we noticed a while ago when using transactions.

    jaybone,

    Lol why did I have to scroll so far to see ROLLBACK

    rwhitisissle,

    Because this is c/programmerhumor and the OP hasn’t covered ROLLBACK yet in his sophomore DB class.

    meldrik,
    @meldrik@lemmy.wtf avatar

    This is missing NSFW tag!

    Tenthrow,
    @Tenthrow@lemmy.world avatar

    This is giving me PTSD

    magic_lobster_party,

    Well at least we got a backup, right?

    Right???

    andrew,
    @andrew@lemmy.stuart.fun avatar

    It last ran a week ago and we technically haven’t tested it. Just our hot replicas which also just deleted all that data.

    TheGreenGolem,

    And of course by now every downstream system replicated AND CACHED that data.

    Amends1782,

    Holy shit the truth with replication deleting the data you needed too true lmao

    dontcarebear,
    @dontcarebear@lemmy.world avatar

    I felt a slight jolt of adrenaline on that second “right???” After living through something similar…

    datelmd5sum,

    ah the cold sweat and clenching of the anus

    DudeDudenson,

    Backup? What is this backup you speak of?

    Alexstarfire,

    Back up? No, we only go forward in this company

    _dev_null,
    @_dev_null@lemmy.zxcvn.xyz avatar

    “That’s why the windshield is bigger than the rear view mirror, we should be vigilant in remaining forward looking.”

    Said by an exec in my chain of command when he caused a huge cascading fuck up in the organization and there was no postmortem allowed.

    originalucifer,
    @originalucifer@moist.catsweat.com avatar

    wasnt halloween last week. stop scarin me

    r00ty,
    @r00ty@kbin.life avatar

    For MS-SQL. If it is production, it has a full transaction log, right? I mean I know for development use I turn that off, but for live data you want that on. You should be able to roll back to any point since the last time it was truncated. Or right before hitting return to whatever level of accuracy you're comfortable with.

    nuke,

    Just hit Ctrl+Z to Undo

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines