英文:
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).
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论