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
andLOCK IN SHARE MODE
set shared locks that permit other transactions to read the examined rows but not to update or delete them.FOR SHARE
andLOCK IN SHARE MODE
are equivalent. However,FOR SHARE
, likeFOR UPDATE
, supportsNOWAIT
,SKIP LOCKED
, andOF tbl_name
options.FOR SHARE
is a replacement forLOCK IN SHARE MODE
, butLOCK IN SHARE MODE
remains available for backward compatibility.