Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common execution methods of DDL in MySQL

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail about the common implementation of DDL in MySQL. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Operation support mode Allow Ripple W description

Add/create index online allows reading and writing when there is an FULLTEXT index on the table, the table needs to be locked and writes are blocked.

Add fulltext index in-place (version 5.6 and above) only supports reading, blocking and writing to create the first fulltext index on the table in copy table mode, unless there is a FTS_DOC_ID column on the table. After that, the fulltext index is created in in-place mode. After testing, 5.6 innodb implicitly adds FTS_DOC_ID columns automatically the first time, that is, 5.6 is all in in-place mode.

Drop index online allows you to read and write metadata without involving table data. So soon, you can rest assured to operate.

Optimize table online allows reading and writing when tables with fulltext index are in copy table mode and block writes

Alter table...engine=innodb online allows reading and writing when tables with fulltext index are in copy table mode and block writes

Add column online allows reading and writing (except adding self-increasing columns) 1. Add auto_increment columns to lock the table and block writes; 2. Although online is used, the table data needs to be reorganized, so adding columns is still an expensive operation

Drop column online allows reading and writing (except adding self-incrementing columns) with add column, reorganizing table data, expensive operations

Rename a column online allows you to read and write metadata; you cannot change the type of the column, otherwise the table is locked

Reorder columns online allows reading and writing to reorganize table data, expensive operations

Make column NOT NULL online allows reading and writing to reorganize table data, expensive operations

Change data type of column copy table only supports read, block write to create temporary tables, copy table data, expensive operations

Set default value for a column online allows read and write operations on metadata because the default value is stored in the frm file and does not involve table data. So soon, you can rest assured to operate.

Alter table xxx auto_increment=xx online allows you to read and write metadata without involving table data. So soon, you can rest assured to operate.

Add primary key online allows expensive operations to read and write

Convert character set copy table only supports read, blocking write if the new character set is different, you need to rebuild the table, expensive operation

This is the end of this article on "what are the common execution methods of DDL in MySQL?" I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report