0

I am a newbie with MySQL database dumps and am currently trying to work with data migration between a source schema and a target schema.

Assuming the source schema is defined by (source_table_structure, source_data) and the target schema is defined by (target_table_structure, target_schema), the resultant schema that I am looking at is (target_table_structure, source_data_WithNewSize) where the source_data_WithNewSize is basically the same source schema data with additional columns values filled by NULL.

Is it possible to use MySQL workbench to perform this type of migration? Are there other tools that are optimized for such migration?

  • Doesn't sound like it would be a migration, but instead you only want the source data to be copied over to the target table, no? If so you could export your source data and then import it in the target table, ignoring duplicate key errors. – Mike Lischke Nov 7 '14 at 7:51
  • How do i export only my source data and import it to the target table? I currently use mysqldump -u root -p --tab=<dir> <database_name> to separate structure and data. Also, is it any different when multiple tables are involved? – lordlabakdas Nov 7 '14 at 16:04
0

There could be following two ways of doing the same.

First is you take unloads from source using following command

select * from table_name into outfile 'file_path' FIELDS TERMINATED BY ',' enclosed by '"' ;

Then on target you can do following

load data local infile 'file_path' into table table_name(Column_list_comma_seprated) FIELDS TERMINATED BY ',' enclosed by '"' escaped by '' ;

Or Else you can try following of inserting data

Replace into target_table(Column_list) select (Column_list) from source table;

Hope it helps.

  • Is there a way to follow this method but in the presence of multiple tables for a particular schema? – lordlabakdas Nov 7 '14 at 16:38
  • Would multiple replace into..statements doesn't solve the problem or can you elaborate your query? – Nawaz Sohail Nov 10 '14 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.