In PostgreSQL for these tables
CREATE TABLE cities (
name text,
population float,
altitude int -- in feet
);
CREATE TABLE cities_capitals (
state char(2)
) INHERITS (cities);
How can I programmatically check whether one of these tables inherits from another table or not? (Think information_schema, pg_catalog, …)
Should be true for cities_capitals and false for cities.
There is a catalog table for that:
pg_inherits.Here’s a query that fits your question:
TRUEif tablecities_capitalsinherits from somewhere, elseFALSE.Schema-qualify the name to be sure.