Home > Database > Mysql Tutorial > What is the use of mysql lock?

What is the use of mysql lock?

coldplay.xixi
Release: 2020-06-29 15:01:04
Original
3645 people have browsed it

The uses of mysql locks: 1. When sharing the lock, other users can read it but cannot change the meter data, which only affects the user; 2. When using the exclusive lock, other users can neither read nor change it. Table data; 3. Ensure the atomicity, integrity, and consistency of data.

What is the use of mysql lock?

The purpose of mysql lock:

Simply put, it is to lock the table and prevent others from touching it

1. There are two main types of locks: shared locks and exclusive locks

  • When sharing a lock, others can read it but cannot change the meter data.

  • When locking exclusively, others can neither read nor modify table data.

Based on the above characteristics, you should know when to use a lock. If you don't want others to change the data and affect you, lock it. The lock must be released after it is no longer used, otherwise the application system will always report errors due to reading data.

2. The advantage is to ensure the atomicity, integrity and consistency of data. Only when the lock holder releases the lock can others change the data.

3. The disadvantage is that it increases system overhead and may cause lock waiting, causing abnormal database operation. These are all problems caused by abnormal use of locks.

Related learning recommendations: mysql video tutorial

The above is the detailed content of What is the use of mysql lock?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template