首页 > 文章列表 > 我们如何从MySQL表中删除一列?

我们如何从MySQL表中删除一列?

125 2023-08-30

要从MySQL表中删除列,我们可以使用ALTER TABLE命令和DROP关键字。语法如下:

Alter Table table_name DROP Column Column_name;

以下是一个示例来演示它

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

上面的查询将从“student”表中删除列名“class”。