Skip to content

Commit 8067b30

Browse files
authored
Create select-for-share.sql
1 parent 89cc66c commit 8067b30

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//First Session
2+
START TRANSACTION;
3+
SELECT * FROM DEPARTMENT WHERE id=5 FOR SHARE;
4+
5+
//Second Session
6+
START TRANSACTION;
7+
SELECT * FROM DEPARTMENT WHERE id=5 FOR SHARE;
8+
9+
//Second Session
10+
SELECT * FROM DEPARTMENT WHERE id=5 FOR UPDATE;
11+
12+
//First Session
13+
COMMIT;
14+
15+
//Second Session
16+
SELECT * FROM DEPARTMENT WHERE id=5 FOR UPDATE;
17+
18+
//Second Session
19+
START TRANSACTION;
20+
UPDATE DEPARTMENT SET code='MA' WHERE id<5 OR id>5;
21+
22+
SELECT * FROM DEPARTMENT;

0 commit comments

Comments
 (0)