To eliminate a column from table we use drop command. Suppose we have table employee with an extra field Address and we want to eliminate this.
| create table student(id int(11) NOT NULL AUTO_INCREMENT, name varchar(40), address varchar(40), PRIMARY KEY(id)); |
| mysql> desc student; +---------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(40) | YES | | NULL | | | address | varchar(40) | YES | | NULL | | +---------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) |
To remove this column we use Drop query. Syntax:
| ALTER TABLE table_name drop column_name; |
| ALTER TABLE student drop address; |
| mysql> desc student; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(40) | YES | | NULL | | +-------+-------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) |
Read More How to create a table in MySql