Home > Database > Mysql Tutorial > body text

How to Modify Column Comments in MySQL?

Barbara Streisand
Release: 2024-11-01 01:43:01
Original
619 people have browsed it

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';
Copy after login

For example:

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

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';
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!