MyISAM uses table-level locks by default. Generally, table-level locks in Web applications can meet the requirements. InnoDB uses row-level locks by default, but it also supports table-level locks. Row-level locks are more accurate and consume the most resources. The Berkeley DB Engine uses page-level locks by default, each of which has its own merits.
1. MySQL table-Level Lock usage:
Lock table [tablename] [lock-type];
For example, add a read lock to table test1:
Lock table test1 read;
2. How to unlock MYSQL:
Unlock tables;
The preceding method uses table-level and release. The following conclusions can be tested in person, which is also obtained from my tests:
1. Write locks take precedence over read locks (this can be set using parameters );
2. When a read lock occurs, the write lock cannot be added, but the read lock can be applied;
3. When there is a write lock, neither the read lock nor the write lock can be added;
When a conflict occurs, the latter is added to the blocking queue.
OK. The above conclusion can be verified using the lock usage method.