如何在PostgresQL中显示所有无效对象 [英] How to show all invalid objects in PostgresQL

查看:572
本文介绍了如何在PostgresQL中显示所有无效对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找视图,我可以列出PostgreSQL中所有无效的对象。
在Oracle中,我们可以使用dab_objects.status列,但是我不确定在PostgreSQL中是否有一种简单的方法可以做到这一点。

Looking for the view I can list up all 'invalid' objects in PostgreSQL. In Oracle, we can use dab_objects.status column but I'm not sure if there is a simple way to do such a thing in PostgreSQL.

也许,我可以使用以下代码检查无效索引。
如何为其他对象执行此操作?

Maybe, I can check the invalid indexes with below code. How can I do that for other objects?

SELECT pg_class.relname 
FROM pg_class, pg_index 
WHERE pg_index.indisvalid = false 
AND pg_index.indexrelid = pg_class.oid;


推荐答案

我认为您不必检查任何内容否则,因为其他对象在PostgreSQL中不会变得无效。

I don't think that you have to check anything else, since other objects cannot become invalid in PostgreSQL.

Oracle和PostgreSQL在这方面的工作方式大不相同:

Oracle and PostgreSQL work quite differently in that respect:


  • 在Oracle中,即使存在依赖对象(例如视图),也始终可以 ALTER 一个对象(例如表) 。然后,从属对象将变为无效,并且必须重新编译

  • In Oracle, you can always ALTER an object (for example a table) even if there are dependent objects (for example views). The dependent objects then become invalid and have to be recompiled.

在PostgreSQL中,您不能 ALTER 具有依赖对象的对象,该对象具有呈现依赖项的方式对象无效。您必须删除并重新创建依赖对象。

In PostgreSQL, you cannot ALTER an object that has dependend objects in a way that renders these dependent objects invalid. You have to drop and recreate the dependent objects.

失败的<$ c $可能会留下无效的索引c>创建索引命令。

这篇关于如何在PostgresQL中显示所有无效对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆