Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:58:51+00:00 2026-05-26T02:58:51+00:00

In PostgreSQL for these tables CREATE TABLE cities ( name text, population float, altitude

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:58:52+00:00Added an answer on May 26, 2026 at 2:58 am

    There is a catalog table for that: pg_inherits.

    The catalog pg_inherits records information about table inheritance
    hierarchies. There is one entry for each direct child table in the
    database. (Indirect inheritance can be determined by following chains
    of entries.)

    Here’s a query that fits your question:

    SELECT EXISTS (
       SELECT FROM pg_catalog.pg_inherits
       WHERE  inhrelid = 'public.cities_capitals'::regclass
       );
    

    TRUE if table cities_capitals inherits from somewhere, else FALSE.
    Schema-qualify the name to be sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to PostgreSQL. I have tables like: CREATE TABLE Person ( ID SERIAL
I have to create 2 tables: Magazine ( 10 millions of rows with these
I set up a set of partitioned tables per the docs at http://www.postgresql.org/docs/8.1/interactive/ddl-partitioning.html CREATE
I am looking to create n-grams from text column in PostgreSQL. I currently split(on
When I create a table in PostgreSQL, the SQL I use looks like this:
I have the following table in PostgreSQL 8.4.5: snake=> create table gps ( id
is there a solution for batch insert via hibernate in partitioned postgresql table? currently
I have a tree structure in an sql table like so: CREATE TABLE containers
I am working on doing a diff between tables in postgresql, it takes a
I have a postgresql (v8.4) table with login id and timestamps, and I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.