How to Drop a Column

To remove a column in Postgres use an alter table like:

alter table employee drop column last_bonus_date ;

If the column is referenced by a foreing key in another table, or used in a view, then the drop of the column will fail with an error. In this case you have to use the ‘cascade’ clause.

create view people as 
select name,last_bonus_date 
from employee where name like 'a%';

As the previous view references the column last_bonus_date to drop, you need to put the cascade clause.

alter table employee drop column last_bonus_date cascade ;

IN THIS PAGE