ALTER TABLE without locking the table?

后端 未结 19 2013
梦毁少年i
梦毁少年i 2020-11-30 17:41

When doing an ALTER TABLE statement in MySQL, the whole table is read-locked (allowing concurrent reads, but prohibiting concurrent writes) for the duration of the statement

19条回答
  •  伪装坚强ぢ
    2020-11-30 18:10

    Nope. If you are using MyISAM tables, to my best understanding they only do table locks - there are no record locks, they just try to keep everything hyperfast through simplicity. (Other MySQL tables operate differently.) In any case, you can copy the table to another table, alter it, and then switch them, updating for differences.

    This is such a massive alteration that I doubt any DBMS would support it. It's considered a benefit to be able to do it with data in the table in the first place.

提交回复
热议问题