Home  >  Article  >  Database  >  What are the two different states of mysql locks?

What are the two different states of mysql locks?

PHPz
PHPzforward
2023-06-03 14:00:211223browse

State lock description

1. Including intention shared locks and intention exclusive locks, which are divided into the core logic of state locks.

2. Both types of locks describe whether a table lock can be added to a table.

When a transaction attempts to lock the entire table (shared lock or row lock), it first needs to obtain the corresponding type of intention lock (intention shared lock or intention shared lock)

Intention shared lock

When a transaction attempts to add a shared lock on the entire table, it first needs to obtain the intention shared lock of the table.

Intention exclusive lock

Before a transaction attempts to lock the entire table, it first needs to obtain the intention lock of the table.

The role of status lock

The locking method of innodb is based on the index, and the locking granularity is row lock. Intention locks exist to coordinate the relationship between row locks and table locks, and support the coexistence of multi-granularity (table locks and row locks) locks.

The above is the detailed content of What are the two different states of mysql locks?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete