Home > Database > Mysql Tutorial > What is the concept of mysql metadata lock

What is the concept of mysql metadata lock

WBOY
Release: 2023-05-28 14:04:11
forward
1182 people have browsed it

1. MDL does not need to be used explicitly, it will be added automatically when accessed.

2. The function of MDL is to ensure the correctness of reading and writing.

As you can imagine, if a query is traversing the data in a table, and another thread changes the structure of the table and deletes a column during execution, then the results obtained by the query thread will definitely not match the table Structure.

3. MDL was introduced in MySQL version 5.5. When adding, deleting, modifying, and querying a table, add MDL read lock.

Add MDL write lock when making structural changes to the table.

Example

//session A:
begin;
select * from stu;
#commin;
 
//session B:
alter table stu add t1 int;
 
//session C:
show processlist;
Copy after login

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

Related labels:
source:yisu.com
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