
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Drop Existing Column from a MySQL Table
We can delete a particular existing column from a MySQL table by using the DROP statement along with an ALTER statement. Its syntax would be as follows −
Syntax
ALTER TABLE table_name DROP column_name;
Here, table_name is the name of the table from which we want to delete the column.
Column_name is the name of the column which is to be deleted from the table.
Example
In this example, we are deleting the column ‘address’ from table ‘student_detail’ as follows −
mysql> select * from student_detail; +-----------+-------------+----------+ | Studentid | StudentName | address | +-----------+-------------+----------+ | 100 | Gaurav | Delhi | | 101 | Raman | Shimla | | 103 | Rahul | Jaipur | | 104 | Ram | Ludhiana | | 105 | Mohan | Patiala | +-----------+-------------+----------+ 5 rows in set (0.19 sec) mysql> ALTER TABLE student_detail DROP address; Query OK, 0 rows affected (1.43 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from student_detail; +-----------+-------------+ | Studentid | StudentName | +-----------+-------------+ | 100 | Gaurav | | 101 | Raman | | 103 | Rahul | | 104 | Ram | | 105 | Mohan | +-----------+-------------+ 5 rows in set (0.00 sec)
The above result set shows that column ‘address’ has been deleted from the table.
Advertisements