SQL DatabaseLesson 50Free preview
SQL Drop Table
This lesson is part of SQL · All levels
Summary
DROP TABLE permanently deletes a table with all its structure and data. Unlike DELETE, which only deletes rows, DROP deletes the table itself so that it cannot be used again without being recreated. Add IF NOT EXIST to ensure that the script does not error when the table is not yet in existence.
Key points
- DROP TABLE name_table; remove the table and all its contents.
- The removal is permanent and irreversible.
- IF NOT EXISTS prevents errors when tables are not found.
- TRUNCATE TABLE deletes all rows but maintains the structure of the table.
- Be careful with foreign keys because deletion can fail or be chain-driven.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.