Lists: | pgsql-novice |
---|
From: | Thorsten Haude <postgresql(at)thorstenhau(dot)de> |
---|---|
To: | PostgreSQL Novice ML <pgsql-novice(at)postgresql(dot)org> |
Subject: | Reference to Inherited Table |
Date: | 2002-03-23 12:37:51 |
Message-ID: | 20020323123751.GA923@eumel.yoo.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-novice |
Hi,
I want to reference an inherited table:
- - - Schnipp - - -
create table parent
(
id serial,
primary key(id)
);
create table child
(
thing integer
) inherits (parent);
create table third
(
stuff integer references child
);
- - - Schnapp - - -
But get an error:
ERROR: PRIMARY KEY for referenced table "child" not found
Is there a way to do it or do I have to reference parent?
tia,
Thorsten
--
Auch Hunger ist Krieg.
- Willy Brandt
From: | Chris <csmith(at)squiz(dot)net> |
---|---|
To: | Thorsten Haude <postgresql(at)thorstenhau(dot)de>, PostgreSQL Novice ML <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Reference to Inherited Table |
Date: | 2002-03-24 22:52:05 |
Message-ID: | 5.1.0.14.0.20020325094919.027bf4e0@cooee.cybersydney.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-novice |
Hi,
>create table third
>(
> stuff integer references child
>);
>- - - Schnapp - - -
>But get an error:
>ERROR: PRIMARY KEY for referenced table "child" not found
Try
create table third(
stuff integer references child(thing)
);
You could do what you were trying to do if in the child table you have a
field called 'stuff', but since you don't, you have to reference it
specifically.
-----------------
Chris Smith
http://www.squiz.net/