如何在Postgres中删除不存在的视图

huangapple go评论50阅读模式
英文:

How to delete views when it doesn't exist in Postgres

问题

我通过pgadmin4在Postgres中创建了一些表和视图。

我更改了一个名为视图A的视图中的代码,它基于表1和2。然后我发现在视图A中不需要表2,所以尝试调整代码,但由于依赖关系而失败。
然后我尝试级联删除表2 - 成功,然后我尝试删除视图A,但失败并显示“找不到特定的未找到”(下图)。

点击此处查看图片描述

问题:在这种情况下如何删除视图A(显示找不到)?

尝试的步骤:我尝试了删除视图、级联删除视图和删除,但都无法删除视图A。

我对Postgres还比较新,请您的帮助。

谢谢。

TW

英文:

I 've create some tables and views in Postgres via pgadmin4.

I change the code in one of the view, called view A, which base on table 1 and 2. I then found out I don't need table 2 in view A so try to adjust the code, but fail due to dependency.
Then I drop cascade table 2 - success, then I try to delete view A but fail and shows "could not found specific none" (below image).

enter image description here

Question: How to delete view A (which shows could not found) in this situation ?

Steps tried: I have try drop view, drop view with cascade, and delete but all fail to delete the view A.

I'm pretty new to Postgres, so appreciate for your help.

Thanks.

TW

答案1

得分: 1

如果使用CASCADE删除表格,且存在依赖于该表格的视图,视图会自动被删除。只有 pgAdmin 不知道视图已被删除。刷新 pgAdmin 的显示,视图将不复存在。

英文:

If you drop a table with CASCADE and there is a view that depends on it, the view is automatically dropped too. Only pgAdmin does not know that the view has been dropped. Refresh pgAdmin's display, and the view will be gone.

huangapple
  • 本文由 发表于 2023年7月20日 15:37:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76727634.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定