I want to know if a certain PostgreSQL table is a part of any inheritance relationship (i.e. is a parent or a child of other table(s)).

Is there a query for that? Where is the inheritance data stored?

SELECT relname 
FROM pg_class c,pg_inherits i 
WHERE c.oid=i.inhrelid;

I am the guy that asked Adam about this, I found a solution so I added it here for future reference of others.


Check out the pg_inherits system catalog: http://www.postgresql.org/docs/9.0/interactive/catalog-pg-inherits.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.