Suppose I have a PostgreSQL table called master.products
and another called account.products
. The second one inherits from the first.
Is is possible to create a query to get the parent name and schema of the table account.products
?
Suppose I have a PostgreSQL table called master.products
and another called account.products
. The second one inherits from the first.
Is is possible to create a query to get the parent name and schema of the table account.products
?
You get this information from the system catalog pg_inherits
.
SELECT inhparent::regclass::text
FROM pg_catalog.pg_inherits
WHERE inhrelid = 'account.product'::regclass;
The name is automatically schema-qualified to make it unambiguous according to the current search_path
.
Related:
About regclass
: