MySQL 5.7 Online DDL Overview
Operation | In-Place? | Rebuilds Table? | Permits Concurrent DML? | Only Modifies Metadata? | Notes |
---|---|---|---|---|---|
CREATE INDEX, ADD INDEX | Yes* | No* | Yes | No | Restrictions apply for FULLTEXT indexes; see next row. |
ADD FULLTEXT INDEX | Yes* | No* | No | No | Adding 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. |
ADD SPATIAL INDEX | Yes | No | No | No | |
RENAME INDEX | Yes | No | Yes | Yes | Only modifies table metadata. |
DROP INDEX | Yes | No | Yes | Yes | Only modifies table metadata. |
OPTIMIZE TABLE | Yes* | Yes | Yes | No | In-place operation is not supported for tables with FULLTEXT indexes. |
Set column default value | Yes | No | Yes | Yes | Only modifies table metadata. |
Change auto-incrementvalue | Yes | No | Yes | No* | Modifies a value stored in memory, not the data file. |
Add foreign key constraint | Yes* | No | Yes | Yes | The INPLACE algorithm is supported when foreign_key_checks is disabled. Otherwise, only theCOPY algorithm is supported. |
Drop foreign key constraint | Yes | No | Yes | Yes | foreign_key_checks can be enabled or disabled. |
Rename column | Yes* | No | Yes* | Yes | To permit concurrent DML, keep the same data type and only change the column name.ALGORITHM=INPLACE is not supported for renaming a generated column. |
Add column | Yes* | Yes* | Yes* | No | Concurrent DML is not permitted when adding an auto-increment column. Data is reorganized substantially, making it an expensive operation. ALGORITHM=INPLACE is supported for adding a virtual generated column but not for adding a stored generated column. Adding a virtual generated column does not require a table rebuild. |
Drop column | Yes | Yes* | Yes | No | Data is reorganized substantially, making it an expensive operation. ALGORITHM=INPLACE is supported for dropping a generated column. Dropping a virtual generated column does not require a table rebuild. |
Reorder columns | Yes | Yes | Yes | No | Data is reorganized substantially, making it an expensive operation. |
Change ROW_FORMATproperty | Yes | Yes | Yes | No | Data is reorganized substantially, making it an expensive operation. |
Change KEY_BLOCK_SIZEproperty | Yes | Yes | Yes | No | Data is reorganized substantially, making it an expensive operation. |
Make column NULL | Yes | Yes* | Yes | No | Rebuilds the table in place. Data is reorganized substantially, making it an expensive operation. |
Make column NOT NULL | Yes* | Yes | Yes | No | Rebuilds 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. The server prohibits changes to foreign key columns that have the potential to cause loss of referential integrity. SeeSection 13.1.8, “ALTER TABLE Syntax”. Data is reorganized substantially, making it an expensive operation. |
Change column data type | No* | Yes | No | No | VARCHAR size may be increased using online ALTER TABLE. See Modifying Column Properties for more information. |
Add primary key | Yes* | Yes* | Yes | No | Rebuilds 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 another | Yes | Yes | Yes | No | Data is reorganized substantially, making it an expensive operation. |
Drop primary key | No | Yes | No | No | Only ALGORITHM=COPY supports dropping a primary key without adding a new one in the same ALTER TABLE statement. |
Convert character set | No | Yes* | No | No | Rebuilds the table if the new character encoding is different. |
Specify character set | No | Yes* | No | No | Rebuilds the table if the new character encoding is different. |
Rebuild with FORCE option | Yes* | Yes | Yes | No | Uses ALGORITHM=INPLACE. ALGORITHM=INPLACE is not supported for tables with FULLTEXT indexes. |
“null” rebuild using ALTER TABLE ... ENGINE=INNODB | Yes* | Yes | Yes | No | Uses ALGORITHM=INPLACE. ALGORITHM=INPLACE is not supported for tables with FULLTEXT indexes. |
Set STATS_PERSISTENT,STATS_AUTO_RECALC,STATS_SAMPLE_PAGESpersistent statistics options | Yes | No | Yes | Yes | Only modifies table metadata. |
ALTER TABLE … ENCRYPTION | No | Yes | No | Yes | |
Drop a STORED column | Yes | Yes* | Yes | No | Rebuilds the table in place. |
Modify STORED column order | Yes | Yes* | Yes | No | Rebuilds the table in place. |
Add a STORED column | Yes | Yes* | Yes | No | Rebuilds the table in place. |
Drop a VIRTUAL column | Yes | No | Yes | Yes | |
Modify VIRTUAL column order | Yes | No | Yes | Yes | |
Add a VIRTUAL column | Yes | No | Yes | Yes |
-
The “In-Place?” column shows which operations permit the ALGORITHM=INPLACE clause.
-
The “Rebuilds Table?” column shows which operations rebuild the table. For operations that use the INPLACE algorithm, the table is rebuilt in place. For operations that do not support the INPLACE algorithm, the table copy method is used to rebuild the table.
-
The “Permits Concurrent DML?” column shows which operations are performed fully online. You can specify LOCK=NONE to assert that concurrent DML is permitted during the DDL operation. MySQL automatically permits concurrent DML when possible.
Concurrent queries are permitted during all online DDL operations. You can specify LOCK=SHARED to assert that concurrent queries are permitted during a DDL operation. MySQL automatically permits concurrent queries when possible.
-
The “Notes” column provides additional information and explains exceptions and dependencies related to the “Yes/No” values of other columns. An asterisk indicates an exception or dependency.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2144287/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7 online DDL特性介紹MySql
- MySQL Online DDL 概述MySql
- Limitations of Online DDL for MySQLMITMySql
- mysql online ddl的演化MySql
- MySQL Online DDL詳解MySql
- MySQL DDL執行方式-Online DDL介紹MySql
- MySQL5.7 InnoDB線上DDL操作MySql
- MySQL 5.6 Online DDL.mdMySql
- mysql之 openark-kit online ddlMySql
- 【MySQL】online ddl 思維導圖MySql
- MySQL online ddl 工具之pt-online-schema-changeMySql
- MySQL Online DDL--pt-online-change-schema測試MySql
- 【MySQL】online ddl 工具之pt-online-schema-changeMySql
- MySQL & MariaDB Online DDL 參考指南MySql
- MySQL ONLINE DDL 和PT-ONLINE-SCHEMA-CHANGE對比MySql
- mysql5.6的online ddl功能測試MySql
- MySQL5.6支援哪些Online DDL操作MySql
- MySQL Online DDL的實現細節介紹MySql
- MySQL5.6 Online DDL線上狀態總結MySql
- MySQL Online DDL導致全域性鎖表案例分析MySql
- 一個 MySQL 線上 DDL 工具 — pt-online-schema-changeMySql
- MySQL 執行 Online DDL 操作報錯空間不足?MySql
- MySQL 5.6版本哪些操作可以進行online DDLMySql
- MySQL Online DDL(二)(r11筆記第88天)MySql筆記
- MySQL在其版本迭代後Online DDL功能發生了哪些變化?MySql
- MySQL 5.7使用pt-online-schema-change對大表加索引MySql索引
- MySQL 8.0 Reference Manual(讀書筆記81節-- InnoDB and Online DDL (1))MySql筆記
- MySQL 8.0 Reference Manual(讀書筆記82節-- InnoDB and Online DDL (2))MySql筆記
- MySQL 8.0 Reference Manual(讀書筆記83節-- InnoDB and Online DDL (3))MySql筆記
- MySQL 8.0 Reference Manual(讀書筆記84節-- InnoDB and Online DDL (4))MySql筆記
- MySQL 5.7使用pt-online-schema-change對大表加欄位MySql
- 記錄一次 Online DDL 操作
- An Overview of PostgreSQL & MySQL Cross ReplicationViewMySqlROS
- 【MySQL】MySQL 5.7 初探MySql
- MySQL DDL操作表MySql
- MySQL 5.7新特性MySql
- 使用Docker Mysql 5.7DockerMySql
- Docker 部署 MySQL 5.7DockerMySql