I’m attempting to merge data from one MySQL database into another. The problem is, some of the tables in Source_DB have fields that the matching table in Target_DB does not have.
Is there a way to automatically ALTER the table in Target_DB to add these missing fields as they are found?
Or should I go about it another way, like doing a first pass where I compare each table to first add any missing fields?
You could query the
INFORMATION_SCHEMA.COLUMNSon each DB and figure out what’s missing with a NOT IN query and then using the data in theINFORMATION_SCHEMA.COLUMNSdynamically generate the DDL.Or you could use a tool like MySQL Compare to do it.