怎么理解mysql innodb的行锁

44次阅读
没有评论

共计 869 个字符,预计需要花费 3 分钟才能阅读完成。

这篇文章主要讲解了“怎么理解 mysql innodb 的行锁”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着丸趣 TV 小编的思路慢慢深入,一起来研究和学习“怎么理解 mysql innodb 的行锁”吧!

基于索引上锁,而不是针对选出来的具体的行
root@sakila 10:14:32 show index from tab_no_index \G
*************************** 1. row ***************************
        Table: tab_no_index
   Non_unique: 1
     Key_name: id
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 5
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment:
Index_comment:
1 row in set (0.00 sec)

第一个会话
root@sakila 10:18:39 select * from tab_no_index where id=1 and name= 1 for update;
+——+——+
| id   | name |
+——+——+
|    1 | 1    |
+——+——+
1 row in set (0.00 sec)

第二个会话
root@sakila 10:18:42 select * from tab_no_index where id=1 and name= 4 for update;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

感谢各位的阅读,以上就是“怎么理解 mysql innodb 的行锁”的内容了,经过本文的学习后,相信大家对怎么理解 mysql innodb 的行锁这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是丸趣 TV,丸趣 TV 小编将为大家推送更多相关知识点的文章,欢迎关注!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-19发表,共计869字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)