homepage Welcome to WebmasterWorld Guest from 54.227.11.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Copy added fields from one database table to another database table
Can anyone advise?
tongpo




msg:4528480
 6:47 pm on Dec 15, 2012 (gmt 0)

Ok I have two databases. They hold similar data. So I have database one and database two.

They both have the same table strucutre with identical tablenames but contain similar but not identical data.

I have added a fseveral fields to database1.tablename and these are now filled with relevant data.

Is there a way I can copy the new structure of database1.tablename(s) to database2.tablename(s) without altering, addding or in any other way shape or form modifying any data the tables contain. Without doing it manually of course.

I simply want to copy the new structure of database1.tablename(s) to database2.tablename(s) - no data. There are several tables this needs to be done for so doing it manually is going to be very tedious.

ANy suggestions? Is this possible?

They are MYSql databases btw

TIA

 

mack




msg:4529955
 4:45 pm on Dec 20, 2012 (gmt 0)

If there are similarities between the tables that might be a good starting point. Even better if both tables share at least one piece of unique data. It would be perfect if both tables shared an ID field where the values matched up.


You could then do something like...

Select * from table
get the col values
insert data into table 2 where the ID matched.

Mack.

tongpo




msg:4530163
 1:57 pm on Dec 21, 2012 (gmt 0)

Thanks for the reply. None of the tables hold any identical data between one and another. I don't want to transfer any data. They both hold similar data. Its just that I've added a couple of columns to one table in database1. I know need to replicate the structure of this table to the rest of the tables in this database and all of the tables in the other database, without altering existing data in any of them. Simply just add the new columns of one table (without data) to the rest of the tables and all tables in the other database. As easy n quickly as poss.

mack




msg:4530171
 3:29 pm on Dec 21, 2012 (gmt 0)

If you are using phpmyadmin I believe you can export a table (rather than a full database) but in the export form select only structure (not data) then open the table you want to export the structure to, open the sql box and drop in your exported sql from the old table.

I would be temped to clone the database and try this process on the clone to ensure it works as planned.

Backup first :)

Mack.

tongpo




msg:4530425
 12:01 pm on Dec 22, 2012 (gmt 0)

If you are using phpmyadmin I believe you can export a table (rather than a full database) but in the export form select only structure (not data) then open the table you want to export the structure to, open the sql box and drop in your exported sql from the old table.

I would be temped to clone the database and try this process on the clone to ensure it works as planned.

Backup first :)


Thanks. I will try that. Havent got round to it yet. Busy busy busy working on other things.

Yes I think thats prob one of the first few lessons I learned. Back up, back up, back up. Once bitten twice shy lol

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved