MySQL 插入时表级锁锁定什么?
我多次读到MySQL会在插入期间对MyISAM表执行表级锁。 如果该锁仅用于序列化插入/删除命令,那对我来说没问题。 无论如何,在我的网站上插入内容很少。
但是,在插入命令完成之前,该锁是否也会阻止所有 Select 查询?
I have read many times that MySQL will perform table level locks on MyISAM tables during inserts. It's OK with me if that lock is ment for serializing insert/delete commands only. Inserts are very infrequent on my website any way.
But will that lock block all Select queries too until the insert command finishes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
写锁将阻止所有使用您已锁定的表的选择。
A write lock will block all selects that use the tables you've locked.
要在 MySQL 服务器中实现隔离级别,您可以使用 SET SESSION 命令更改会话隔离模式。
上面的语句将像WITH(nolock)一样工作,即读取未提交的数据。 您还可以为所有连接全局设置隔离级别。
MySQL服务器中有两个与隔离级别相关的系统变量。
第一个语句将返回全局隔离级别,第二个语句将仅返回当前会话。
在 SQL Server 中,您还可以像这样在事务级别设置隔离级别。
阅读更多@: 带有 nolock 的 mysql
To accomplish isolation levels in MySQL server you can change the session isolation mode using SET SESSION command.
The above statement will work like WITH (nolock) i.e READ UNCOMMITTED data. You can also set the isolation level globally for all connections.
There are two system variables related to isolation level in MySQL server.
The first statement will return the global isolation level, the second will return only for current session.
In SQL Server you can also set the isolation level at transaction level like this.
reade more @: mysql with nolock