Change the second transaction (terminal B) to obtain a share lock. Other sessions can read the rows , but cannot modify them until your transaction commits. InnoDB implements standard row -level locking where there are two types of locks , shared ( S ) locks and exclusive ( X ) locks. A shared ( S ) lock permits the transaction that holds the lock to read a row. The locked data is reserved for read by the current session.
But they can not write (update) the locked.
I want to select and row lock the result for writing, write the change . MySQL get a lock to update certain rows and prevent other. Lock mysql table to prevent select and insert at the same time. The session that holds the READ lock can only read data from the table, but cannot write. Finally, try to insert a new row into the messages table:.
Then, a write lock is acquired. All transactions can read the rows , but if they want to modify them, they have to wait until your transaction is committed. SKIP LOCKED modifier which can be used to non-deterministically read rows from a table .
InnoDB supports both table-level and row -level locking.
