Hubcap Posted October 19, 2010 Posted October 19, 2010 How can I import just some of the fields from a newer backup database into the existing database. The complete database is less than 2 megs. 67 tables 4103 Queries
Guest Posted October 19, 2010 Posted October 19, 2010 Joe, Open the .sql using a code editor and find the tables/ data you wish to incorporate into the other database. Copy and paste that portion of the sql into the SQL QUERY TAB in phpmyadmin. Chris
MrPhil Posted October 20, 2010 Posted October 20, 2010 Fields or tables? It's easy to import selected tables from a backup... just use an editor to snip out everything else, leaving only the DROP TABLE, CREATE TABLE, and INSERT for those tables. However, first make sure that the old and new table structure definitions are the same, or that you can account for the differences. You also want to determine whether there are other tables with pointers to records in the tables you are replacing -- you have to keep your data in sync (e.g., customer_id values used as the primary key in one table, with many other tables using that value to point back to the table). Updating specific fields is a lot tougher, because there may have been rows added or deleted (i.e., the number of available rows in the backup doesn't match the number of existing rows in the database). You would have to first find a way to match up your data with the existing database, and use something like UPDATE tablename SET fieldx='valuex', fieldy='valuey' WHERE fielda='valuea' AND fieldb='valueb'; Needless to say, it's a lot of work, and by the time you get through it, you might have spent less time just cutting and pasting values into phpMyAdmin's table editor. Not to mention that it will take a great deal of understanding of the data structure and usage to know which records to update and which backup fields go with which record. So, think long and hard about doing a partial database restore like this, and understand all the possible consequences!
Hubcap Posted October 20, 2010 Author Posted October 20, 2010 Thank you for the details, I thought there might have been an easier way. I keep earching and cannot find much or I'm searching for the wrong words Hubcap
Recommended Posts
Archived
This topic is now archived and is closed to further replies.