MyISAM表
1.不支持事務(wù)
MyISAM:對(duì)整張表進(jìn)行加鎖,鎖全表而不是行。在讀數(shù)據(jù)的時(shí)候,所有的表上都可以獲得共享鎖(讀鎖),每個(gè)連接都不互相干擾。在寫的時(shí)候,或者排他鎖,會(huì)把整個(gè)表進(jìn)行加鎖,而其他的連接請(qǐng)求(讀和寫)都處于等待。
MySQL的表級(jí)鎖有兩種模式:表共享讀鎖(Table Read Lock)和表獨(dú)占寫鎖(Table Write Lock)。MyISAM在執(zhí)行查詢語句(SELECT)前,會(huì)自動(dòng)給涉及的所有表加讀鎖,在執(zhí)行更新操作(UPDATE、DELETE、INSERT等)前,會(huì)自動(dòng)給涉及的表加寫鎖。
所以對(duì)MyISAM表進(jìn)行操作,會(huì)有以下情況:
a、對(duì)MyISAM表的讀操作(加讀鎖),不會(huì)阻塞其他進(jìn)程對(duì)同一表的讀請(qǐng)求,但會(huì)阻塞對(duì)同一表的寫請(qǐng)求。只有當(dāng)讀鎖釋放后,才會(huì)執(zhí)行其它進(jìn)程的寫操作。
b、對(duì)MyISAM表的寫操作(加寫鎖),會(huì)阻塞其他進(jìn)程對(duì)同一表的讀和寫操作,只有當(dāng)寫鎖釋放后,才會(huì)執(zhí)行其它進(jìn)程的讀寫操作。
2.MyIASM的修復(fù)表
[root@MyO test]# echo "a" >> myisam_tab.MYD
mysql> check table myisam_tab;
+-----------------+-------+----------+---------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+-----------------+-------+----------+---------------------------------------------------+
| test.myisam_tab | check | warning | Size of datafile is: 102 Should be: 100 |
| test.myisam_tab | check | error | got error: 120 when reading datafile at record: 5 |
| test.myisam_tab | check | error | Corrupt |
+-----------------+-------+----------+---------------------------------------------------+
3 rows in set (0.01 sec)
mysql> repair table myisam_tab;
+-----------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-----------------+--------+----------+----------+
| test.myisam_tab | repair | status | OK |
+-----------------+--------+----------+----------+
1 row in set (0.01 sec)
mysql> check table myisam_tab;
+-----------------+-------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-----------------+-------+----------+----------+
| test.myisam_tab | check | status | OK |
+-----------------+-------+----------+----------+
1 row in set (0.00 sec)
參考:http://www.cnblogs.com/baochuan/archive/2012/03/15/2398276.html