??????????????????斜?????????????????????????????????????????????效??????MySQL??????????????????????屑????????????MySQL????????????????????????????????????????MySQL??????????????MYISAM??INNODB?????????????

????????????????????????写???????????????????????卸??????????????????????????写????????????????2??????????????????????????????????

??????????

?????梅???LOCK TABLE table_name [ AS alias_name ] READ

?????????????LOCK?????READ?????AS??????????????????????????????????????????

?????????????????????????????????写???????????????????

????????????????????????????????????????????????????????????写??

 写???? ??????
????????? ??????? ??
??????????? ???????? ??


????????????????MySQL??????????????????魏??????????????????????????????????????????????卸???????写?????????????????????????????????????MySQL??????????????卸????????????????校????????写???????????????????????????????????卸???????????????????写??????

????写????

?????梅???LOCK TABLE table_name [AS alias_name] [ LOW_PRIORITY ] WRITE

?????????梅???????????写??????????????????????????LOW_PRIORITY???????写????????????

????????写???????????????????????写????????????????????????

?????????????????MySQL????????????????写????????

 写???? ??????
???写????? ?? ??
?????写????? ???????? ?????????


???????????写????MySQL??????????????????卸?写?????????????????????????????写??????????????????????写??????

?????????????????

????????????????????????? LOW_PRIORITY WRITE < READ < WRITE

????1????????????????????????????WRITE??????????WRITE??????????READ????LOW_PRIORITY WRITE??????WRITE????READ?????????谢???????????

????2???????????????????????????????????????????

???????????

????1??????????????????锟�???斜?????????

???????绲�(t菕ng)?????table1???????SQL????邪?????table2???????????????纾�

mysql> LOCK TABLE test READ;
Query OK?? 0 rows affected (0.00 sec)

mysql> SELECT * FROM test_myisam;
ERROR 1100 (HY000): Table 'test_myisam' was not locked with LOCK TABLES
 


????2???????????SQL????????伪??????????????

??????SQL????卸??????????????????????纾�

mysql> LOCK TABLE test READ;
Query OK?? 0 rows affected (0.00 sec)

mysql> SELECT * FROM test WHERE id IN (SELECT id FROM test );
ERROR 1100 (HY000): Table 'test' was not locked with LOCK TABLES
 


????????????????????????????????????????????????????????????

mysql> LOCK TABLE test AS t1 READ?? test AS t2 READ;
Query OK?? 0 rows affected (0.00 sec)

mysql>  SELECT * FROM test AS t1 WHERE id IN (SELECT id FROM test AS t2);
+----+-----------+
| id | content   |
+----+-----------+
|  1 | tt_1      |
|  3 | new_3     |
|  4 | new_4     |
|  5 | content_5 |
+----+-----------+
4 rows in set (0.00 sec)
 


????3???????????????????????????????????????