开发者

Lock Mysql table for write but allow read

Is there a way to lock a Mysql table only for write, so that another script can still make a SELECT query?

I'm using this code to write to a table (executes almost every second):

mysql开发者_开发知识库_query("LOCK TABLES table WRITE;");
mysql_query("insert into...
mysql_query("UNLOCK TABLES;");

and this to select (this script just freezes, probably because of the lock):

mysql_query("select * from...

Thanks.


No.

WRITE lock:

Only the session that holds the lock can access the table. No other session can access it until the lock is released.

http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜