amazon-redshift - Redshift - 如何显示 CASCADE 将删除的依赖项?

标签 amazon-redshift cascade

在 Redshift 中删除表时,我收到一条错误消息:

Amazon Invalid operation: cannot drop table rawdata.bss_edw_customer_account because other objects depend on it;

我不想使用 CASCADE,因为我不知道它会杀死哪些其他表/ View 。如何找出哪些表或 View 依赖于我要删除的表?我想确保我不会侵犯别人的工作。

谢谢

最佳答案

对象 [1] 和约束 [2] 依赖关系的 Redshift 管理 View 可以帮助识别依赖对象。您还可以按照 DROP 表文档 [3] 中的说明创建 find_depend View 来查看任何依赖项。

我还发现这些 View 可能并不总是将物化 View 列为依赖对象。如果您过去创建过任何 MV,那么您可能需要使用 View DDL 检查依赖关系。以下查询可能会有所帮助:

select schemaname, viewname from pg_views where schemaname not like 'pg_catalog' and schemaname not like 'information_schema' and definition like '%<tablename>%';

[1] https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_object_dependency.sql

[2] https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_constraint_dependency.sql

[3] https://docs.aws.amazon.com/redshift/latest/dg/r_DROP_TABLE.html

关于amazon-redshift - Redshift - 如何显示 CASCADE 将删除的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62334766/

相关文章:

c# - 级联错误: deleted object would be re-saved by cascade

ruby-on-rails - 如何使用 PG gem 捕获 PSQL 命令的输出?

sql - Redshift 数据库的透视

amazon-web-services - 独立游戏后端的 Aurora 与 Redshift 与 DynamoDB?

amazon-web-services - 如何通过SQL Workbench将Amazon Redshift输出保存到本地CSV?

mysql - 查看 MySQL Workbench 中级联删除的完整效果?

amazon-web-services - 更改 Amazon Redshift 中的列数据类型

sql - CASCADE DELETE 两个外键约束

NHibernate 按代码映射 (Loquacious) - 级联选项

ios - 核心数据在更新时应用删除规则