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

Classes, Inheritance, and Children

From: Thomas Swan <tswan(at)olemiss(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Classes, Inheritance, and Children
Date: 2000-07-27 07:06:51
Message-ID: 4.3.2.7.2.20000727014844.020d4d48@sunset.backbone.olemiss.edu (view raw or flat)
Thread:
Lists: pgsql-sql
I think I may have asked this before... If I did I'm sorry, but maybe this 
attempt, assuming a prior one, may be a little more clear.

create table foo (id int8);
create table bar1 (name text) inherits (foo);
create table bar2 (data text) inherits (foo);
create table hybrid ( ) inherits (bar1, bar2);

INSERT INTO foo VALUES (1);
INSERT INTO bar1 VALUES (2,'myname');
INSERT INTO bar2 VALUES (3,'mydata');
INSERT INTO hybrid VALUES (4,'morename','moredata');


I want to do a SELECT * FROM foo*; but I only get the 'id' column as in :

id
---
  1
  2
  3
  4


What would be the query to get the following table or a magical way to 
expand children?

I had originally hoped that SELECT * FROM foo* would yield the following, 
but it's not so.

id | name       | data
---+------------+-------------
  1 | null       | null
  2 | 'myname'   | null
  3 | null       | 'mydata'
  4 | 'morename' | 'moredata'
    |            |

I tried SELECT id, name AS NULL, data AS NULL FROM foo*; but that didn't do 
anything but make 2 null columns...

Any help would be ... helpful...

Thanks,
Thomas

pgsql-sql by date

Next:From: Vladimir TerzievDate: 2000-07-27 08:30:26
Subject: Large text insertion
Previous:From: pgsql-sqlDate: 2000-07-27 02:40:04
Subject: Re(2): optimize sql

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