To remove a column from a table, we have to use the ALTER TABLE
statement.
The ALTER TABLE
statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE
statement is also used to add and drop various constraints on an existing table.
We want to remove the column named color
from the cars
table.
To remove a column, use the DROP COLUMN
statement:
Remove the color
column:
ALTER TABLE cars
DROP COLUMN color;
ALTER TABLE
To check the result we can display the table with this SQL statement:
As you can see in the result, the color
column has been removed from the cars
table.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!