DatabaseLesson 14Free preview
PostgreSQL DROP TABLE
This lesson is part of PostgreSQL · All levels
Summary
DROP TABLE permanently deletes a table with all its structure and data. The IF EXISTS option is available to avoid errors as well as the CASCADE option to delete tables-dependent objects. Since this removal cannot be reversed, always make backup first in the production environment.
Key points
- DROP TABLE permanently deletes the table and all its data.
- IF EXISTS prevents errors when tables have never been created.
- CASCADE removes dependencies such as a view or foreign key that points to a table.
- In production, backup before DROP so it can still be restored.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.