Skip to content

Instantly share code, notes, and snippets.

@aidangannon
Created March 6, 2022 17:20
Show Gist options
  • Save aidangannon/84964f964f119cf146a49d6f7e333e45 to your computer and use it in GitHub Desktop.
Save aidangannon/84964f964f119cf146a49d6f7e333e45 to your computer and use it in GitHub Desktop.
# transaction 1
START TRANSACTION;
LOCK TABLE User IN EXCLUSIVE MODE;
INSERT INTO User (Name, Dob, Age) VALUES ('John', '10-10-1999', 24);
UNLOCK TABLE User;
COMMIT;
# transaction 2
START TRANSACTION;
SELECT * FROM User WHERE ID = '1bd76753-f391-453d-bd98-a212789dd652' FOR UPDATE;
INSERT INTO User (Name, Dob, Age) VALUES ('Jason', '9-9-1998', 32);
COMMIT;
@aidangannon
Copy link
Author

deadlock code, for oracle DB...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment