如何將註釋放入現有 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)

更新於:29-1 月 -2020

3K+ 瀏覽

開啟您的 事業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.