We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89cc66c commit 8067b30Copy full SHA for 8067b30
sql-queries-11/lock-single-row-mysql/select-for-share.sql
@@ -0,0 +1,22 @@
1
+//First Session
2
+START TRANSACTION;
3
+SELECT * FROM DEPARTMENT WHERE id=5 FOR SHARE;
4
+
5
+//Second Session
6
7
8
9
10
+SELECT * FROM DEPARTMENT WHERE id=5 FOR UPDATE;
11
12
13
+COMMIT;
14
15
16
17
18
19
20
+UPDATE DEPARTMENT SET code='MA' WHERE id<5 OR id>5;
21
22
+SELECT * FROM DEPARTMENT;
0 commit comments