Percona Toolkit在线架构更改:可以一​​次添加多个列吗?

eva*_*anv 2 mysql sql database-schema percona

有没有人知道是否可以使用Percona的pt-online-schema-change为MySQL一次添加多个列?我已经尝试过每个我能想到的变体,以便一次添加多个列.这似乎是你应该能够做的事情,但我无法在网上找到任何可以证明的证据,也无法找到合理的语法.我尝试过的一些陈述如下,让你知道我尝试了什么(用户名和密码已被删除,原因很明显)

声明1:

    pt-online-schema-change --print --progress time,5 --max-load Threads_running=1000 
--critical-load Threads_running=10000 --chunk-time 5 --set-vars "innodb_lock_wait_timeout=600" 
--nocheck-plan --execute -h webdb -u xxxx --p xxxx --alter "ADD first_seen datetime NOT NULL 
DEFAULT 0, last_seen datetime NOT NULL DEFAULT 0 AFTER days_running"  D=mydata,t=mytable
Run Code Online (Sandbox Code Playgroud)

声明2:

    pt-online-schema-change --print --progress time,5 --max-load Threads_running=1000 
--critical-load Threads_running=10000 --chunk-time 5 --set-vars "innodb_lock_wait_timeout=600" 
--nocheck-plan --execute -h webdb -u xxxx --p xxxx --alter "ADD first_seen datetime NOT NULL 
DEFAULT 0, ADD last_seen datetime NOT NULL DEFAULT 0 AFTER days_running"  D=mydata,t=mytable
Run Code Online (Sandbox Code Playgroud)

声明3:

 pt-online-schema-change --print --progress time,5 --max-load Threads_running=1000 
--critical-load Threads_running=10000 --chunk-time 5 --set-vars "innodb_lock_wait_timeout=600" 
--nocheck-plan --execute -h webdb -u xxxx --p xxxx --alter "ADD first_seen datetime NOT NULL 
DEFAULT 0 AFTER days_running, ADD last_seen datetime NOT NULL DEFAULT 0 AFTER days_running"  
D=mydata,t=mytable
Run Code Online (Sandbox Code Playgroud)

等等.基本上我已经尝试了我能想到的每个变体ADD first_seen datetime NOT NULL DEFAULT 0,ADD last_seen datetime NOT NULL DEFAULT 0 after days_running"(移动/移除后,移动/移除ADD,移动/移除逗号等等) )

Ike*_*ker 8

根据手册,这是可能的,只需用逗号分隔语句.引用--alter手册的部分:

- 改变

type: string

The schema modification, without the ALTER TABLE keywords. You can perform 
multiple modifications to the table by specifying them with commas. Please 
refer to the MySQL manual for the syntax of ALTER TABLE.
Run Code Online (Sandbox Code Playgroud)

在你的情况下这--alter应该工作(假设你的陈述的其余部分是正确的):

--alter "ADD first_seen datetime NOT NULL DEFAULT 0, ADD last_seen datetime NOT NULL DEFAULT 0 AFTER days_running"
Run Code Online (Sandbox Code Playgroud)