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
Release: 2023-09-04 12:41:02
forward
1647 people have browsed it

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;
Copy after login

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
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template