问题描述
这是我的第一个问题,请耐心等待.
This is my first question so please bear with me.
我使用了以下命令:
LOCK "table table_name WRITE;"
在mysql工作台中
锁定所有向该表添加行的新手.我无法解锁"此表.
每当我尝试输入其他命令时,例如
in mysql workbench to lock any new people adding rows to this table. I cannot "unlock" this table.
Whenever I try entering different commands for example
select * from table_name
屏幕一直处于加载状态.任何帮助将不胜感激.
the screen just keeps on loading. Any help will be appreciated.
推荐答案
锁定释放规则
释放会话持有的表锁时,它们将同时释放.会话可以显式释放其锁,也可以在某些条件下隐式释放锁.
When the table locks held by a session are released, they are all released at the same time. A session can release its locks explicitly, or locks may be released implicitly under certain conditions.
-
会话可以使用UNLOCK TABLES显式释放其锁.
A session can release its locks explicitly with UNLOCK TABLES.
如果会话发出LOCK TABLES语句来获取锁,而已经持有锁,其现有锁被隐式释放在授予新锁之前.
If a session issues a LOCK TABLES statement to acquire a lock whilealready holding locks, its existing locks are released implicitlybefore the new locks are granted.
如果会话开始事务(例如,使用STARTTRANSACTION),则执行隐式的UNLOCK TABLES,这会导致现有的要释放的锁.
If a session begins a transaction (for example, with STARTTRANSACTION), an implicit UNLOCK TABLES is performed, which causesexisting locks to be released.
参考: http://dev.mysql.com/doc/refman/5.7/en/lock-tables.html
这篇关于如果我使用命令LOCK table table_name WRITE,MYSQL如何解锁表;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!