DatabaseLesson 12Free preview
PostgreSQL DROP COLUMN
This lesson is part of PostgreSQL · All levels
Summary
ALTER TABLE ... DROP COLUMN permanently deletes a column and all of its data. PostgreSQL provides IF EXISTS so that the command does not error when columns are not found, as well as CASCADE when there are other objects that depend on it. Since this removal is difficult to override, check the reference first.
Key points
- DROP COLUMN deletes the column and its contents.
- If EXIST prevents errors when columns do not exist.
- CASCADE removes dependen objects such as views, indexes, or constraints.
- Verify the use reference before running the DROP COLUMN in production.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.