I wrote column comments in MySQL database replica made for testing. Now I need to copy these comments to production database. Since comments are stored in table COLUMNS of information_schema database, and information_schema is not writeable, what would be the way to go to copy comments across?
Test database version is 5.5.35 while production database is 5.1.71.
Is there any way to import these comments in production database other than enter them again?
Thank you
Maciej
Best Answer
You could use the INFORMATION_SCHEMA to sculpt the SQL commands for you.
Output this query to a text file and view the text file
If the output looks like what you need, then copy the script to the production server, login to mysql and run this to execute the script:
Give it a Try !!!
UPDATE 2014-04-04 16:34 EDT
It is a little harder to change each column definition's COMMENT. Why ???
According to the MySQL Documentation
You would have to express the entire column definition from scratch each time. Doing that is not only tedious but dangerous because it would just copy the data into a fresh temp table and rename the temp table afterwards.
ADDITIONAL WARNING : StackOverflow has this : https://stackoverflow.com/questions/2162420/alter-mysql-table-to-add-comments-on-columns
One of the comments on the accepted answer says : This solution can break the auto increments. – workdreamer Jul 31 '13 at 12:10
That's makes sense because of what I just said: The table get's copied, so there will be some auto_increment movement.