1. What locks are there in MySQL?
- Locks can be categorized into three types: global locks, table-level locks, and row-level locks.
Global Lock
- Using the
FLUSH TABLES WITH READ LOCK
statement puts the entire database in a read-only state
- During this time, operations such as inserts, updates, deletes, or table structure modifications by other threads are blocked.
- Mainly used for full database logical backups to ensure data consistencies in the backup file.
Table-Level Lock
-
Table Lock
-
Metadata Lock (MDL)
-
Intention Lock
Row-Level Lock
-
Record Lock
-
Gap Lock
-
Next-Key Lock