From: | Jason Hihn <jhihn(at)paytimepayroll(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Creating a table: UNIQUE constraint matching given keys |
Date: | 2003-08-07 15:06:46 |
Message-ID: | NGBBLHANMLKMHPDGJGAPMEEECMAA.jhihn@paytimepayroll.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
*smacks palm against forehead in a I-feel-like-a-dolt manner*
Thank you Bruno and Tom!
> -----Original Message-----
> From: pgsql-novice-owner(at)postgresql(dot)org
> [mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Tom Lane
> Sent: Thursday, August 07, 2003 10:42 AM
> To: Jason Hihn
> Cc: pgsql-novice(at)postgresql(dot)org
> Subject: Re: [NOVICE] Creating a table: UNIQUE constraint matching given
> keys for referenced table "xy" not found
>
>
> Jason Hihn <jhihn(at)paytimepayroll(dot)com> writes:
> > create table xy( x integer not null, y integer not null,
> primary key (x,y));
> > create table xyz( x integer not null references xy(x), y
> integer not null
> > references xy(y), z integer not null, primary key (x,y,z));
> > ERROR: UNIQUE constraint matching given keys for referenced
> table "xy" not
> > found
>
> I think what you want is a two-column foreign key reference:
>
> create table xyz( x integer not null, y integer not null, z
> integer not null,
> primary key (x,y,z),
> foreign key (x,y) references xy(x,y));
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-08-07 15:41:38 | Re: database design |
Previous Message | Tom Lane | 2003-08-07 14:41:39 | Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found |