开发者

Lock Mysql table for write but allow read

开发者 https://www.devze.com 2023-01-04 15:00 出处:网络
Is there a way to lock a Mysql table only for write, so that another script can still make a SELECT query?

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

精彩评论

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