MySQL 테이블 컬럼 삭제

1 개요[ | ]

MySQL 컬럼 삭제
ALTER TABLE `테이블명` DROP `컬럼명`;

2 예시[ | ]

mysql> DESC employee;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| id            | int(11)      | NO   | PRI | NULL    |       |
| name          | varchar(16)  | NO   |     | NULL    |       |
| department_id | int(11)      | NO   |     | NULL    |       |
| comments      | varchar(200) | NO   |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> ALTER TABLE `employee` DROP `comments`;
Query OK, 4 rows affected (0.06 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> DESC employee;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| id            | int(11)     | NO   | PRI | NULL    |       |
| name          | varchar(16) | NO   |     | NULL    |       |
| department_id | int(11)     | NO   |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}