MySQL 如何在现有 MySQL 表的列中添加注释?
使用 ALTER TABLE 命令并使用 “COMMENT” 关键字即可完成。例如,如果我们想在表 “testing” 的列 “id” 中添加注释,则以下查询会完成此操作:
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
可通过以下查询检查列的注释字段。
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)
阅读更多:MySQL 教程