【问题标题】:Redshift - Dropping unused columnRedshift - 删除未使用的列
【发布时间】: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


    【解决方案1】:

    这似乎是 2013 年公认的错误,但在 2016 年仍未修复..

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      相关资源
      最近更新 更多