mysql8,快速添加列

copy

inplace

pt-osc

gh-ost

instant

数据读取

允许

允许

允许

允许

允许

数据写入

不允许

允许

允许

允许

允许

MDL

需要

需要

需要

需要

需要

执行时间

非常长

同步延迟

非常大

MySQL 8.0.12 中,如下 Alter 操作已经默认使用了 instant 算法:

  • 添加列
  • 不支持删除普通列
  • 添加或者删除一个虚拟列
  • 添加或者删除一个列的默认值
  • 修改 ENUM 或者 SET 列的定义
  • 变更索引的类型(B 树,哈希)
  • 使用 alter 语法重命名表

alter table user add column test varchar(128),algorithm=copy;

alter table user drop column test,algorithm=copy;

alter table user  add column test varchar(128),algorithm=inplace;

alter table user drop column test,algorithm=inplace;

alter table user add column test varchar(128),algorithm=instant;

你可能感兴趣的:(数据库,sql)