From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
---|---|
To: | Marques Johansson <postgresql(at)displague(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: REFERENCES this_table ( oid ) |
Date: | 2002-12-06 20:14:47 |
Message-ID: | 3DF10537.4D9FABAD@nsd.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hello Marques,
Your problem is that the oid is not indexed.
Create an index on photos(oid) then add the constraint separately.
JLL
Marques Johansson wrote:
>
> See the ERROR and comments below...
>
> create table photos (
> filename varchar[128] not null,
> filesize int default null,
> width int default null,
> height int default null,
> origPhoto oid default null references photos ( oid ),
> altDesc varchar[128] default null
> );
>
> psql:sid-sql:40: NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
> psql:sid-sql:40: ERROR: UNIQUE constraint matching given keys for referenced table "photos" not found
>
> Am I not supposed to have self referencing 'reference' values? Or is the
> oid field invisible to this function? (Maybe because the table has yet to
> be created?) I don't see any reason why I shouldn't be able to make a
> self-referencing ref.
>
> I would try creating the table first, then altering the field later - but
> you still can't 'alter column' that way. Should I just forget about using
> the 'references' keyword?
>
> --
> Marques Johansson
> postgresql(at)displague(dot)com
>
> You may my glories and my state dispose,
> But not my griefs; still am I king of those.
> -- William Shakespeare, "Richard II"
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
From | Date | Subject | |
---|---|---|---|
Next Message | Stéphane Bérubé | 2002-12-06 21:29:59 | Debian, postgresql 7.3a4 |
Previous Message | Stephan Szabo | 2002-12-06 20:14:45 | Re: REFERENCES this_table ( oid ) |