对于超过 4000 万行的 table 大小,如何向 MySQL 中的 ENUM 类型列添加更多成员?

How do I add more members to my ENUM-type column in MySQL for a table size of more than 40 million rows?

我的 table 大小为 4000 万行,我希望修改 table Aurora MySQL RDS 数据库 V5.6.10 的枚举列以添加更多。这个 table 是一个经常更新的。有没有人曾经尝试过改变这样的 tables ?如果有,能否请您详细说明一下体验?

Table结构:

CREATE TABLE `tee_sizes` (
id bigint auto_increment,
customer_id bigint,
tee-size enum('small', 'large', 'x-large'),
created_at  timestamp NOT NULL default CURRENT_TIMESTAMP(),
updated_at  timestamp NOT NULL default CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP(),
PRIMARY KEY(id)
) ENGINE=InnoDB AUTO_INCREMENT=36910751 DEFAULT CHARSET=utf8;

我希望将 'xx-large' 添加到 T 恤尺寸列中。

执行此操作时会停机吗?

MySQL 5.6 应该允许 InnoDB online DDL 没有 任何停机 table 并且并发查询应该仍然可以在 table 同时改变。

   ALTER TABLE tee_sizes MODIFY COLUMN `tee-size` enum('small', 'large', 'x-large', 'new-item'),
   ALGORITHM=INPLACE, LOCK=NONE;

ALGORITHM=INPLACE, LOCK=NONE 会强制 MySQL 在 请求的并发级别 没有 停机时间。
如果您的 MySQL 版本未执行,则请求的并发级别不可用,这意味着 ALGORITHM=INPLACE, LOCK=NONE 需要更改。

demo

因评论而编辑:

Wait.. So, does this force any locks? ALGORITHM=INPLACE, LOCK=NONE would force MySQL in executing (if allowed) without downtime if your MySQL does not execute it means it can't be done using ALGORITHM=INPLACE, LOCK=NONE This statement is confusing.

不,它不会从 manual

锁定 copy/paste

You can control aspects of a DDL operation using the ALGORITHM and LOCK clauses of the ALTER TABLE statement. These clauses are placed at the end of the statement, separated from the table and column specifications by commas. .. To avoid accidentally making the table unavailable for reads, writes, or both, specify a clause on the ALTER TABLE statement such as LOCK=NONE` (permit reads and writes) or LOCK=SHARED (permit reads). The operation halts immediately if the requested level of concurrency is not available.