February 27th, 2014, 04:02 AM
How to import sql file and force update tables?
i have mysql database with default tables and default data and i also have second database which contains new data.
I want to add this new data into default database.
I mean when i import new database .sql file, data are not aded becasue tables exist
please how can i
1) replace all data by imported data
2) add only data that dont exist in tables
possibly without doing new mysql export? If new export is required, please how the command will look like so it supports update?
February 27th, 2014, 10:12 AM
The export .sql file is plain text, as big as it may be. Either edit oit the create tabel commands, or add IF NOT EXISTS before the table name.
As for not inserting duplicates esnure you have a unique key defined what whatever column(s) define what a duplicate is and add IGNORE to the INSERT clause.
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc