开发者

Alter table with multiple modify column VS Alter table query with single column

I have huge table with 1 million records, i wou开发者_开发知识库ld like to modify some of the text columns to varchar column. Which is the best way to modify the columns.

  1. Alter table query with all modify columns
  2. Alter table queries with single modify column.


Definitely variant 1, because, as stated in the MySQL documentation,

In most cases, ALTER TABLE makes a temporary copy of the original table. MySQL waits for other operations that are modifying the table, then proceeds. It incorporates the alteration into the copy, deletes the original table, and renames the new one.

So, it's better to have a single copy/wait for operations/delete old table/rename new one operation than multiple ones.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜