Adding and Modifying Column Comments in MySQL Tables
When modifying or creating tables using the ALTER TABLE command, MySQL users may encounter the need to add or alter comments associated with specific columns. While the ALTER TABLE documentation does not explicitly indicate a method for managing column comments, a solution exists.
Column Comment Alteration
To add or modify a comment for a specific column within a table, use the CHANGE clause in the ALTER TABLE command. The following syntax outlines the process:
<code class="sql">ALTER TABLE table_name CHANGE column_name new_column_name data_type COMMENT 'new comment';</code>
For example:
<code class="sql">ALTER TABLE user CHANGE id id INT(11) COMMENT 'id of user';</code>
By implementing this syntax, you can effortlessly attach or update comments to columns in your MySQL tables, facilitating information management and enhancing your database architecture.
The above is the detailed content of How do I Add or Modify Column Comments in MySQL Tables?. For more information, please follow other related articles on the PHP Chinese website!