How to Delete a Column from a Table in SQL
The correct command to delete a column 'Category' from a table 'Products' is:
D. Alter table products drop column category
This command uses the ALTER TABLE statement with the DROP COLUMN clause. It specifies the table name ('products') and the column name ('category') to be removed.
Let's break down why the other options are incorrect:
- A. Alter table products delete column category: While
ALTER TABLEis used,DELETE COLUMNis not a valid SQL command for removing columns. - B. Alter table delete column category from product: The syntax is incorrect. The
FROMclause is unnecessary in this context. - C. None of them: This is incorrect, as option D provides the correct command.
原文地址: https://www.cveoy.top/t/topic/nwVf 著作权归作者所有。请勿转载和采集!