Sai Sai
Sai Sai

Reputation: 41

How to safely modify a lot of MySQL column comments?

In our current database, We have a lot of tables without a comment on the column. We would like to add comments to columns, but

 ALTER TABLE `user` CHANGE `id` `id` INT( 11 ) COMMENT 'id of user'  

will change the column data schema,too.

We are afraid that with so many changes, a mistake would be made and the data schema would be accidentally altered.

What would be the best way to insert the comments with no change to the data schema ?

Upvotes: 3

Views: 2107

Answers (1)

kmoser
kmoser

Reputation: 9273

This script creates the required ALTER TABLE statements. After running it, change the comments descriptions, then run those ALTER TABLE statements.

https://stackoverflow.com/a/17791564/378779

Upvotes: 1

Related Questions