How to lock these tables?


#1

Information: MySQL version 4.0.20. The table S1 and follow_up are MyISAM type.


mysql> lock tables follow_up write, S1 write;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT follow_up (reg_no) SELECT S1.reg_no FROM S1 LEFT JOIN follow_up ON
S1.reg_no=follow_up.reg_no WHERE follow_up.reg_no IS NULL;
ERROR 1100: Table ‘follow_up’ was not locked with LOCK TABLES

If I use the following locking methods, they can not help yet.

  1. lock tables follow_up as S1 write;
  2. lock tables S1 as follow_up write;
  3. lock tables follow_up write;

How to lock these tables? Thanks!


#2

I think locking of tables can only be done using the InnDB table type.


#3

I have tested that MyISAM tables can be locked.


#4

In that case all I can give you is this

http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html

Good luck :)


#5

I have found the useful information listed below. Thank you!

“Also, you cannot use a locked table multiple times in one query - use aliases for that. Note that in that case you must get a lock for each alias separately.”