Home > database >  MySQL InnoDB: Difference Between `FOR SHARE` and `LOCK IN SHARE MODE`
MySQL InnoDB: Difference Between `FOR SHARE` and `LOCK IN SHARE MODE`

Time:12-23

What is the difference of the following two sql:
select * from user where id = 1 for share
select * from user where id = 1 lock in share mode
Are they have the same effect that lock a row with shared lock?

CodePudding user response:

https://dev.mysql.com/doc/refman/8.0/en/select.html

FOR SHARE and LOCK IN SHARE MODE set shared locks that permit other transactions to read the examined rows but not to update or delete them. FOR SHARE and LOCK IN SHARE MODE are equivalent. However, FOR SHARE, like FOR UPDATE, supports NOWAIT, SKIP LOCKED, and OF tbl_name options. FOR SHARE is a replacement for LOCK IN SHARE MODE, but LOCK IN SHARE MODE remains available for backward compatibility.

  • Related