CodeBlanks Logo Icon CodeBlanks

DROP TABLE

Delete a table.

DROP TABLE

DROP TABLE deletes the table and all its data. Permanent and irreversible.

DROP TABLE old_products;

This query removes the table entirely.

DROP TABLE — details

DROP TABLE removes the table, data, indexes and constraints. Use with extreme care.

DROP TABLE IF EXISTS avoids an error when the table is missing; but because there is no undo, take a backup first.

Practice DROP TABLE

Drop the old_products table with DROP TABLE.

Starter code

query.sql
-- drop table
DROP TABLE

Sample solution

query.sql
DROP TABLE old_products;

Expected output

Tablo kaldırıldı

Questions and answers

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

1 Add DROP TABLE

Question
____ old_products;
Answer
DROP TABLE old_products;

Explanation: DROP TABLE is the right answer.

2 DROP TABLE: match the terms

Term Meaning
DROP TABLE drop table
data lost
permanent irreversible
careful risky

3 What does DROP TABLE delete?

  • The table and its data Correct answer
  • Only the data
  • Only the structure
  • The index

Explanation: DROP TABLE deletes the table and data.

All lessons in Intermediate