SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Mr. Ram's Avatar
    Join Date
    Nov 2005
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Thumbs up How to append old data in MySQL

    My application is working with MySQL database. Bz of Disk crash, we lost DataBase data. We have application backup. Temporarily, we made application is ready with empty DataBase. Now, users are working with the application.
    In future, if we get the old data from crashed disk, is it possible to append the old db data to the existing new db data without over-write/replace. Bz, we used primary keys.
    Pls give me some idea/commands to do the process simple.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,328
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    depends on what kind of primary keys

    if you have auto_increment numbers, and you created your empty database with new numbers beginning with 1, then you will surely need to renumber the keys from the old backup
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    or renumber the keys of the new data.

  4. #4
    SitePoint Zealot Mr. Ram's Avatar
    Join Date
    Nov 2005
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Ofcourse, I can do it. But, I am using them as foreign keys in some other tables.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,328
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    are the keys based upon an auto_increment key?

    if so, find the highest value in the new database, round up to the nearest 10000 or something, then add than rounded-up value to every key in the tables you're restoring, PKs and FKs alike, while inserting
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •