MySQL5.6 Online DDL 是否锁表、rebuild表、inplace的说明
admin
2023-05-18 02:02:01
0

Online DDL 是否锁表、是否rebuild表、inplace或copy算法的说明:

原文: https://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html?spm=5176.100239.blogcont64664.13.SpL8lH

OperationIn-Place?Rebuilds Table?Permits Concurrent DML?Only Modifies Metadata?Notes
CREATE INDEXADD INDEXYes*No*YesNoRestrictions apply for FULLTEXT indexes; see next row.
ADD FULLTEXT INDEXYes*No*NoNoAdding the first FULLTEXT index rebuilds the table if there is no user-defined FTS_DOC_ID column. Subsequent FULLTEXT indexes may be added on the same table without rebuilding the table.
DROP INDEXYesNoYesYesOnly modifies table metadata.
OPTIMIZE TABLEYes*YesYesNoPerformed in-place as of MySQL 5.6.17. In-place operation is not supported for tables withFULLTEXT indexes.
Set column default valueYesNoYesYesOnly modifies table metadata.
Change auto-incrementvalueYesNoYesNo*Modifies a value stored in memory, not the data file.
Add foreign key constraintYes*NoYesYesThe INPLACE algorithm is supported when foreign_key_checks is disabled. Otherwise, only theCOPY algorithm is supported.
Drop foreign key constraintYesNoYesYesforeign_key_checks can be enabled or disabled.
Rename columnYesNoYes*YesTo permit concurrent DML, keep the same data type and only change the column name.
Add columnYesYesYes*NoConcurrent DML is not permitted when adding an auto-increment column. Data is reorganized substantially, making it an expensive operation.
Drop columnYesYesYesNoData is reorganized substantially, making it an expensive operation.
Reorder columnsYesYesYesNoData is reorganized substantially, making it an expensive operation.
Change ROW_FORMATpropertyYesYesYesNoData is reorganized substantially, making it an expensive operation.
Change KEY_BLOCK_SIZEpropertyYesYesYesNoData is reorganized substantially, making it an expensive operation.
Make column NULLYesYes*YesNoRebuilds the table in place. Data is reorganized substantially, making it an expensive operation.
Make column NOT NULLYes*Yes*YesNoRebuilds the table in place. STRICT_ALL_TABLES or STRICT_TRANS_TABLES SQL_MODE is required for the operation to succeed. The operation fails if the column contains NULL values. As of 5.6.7, the server prohibits changes to foreign key columns that have the potential to cause loss of referential integrity. See Section 13.1.7, “ALTER TABLE Syntax”. Data is reorganized substantially, making it an expensive operation.
Change column data typeNoYesNoNoOnly supports ALGORITHM=COPY
Add primary keyYes*Yes*YesNoRebuilds the table in place. Data is reorganized substantially, making it an expensive operation.ALGORITHM=INPLACE is not permitted under certain conditions if columns have to be converted toNOT NULL.
Drop primary key and add anotherYesYesYesNoData is reorganized substantially, making it an expensive operation.
Drop primary keyNoYesNoNoOnly ALGORITHM=COPY supports dropping a primary key without adding a new one in the sameALTER TABLE statement.
Convert character setNoYes*NoNoRebuilds the table if the new character encoding is different.
Specify character setNoYes*NoNoRebuilds the table if the new character encoding is different.
Rebuild with FORCEoptionYes*YesYesNoUses ALGORITHM=INPLACE as of MySQL 5.6.17. ALGORITHM=INPLACE is not supported for tables withFULLTEXT indexes.
null rebuild usingALTER TABLE ... ENGINE=INNODBYes*YesYesNoUses ALGORITHM=INPLACE as of MySQL 5.6.17. ALGORITHM=INPLACE is not supported for tables withFULLTEXT indexes.
Set STATS_PERSISTENT,STATS_AUTO_RECALC,STATS_SAMPLE_PAGESpersistent statisticsoptionsYesNoYesYesOnly modifie

其余可参考文章: https://yq.aliyun.com/articles/64664


相关内容

热门资讯

联合国秘书长欢迎黎以延长停火 新华社联合国5月16日电(记者尚绪谦)联合国秘书长发言人办公室16日说,秘书长古特雷斯欢迎黎巴嫩与以...
如何让“彩礼”回归于“礼”?一... 黄河水浇灌出的宁夏红寺堡是中国最大的生态移民安置区,宁南八县的乡音在此交汇,对美好生活的期盼与发展中...
原创 外... 外星翻译官的翻车现场:地球语言真的太难了! 银河系翻译官协会(假想机构)最近发布了一份年度报告,总...
首飞成功!已突破大重量载荷发射... 科技日报记者 付毅飞 实习生 张城辉 记者从蓝箭航天获悉,5月14日11时0分,朱雀二号改进型遥五运...
京东携手MAXHUB共推AI智... PChome消息,近日,京东与智能会议平板领域领军品牌MAXHUB正式签署战略合作协议,标志着双方战...
29个智能气象站启动业务试运行 本报北京5月15日电(记者李红梅)记者从中国气象局获悉:北京密云等29个智能气象站已于近日启动业务试...
广西一载15人车辆坠河,10人... 记者从广西环江毛南族自治县相关方面获悉,据初步了解,5月16日21时30分许,一辆汽车在环江县洛阳镇...
iOS 26.5更新苹果地图两... 苹果地图是iOS 26.5此次更新中获得新功能的应用之一。以下是地图用户需要了解的最新变化。 推荐...
每经热评 | 黄仁勋喝蜜雪冰城... 每经评论员 朱成祥 黄仁勋近期到访北京,被拍到在胡同喝豆汁、吃炸酱面、举着蜜雪冰城饮料。他表情轻松,...
我省3项目被列入工信部先进计算... 本报太原5月15日讯(记者王蕾)近日,工业和信息化部公布了2025年先进计算赋能新质生产力典型应用案...