溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么理解MySQL 5.7 Online DDL Overview

發(fā)布時(shí)間:2021-11-16 09:29:38 來源:億速云 閱讀:194 作者:柒染 欄目:MySQL數(shù)據(jù)庫

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)怎么理解MySQL 5.7 Online DDL Overview,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。



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  

此列顯示哪些操作允許使用ALGORITHM=INPLACE子句?!癛ebuilds Table?”列顯示哪些操作可以重建表。對(duì)于使用就地算法的操作,表將就地重建。對(duì)于不支持就地算法的操作,使用表復(fù)制方法重新生成表。

“允許并發(fā)DML?”列顯示完全在線執(zhí)行的操作。您可以指定LOCK=NONE來斷言在DDL操作期間允許并發(fā)DML。MySQL在可能的情況下自動(dòng)允許并發(fā)DML。

在所有聯(lián)機(jī)DDL操作期間允許并發(fā)查詢。您可以指定LOCK=SHARED來斷言在DDL操作期間允許并發(fā)查詢。MySQL在可能的情況下自動(dòng)允許并發(fā)查詢。

“注釋”列提供附加信息,并解釋與其他列的“是/否”值相關(guān)的異常和依賴關(guān)系。星號(hào)表示異常或依賴項(xiàng)。

上述就是小編為大家分享的怎么理解MySQL 5.7 Online DDL Overview了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI