Home >Database >Mysql Tutorial >How do we delete a column from a MySQL table?

How do we delete a column from a MySQL table?

WBOY
WBOYforward
2023-09-04 12:41:021671browse

How do we delete a column from a MySQL table?

To delete a column from a MySQL table, we can use the ALTER TABLE command and the DROP keyword. The syntax is as follows:

Alter Table table_name DROP Column Column_name;

Here is an example to demonstrate it

mysql> Alter table student drop column class;
Query OK, 5 rows affected (0.34 sec)
Records: 5 Duplicates: 0 Warnings: 0

The above query will delete the column name "class" from the "student" table.

The above is the detailed content of How do we delete a column from a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete