CodeBlanks Logo Icon CodeBlanks

Dropping a column

Remove a column with DROP COLUMN.

Dropping a column

With DROP COLUMN you remove a column from a table. The column data is deleted.

ALTER TABLE products
DROP COLUMN stock;

This query removes the stock column.

Dropping a column — details

DROP COLUMN cannot be undone. All data in the column is lost. Backup before using it.

For example, ALTER TABLE customers DROP COLUMN fax permanently deletes every stored fax number.

Practice Dropping a column

Drop the stock column from products.

Starter code

query.sql
-- drop column
ALTER TABLE products

Sample solution

query.sql
ALTER TABLE products
DROP COLUMN stock;

Expected output

Tablo güncellendi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Dropping a column: match the terms

Term Meaning
DROP COLUMN drop column
data lost
cannot undo permanent
backup first

2 Add DROP COLUMN

Question
ALTER TABLE products
____ stock;
Answer
ALTER TABLE products
DROP COLUMN stock;

Explanation: DROP COLUMN is the right answer.

3 What does DROP COLUMN do to data?

  • Keeps it
  • Moves it
  • Deletes them Correct answer
  • Hides it

Explanation: DROP COLUMN deletes data.

All lessons in Intermediate