Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: open

Message Too Old, No Replies

Copy added fields from one database table to another database table

Can anyone advise?

     

tongpo

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

10+ Year Member



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

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

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

10+ Year Member



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

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

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

10+ Year Member



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month