Merge Two Databases into one
Date: Tue, 28 Oct 2014 09:08:35 -0700 (PDT)
Message-ID: <153f4c59-3611-4071-868a-b34708bf67d4_at_googlegroups.com>
Hi all,
I want to append my data's from old_db in to the new_db In new_db the table exists and has data already and I am trying to insert old_db data's(rows) also maintaining foreign key.
This is my table
-old_db tables
#address table
id address
1 old_street1
2 old_street2
#name table
id Name fk_address_id
1 foo1 1
2 foo2 2
3 foo3 2
-new_db tables:
#address table
id address
1 new_street1
2 new_street2
#name table
id Name fk_address_id
1 bar1 2
2 bar2 1
3 bar3 2
trying to insert old_db in to the new_db like this
#address table
id address
1 new_street1 2 new_street2 3 old_street1 4 old_street2
#name table
id Name fk_address_id
1 bar1 2
2 bar2 1
3 bar3 2
4 foo1 3
5 foo2 4
6 foo3 4
I am trying this
Dump the old_db using --no-create-info and then load it to
the new_db from the command line.
I am getting this error:
I am new to MySQL
what do you think would be the best solution for my problem?
MySQL Version -5.5
Thanks,
>>>mysql -u -p new_db < old_db.sql
"ERROR 1062 (23000) at line 51: Duplicate entry '1' for key 'PRIMARY'"
because I have a column(id) with unique entries
Ram Ganesh K