25
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQL5.6にしたのに、Online DDLできない

Last updated at Posted at 2014-12-04

結論

Online DDLできない制約にひっかかってた

InnoDB tables created before MySQL 5.6 do not support ALTER TABLE ... ALGORITHM=INPLACE for tables that include temporal columns (DATE, DATETIME or TIMESTAMP) and have not been rebuilt using ALTER TABLE ... ALGORITHM=COPY. In this case, an ALTER TABLE ... ALGORITHM=INPLACE operation returns the following error:

ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported.
Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

Ref.

意訳

  • 5.6より前に作ったテーブル
    • DATE DATETIME TIMESTAMPカラムが存在する
    • ALGORITHM=COPYでrebuildされていない (5.6にしてから一度もALTER TABLEしていない)
  • ALGORITHM=INPLACEできない
  • 言い換えれば、ALGORITHM=COPYが必須であり、書込ロックがかかる
    • LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED.

メモ

  • ALTER TABLE table_name ... LOCK=NONEとすれば、Online DDLできないときはエラー出るので確認に有用
  • MySQL 5.5から移行した理由が、Online DDLしたかったからなのに出来ないジレンマ \(^o^)/
  • ALGORITHM=COPYALTER TABLEすれば、次回からはOnline DDLできる
25
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?