??????????????????б?????????????????????????????????????????????Ч??????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???????????????????????????????????????