如何使用percona修改表以允许空值。
pt-online-schema-change --modfiy mycolumn default null d=database, t=table我看到了--alter,但没有修改现有列。
发布于 2018-02-03 01:46:48
首先,您不必使用pt-online-schema-change来实现这一点,因为您可以在原生SQL中做到这一点(尽管您可能有理由询问如何使用pt-online-schema-change)
对于此表:
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(40)
) ENGINE=InnoDB;您可以使用以下SQL:
ALTER TABLE `test`.`t1` CHANGE COLUMN name name VARCHAR(40) NULL;但是,接下来,如果您有充分的理由使用pt-online-schema-change,例如,如果表非常大,则语法如下:
pt-online-schema-change h=127.0.0.1,P=3306,u=user,p=password,D=test,t=t1 --alter "CHANGE COLUMN name name VARCHAR(40) NULL" --execute以下是该工具的文档https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html的链接
https://stackoverflow.com/questions/48587393
复制相似问题