Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: foreign key missing

Re: foreign key missing

From: Geoff White <whiteg_at_ccis.adisys.com.au>
Date: Fri, 26 Mar 1999 12:02:26 +0800
Message-ID: <36FB06D2.2E3128CF@ccis.adisys.com.au>


Sybrand Bakker wrote:

> Verify the existence of the primary key on the lumbergroups table. Ifr this
> doesn't exist the foreign key on lumbersize will not be created. Also, you
> shouldn't include columns names in the references clause, as those are derived
> from the primary key on the other table.
>

There is a circumstance where that isn't the case. A foreign key can reference a unique constraint. If you don't specify the referenced column in the foreign key constraint one of 2 things will happen:. If the table with the unique constraint has a primary key then will try and attach the foreign key to the primary key. If it is the correct datatype then the connection will be made and you won't know it is incorrect until data is entered. Otherwise, you will get an error. . If the table with the unique constraint doesn't have a primary key you will get an error message that the primary key doesn't exist.

And no, off the top of my head I can't think of any examples where the tables might be defined like this. It's just something worth keeping in mind.

Geoff

> Hth,
>
> Sybrand Bakker, Oracle DBA
>
> Gennady wrote:
>
> <snip>

> Sybrand Bakker <postbus_at_sybrandb.demon.nl>
>
> Sybrand Bakker
> <postbus_at_sybrandb.demon.nl>
> Netscape Conference Address
> Netscape Conference DLS Server
> Additional Information:
> Last Name Bakker
> First Name Sybrand
> Version 2.1
Received on Thu Mar 25 1999 - 22:02:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US