Quote:
Originally Posted by Fredde87
To summerize, I basically want a easy way to generate a big SQL statement which will update my tables. It should in other words add a new column if the column does not exist in the current database or update it if it has changed but still keep the data intackt.
|
That is exactly what you should do, and I am afraid there is no easy shortcut.
In my experience the best thing to do: I assume you have a development version of your MySQL database, or a test environment or you simply perform tests and changes on a copy of your database.
Create a file, say delta.sql.
In your test version you make the alter table statement. If it is succesful, copy it from the terminal and paste it in your delta.sql. Once it is complete, try it on a backed up copy of your live version:
mysql -u user -ppasswd databasename < delta.sql
That does it.
jlinkels