mysql bulk update table structures

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

mysql bulk update table structures

Post by JakeJ »

I'm having a surprisingly hard time finding the answer to this question but how do I do bulk updates of table structures.

I know how to use the alter command, but I need to know how to export my local table structure and import it in to my server without touching the data. I'm not seeing any way to do this with phpmyadmin. It will just create a table if it doesn't exist, but it won't add my extra fields.

Thanks
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: mysql bulk update table structures

Post by jaiswarvipin »

yes PHPMYSQL fdoes have feature only that are devided in tow step.

1) you have do on the database ans say "Export" and then it will ask you select that table and with data. So uncheck that option. and say go. IT will give you you all table create statement in that. Simply copy or save iun other file.
2) Now on destination table siply import the generated data and say go.

Done :)
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: mysql bulk update table structures

Post by JakeJ »

jaiswarvipin,

That doesn't work if the table already exists. It doesn't alter an existing table.

I think what I really need is a tool that can compare two database structures and build a series of ALTER statement from there.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: mysql bulk update table structures

Post by mikosiko »

JakeJ wrote: build a series of ALTER statement
there you go!!... but be careful if you changed your table structure drastically, because in that case you can face some problems.... if you only added fields you should be ok (attention with the NOT NULL's or referential integrity rules if you added some)
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: mysql bulk update table structures

Post by JakeJ »

Back to the original question. I want to do do bulk structural changes. I know how to use the ALTER statement already. What I need is a tool that will look at the structure of two databases and then create a series of ALTER statements so I can make database2 just like database1 without affecting the data inside.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: mysql bulk update table structures

Post by mikosiko »

never tried it myself... but maybe it could work for you

http://www.webyog.com/images/screenshot ... a_sync.png

and I do understand that MYSQL Workbench also have the database sync functionality
http://wb.mysql.com/?page_id=11
Post Reply