Redshift - 删除未使用的列
Redshift - Dropping unused column
在 Redshift 中,如果存在依赖于您的 table 的视图,您似乎无法删除列,无论 您的列是否是已引用。
第 1 步 - 创建 table
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)
想法?在没有 dropping/modifying 视图的情况下如何解决这个问题?
这似乎是 2013 年公认的错误,2016 年仍未修复..
在 Redshift 中,如果存在依赖于您的 table 的视图,您似乎无法删除列,无论 您的列是否是已引用。
第 1 步 - 创建 table
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)
想法?在没有 dropping/modifying 视图的情况下如何解决这个问题?
这似乎是 2013 年公认的错误,2016 年仍未修复..