Home >Database >Mysql Tutorial >Can I Add or Modify Comments on MySQL Columns?
Question:
Can you add or modify comments on MySQL columns? The official documentation does not explicitly mention this feature.
Answer:
Yes, you can add or modify comments on MySQL columns using the ALTER TABLE statement.
For Column Comments:
To add or modify a comment on a specific column, use the following syntax:
ALTER TABLE <table_name> CHANGE <column_name> <column_name> <data_type> COMMENT '<comment>'
For example, to add a comment to the id column in the user table:
ALTER TABLE `user` CHANGE `id` `id` INT( 11 ) COMMENT 'id of user'
This will add the comment 'id of user' to the id column.
Note: The CHANGE clause is used to modify the column definition while preserving its existing data.
The above is the detailed content of Can I Add or Modify Comments on MySQL Columns?. For more information, please follow other related articles on the PHP Chinese website!