Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

วิธีเพิ่มคำอธิบาย (Comment) ให้คอลัมน์ในตาราง MySQL

ใช้คีย์เวิร์ด COMMENT ขณะ MODIFY คอลัมน์ด้วย ALTER TABLE:

mysql> ALTER TABLE testing MODIFY id INT COMMENT 'id of employees';
Query OK, 0 rows affected (0.07 sec)

ตรวจสอบด้วย SHOW FULL COLUMNS:

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: 

คำอธิบายจะปรากฏในฟิลด์ Comment ช่วยให้ทีมทำงานเข้าใจความหมายของคอลัมน์