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
精彩评论