I need to add a new column to existing MySQL table and populate with value calculated from another column.
Is there a way to do this using pt-online-schema-change
?
Thanks
I need to add a new column to existing MySQL table and populate with value calculated from another column.
Is there a way to do this using pt-online-schema-change
?
Thanks
pt-online-schema change runs
ALTER TABLE
statements, notUPDATE
statements. If you need to populate a column you have two options:Add the column with pt-online-schema change. Then after that is complete, use UPDATE to populate the column with data. It is recommended to do the UPDATE in batches. For example, I'd run it on 1000 rows at a time, and repeat that until the UPDATE reports that you've changes 0 rows.
If you use MySQL 5.7 or later, define the column as a GENERATED column.