Skip site navigation (1) Skip section navigation (2)

Re: Inheritance in Postgresql ?

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: ABBAS SHAKEEL <shakeel(dot)abbas(dot)qau(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Inheritance in Postgresql ?
Date: 2009-12-16 07:15:38
Message-ID: dcc563d10912152315w2d6993dcr126c0272d7656e0c@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
On Wed, Dec 16, 2009 at 12:01 AM, ABBAS SHAKEEL
<shakeel(dot)abbas(dot)qau(at)gmail(dot)com> wrote:
> Thanks Scott
> you are right . It inherits structure only and i don't know whether to call
> to it an advantage or disadvantage that it query the children table as well
> while select. But in case of insert and update this concepts takes a new
> turn.
> How inheritance effect data?
>  Can you please briefly compare concept of inheritance in Postgres and JAVA,
> as my mind is trying to compare this with already  stored concept in mind
> about inheritance ;)

I'm no Java specialist, so can't directly compare there.  In the case
of inserts those go to the parent or, if you insert directly to them
the child tables. Updates operate on the appropriate child tables.

By defining triggers or rules, you can make inserts to the parent
table go to appropriate child tables, which is often done for
partitioning data, which is in turn the most common use for table
inheritance.

You can also select data from JUST the parent with the only keyword,
as in "select * from only parent_table".

Note that pgsql supports multiple inheritance, so that you can have a
table inherit structure from two or more parent tables as well.

Note that as of 8.4, according to the docs:
"All check constraints and not-null constraints on a parent table are
automatically inherited by its children. Other types of constraints
(unique, primary key, and foreign key constraints) are not inherited."

So for foreign keys and such, inheritance is much less useful than
regular tables.

In response to

Responses

pgsql-admin by date

Next:From: ABBAS SHAKEELDate: 2009-12-16 07:33:56
Subject: Re: Inheritance in Postgresql ?
Previous:From: ABBAS SHAKEELDate: 2009-12-16 07:01:05
Subject: Re: Inheritance in Postgresql ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group