5
votes

In Redshift, you appear to not be able to drop a column if there is a view dependent on your table, regardless of whether or not your column is referenced.

step 1 - Create table

create table codenames
(
  id int identity(0, 1),
  name text,
  code text
)

step 2 - Create view

create view codenames_names_only
as
select name
from codenames;

step 3 - drop unused column

alter table codenames
drop column code;

At this time, you get the following error:

Error: ERROR: cannot drop table x column code because other objects depend on it
Hint: Use DROP ... CASCADE to drop the dependent objects too.

The above works fine in barebones PostgreSQL (SQLFiddle link)

Thoughts? Ways to get around this without dropping/modifying the views?

1

1 Answers

2
votes

This seems to be an acknowledged bug in 2013 and still has not been fixed in 2016..

https://forums.aws.amazon.com/thread.jspa?threadID=128056