位置: IT常识 - 正文

mysql临键锁的使用(mysql 临键锁)

编辑:rootadmin

推荐整理分享mysql临键锁的使用(mysql 临键锁),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:mysql临时密码在哪里,mysql创建临时表sql,mysql临键锁和间隙锁的区别,mysql临时密码在哪里,mysql临建锁,mysql 临键锁,mysql临建锁,mysql临键锁和间隙锁的区别,内容如对您有帮助,希望把文章链接给更多的朋友!

mysql临键锁的使用(mysql 临键锁)

1、默认情况下,innodb使用临键锁锁定记录。

select...forupdate

2、当查询索引包含唯一属性时,临键锁将被优化并降级为记录锁,即只锁定索引本身,而不是范围。

3、不同场景下的临键锁会退化。

实例

事务1starttransaction;selectSLEEP(4);select*fromtestwhereage=22forupdate;select*fromtestwhereage>23forupdate;selectsleep(20);commit;**************************事务2starttransaction;selectsleep(8);select*fromtestwhereage=20forupdate;select*fromtestwhereage=21forupdate;select*fromtestwhereage=22forupdate;select*fromtestwhereage=23forupdate;commit;************************************事务执行状态事务1starttransaction>OK>时间:0sselectSLEEP(4)>OK>时间:4.001sselect*fromtestwhereage=22forupdate>Affectedrows:0>时间:0.001sselect*fromtestwhereage>23forupdate>Affectedrows:0>时间:0.001sselectsleep(20)>OK>时间:20scommit>OK>时间:0.001s***********************事务2starttransaction>OK>时间:0.001sselectsleep(8)>OK>时间:8sselect*fromtestwhereage=20forupdate>Affectedrows:0>时间:0.001sselect*fromtestwhereage=21forupdate>Affectedrows:0>时间:0.001sselect*fromtestwhereage=22forupdate>Affectedrows:0>时间:14.158sselect*fromtestwhereage=23forupdate>Affectedrows:0>时间:0.001scommit>OK>时间:0s

以上就是mysql临键锁的使用,希望对大家有所帮助。更多mysql学习指路:MySQL

本文链接地址:https://www.jiuchutong.com/zhishi/304167.html 转载请保留说明!

上一篇:python uiautomator2的点击操作

下一篇:c语言内联汇编如何理解(c语言内嵌汇编)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络