ALTERTABLE testingMODIFYidINTCOMMENT'idofemployees';QueryOK,0rowsaffected(0.07sec)Records:0Duplicates:0Warnings:0 by following query, you can check it in the comment field of the column."/> ALTERTABLE testingMODIFYidINTCOMMENT'idofemployees';QueryOK,0rowsaffected(0.07sec)Records:0Duplicates:0Warnings:0 by following query, you can check it in the comment field of the column.">

Home  >  Article  >  Database  >  How can we add comments on columns using MySQL ALTER TABLE command?

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

王林
王林forward
2023-09-13 22:21:081477browse

我们如何使用 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

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete