Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 491 Bytes

File metadata and controls

20 lines (17 loc) · 491 Bytes

PostgreSQL: Drop Column

To drop a column from a table in PostgreSQL here is the commands.

Command

ALTER TABLE table_name DROP COLUMN column_name;

If the column has constraints (FK, PK), drop them first:

ALTER TABLE table_name DROP CONSTRAINT constraint_name;
ALTER TABLE table_name DROP COLUMN column_name;

If you’re not sure about the constraint name:

SELECT conname, conrelid::regclass
FROM pg_constraint
WHERE conrelid = 'table_name'::regclass;