tags:

views:

40

answers:

1

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.

A: 

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

Frank Farmer