PostgreSQL Drop Table
Overview
The DROP TABLE statement permanently removes a table and all its data from the database. This is an irreversible operation, so make sure to backup important data before executing.
DROP TABLE Statement
Basic Syntax
Simple Examples
Complete Syntax
Drop Options
CASCADE vs RESTRICT
Difference Explained
Dropping Multiple Tables
Practical Examples
Cleaning Up Test Data
Resetting Database Structure
Viewing Table Dependencies
Before dropping a table, check which objects depend on it:
Important Notes
- Data loss: DROP TABLE permanently deletes all data
- Index deletion: All indexes on the table are also deleted
- Trigger deletion: Triggers associated with the table are deleted
- Foreign key constraints: CASCADE affects foreign keys referencing the table
- Permission required: Requires table owner or superuser privileges