Home > Database > Mysql Tutorial > body text

How can we add comments on columns using MySQL ALTER TABLE command?

王林
Release: 2023-09-13 22:21:08
forward
1484 people have browsed it

我们如何使用 MySQL ALTER TABLE 命令在列上添加注释?

We can use the "COMMENT" keyword with the ALTER TABLE command to add comments on the column while modifying the column. For example, if we want to add a comment in the "id" column of the table "testing", the following query will do this -

mysql> ALTER TABLE testing MODIFY id INT COMMENT 'id of employees';
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0
Copy after login

With the following query, we can check it in the comment field of the column.

mysql> Show full columns from testing\G
*************************** 1. row ***************************
     Field: id
      Type: int(11)
 Collation: NULL
      Null: NO
       Key: PRI
   Default: 0
     Extra:
Privileges: select,insert,update,references
   Comment: id of employees
*************************** 2. row ***************************
     Field: Name
      Type: varchar(20)
 Collation: latin1_swedish_ci
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
2 rows in set (0.05 sec)
Copy after login

The above is the detailed content of How can we add comments on columns using MySQL ALTER TABLE command?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template