Problem:
You want to remove a column from a table.
Example:
We would like to delete the column description
from the table product
.
Solution:
ALTER TABLE product DROP COLUMN description; |
Discussion:
SQL provides the ALTER TABLE
statement to change the structure of a table. If you’d like to remove a column from a table, use this statement.
First, write ALTER TABLE
, followed by the name of the table you want to change (in our example, product
). Next add the DROP COLUMN
clause, followed by the name of the column you want to remove (in our example, description
). This removes the column from the table, including any data stored in it.
No comments:
Post a Comment