HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

PostgreSQL: Displaying inheritance relationship?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlrelationshipinheritancedisplaying

Problem

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?

Solution

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.

Code Snippets

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

Context

StackExchange Database Administrators Q#3115, answer score: 6

Revisions (0)

No revisions yet.