Frage

I have 2 mysql databases, which have the same structure, but are from two different sites hosted on 2 different servers.

I would like to be able to select just some specific rows from table A(db 1), save them to my computer and then insert them into table A(db 2), which already has its own content which I would like to also keep in the db.

Until now I have tried to do this: I have selected and exported them to my computer, but when I try to insert them into table A (db2) I get an error message #1050 - Table 'A' already exists.

I don't want to replace the table A (db 2), I just want to add to it some info from table A (db 1), but also to keep the existing data.

How do I achieve this from the database side?

War es hilfreich?

Lösung

If you're using mysqldump to dump the database, use the --no-create-info option to prevent it from putting CREATE TABLE statements in the dump file.

Andere Tipps

I would just select columns_you_want from table A

Then I would use vim or (preferably) sed to format the results so that

name: 'smith'
country: 'usa'

becomes transformed into insert into tableB(name,country) values ('smith','usa')'

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top