#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    46
    Rep Power
    2

    How to import sql file and force update tables?


    Hello,

    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?
    $0.5 Hosting on cPanel
    $4 VPS; $30 Dedi
    InstantcPanelHosting.com
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    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

IMN logo majestic logo threadwatch logo seochat tools logo