Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 482
Sai Sai Avatar asked Dec 10 '25 11:12

Sai Sai


1 Answers

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

like image 68
kmoser Avatar answered Dec 13 '25 08:12

kmoser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!