Get the App
SLTechnology News&Howtos  ›  Database  › 

MyISAM table

Shulou Source: shulou.com Published: 2022-06-01 07:48:14 10月01日 Update

1. not support transactions

MyISAM: locks the entire table, locking the entire table instead of the rows. Shared locks (read locks) can be acquired on all tables when reading data, and each connection does not interfere with each other. At write time, or exclusive lock, the entire table is locked while other join requests (read and write) are pending.

MySQL has two modes of table-level locking: shared table Read lock and exclusive table write lock. MyISAM automatically adds read locks to all tables involved before executing query statements (SELECT), and automatically adds write locks to all tables involved before executing update operations (UPDATE, Delete, INSERT, etc.).

Therefore, when operating on the MyISAM table, the following situations will occur:

Read operations (read locks) on MyISAM tables will not block read requests from other processes on the same table, but will block write requests on the same table. Only when the read lock is released will other processes 'writes be executed.

b. Write operations to MyISAM tables (add write locks) will block other processes from reading and writing to the same table. Only when the write locks are released will read and write operations of other processes be performed.

2. MyIASM repair table

[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)

Reference: www.cnblogs.com/baochuan/archive/2012/03/15/2398276.html

Tags: Process blocking only time transaction situation data pattern statement reference reading interference support update query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Huawei Shulou Technology Redmi