Computer >> 컴퓨터 >  >> 프로그램 작성 >> MySQL

열에 주석을 추가하기 위해 MySQL ALTER TABLE 명령을 어떻게 사용할 수 있습니까?

<시간/>

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)