How to show all invalid objects in PostgresQL
Answer a question
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;
Answers
I don't think that you have to check anything else, since other objects cannot become invalid in PostgreSQL.
Oracle and PostgreSQL work quite differently in that respect:
-
In Oracle, you can always
ALTERan 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. -
In PostgreSQL, you cannot
ALTERan object that has dependend objects in a way that renders these dependent objects invalid. You have to drop and recreate the dependent objects.
Invalid indexes can be left behind by a failed CREATE INDEX command.
更多推荐
所有评论(0)