Re: Selecting * from the base table but getting the inheriteds

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: James Adams <pornstarbatman(at)hotmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Selecting * from the base table but getting the inheriteds
Date: 2002-10-30 08:05:19
Message-ID: 3DBF92BF.4080506@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Uz.ytkownik James Adams napisa?:
> Hello,
>
> I have a "baseTable". I have a number of decendantTables that INHERIT
> from the base table.
>
> I want to do somthing like
>
> =>select * from baseTable;
>
> But I want it to return the data in the all the descendant tables along
> with the extra column that they contain. How do I do this?
>

select
*,
cast(null as varchar) as another_field1,
cast(null as int4) as another_field2
from only basetable
union
select
*
from descent_table

Isn't it easier to just create baseTable with the same columns as
descent tables (and fill them with nulls)?

Tomasz Myrta

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Kabai Jzsef 2002-10-30 08:07:00 Re: Creating Stored Procedures
Previous Message Viacheslav N Tararin 2002-10-30 06:45:34 Database Design tool