Home >Database >Mysql Tutorial >How to Modify Column Comments in MySQL?

How to Modify Column Comments in MySQL?

Barbara Streisand
Barbara StreisandOriginal
2024-11-01 01:43:01682browse

How to Modify Column Comments in MySQL?

Modifying Column Comments in MySQL

To add or modify comments on columns in MySQL, use the following syntax:

ALTER TABLE table_name CHANGE column_name column_name data_type COMMENT 'comment text';

For example:

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

This command modifies the id column in the user table, adding the comment "id of user".

Note: The COMMENT clause can only be used when modifying the column definition, not when adding a new column. To add a comment to a new column, use the following syntax:

ALTER TABLE table_name ADD column_name data_type COMMENT 'comment text';

The above is the detailed content of How to Modify Column Comments in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn