【发布时间】:2016-06-23 08:22:56
【问题描述】:
在 Redshift 中,如果存在依赖于您的表的视图,您似乎无法删除列,无论您的列是否被引用。
第 1 步 - 创建表
create table codenames
(
id int identity(0, 1),
name text,
code text
)
第 2 步 - 创建视图
create view codenames_names_only
as
select name
from codenames;
第 3 步 - 删除未使用的列
alter table codenames
drop column code;
此时,你会得到如下错误:
Error: ERROR: cannot drop table x column code because other objects depend on it
Hint: Use DROP ... CASCADE to drop the dependent objects too.
以上在准系统 PostgreSQL 中运行良好 (SQLFiddle link)
想法?在不删除/修改视图的情况下解决此问题的方法?
【问题讨论】:
标签: postgresql amazon-redshift