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: How to associate Foreign Key with an Index?

Re: How to associate Foreign Key with an Index?

From: Walt <walt_askier_at_SHOESyahoo.com>
Date: Thu, 08 Feb 2007 10:10:57 -0500
Message-ID: <12smfc330dusce5@corp.supernews.com>


John K. Hinsdale wrote:

> I'm still interested to know if Oracle allows an FK without
> an unique index on the child columns, which you seemd to
> imply was the case. Is that really possible? I'll be
> surprised, but then I have been surprised by Oracle before.

In order to create a foreign key, the referenced column must be a primary key, or have a unique constraint. (Note that a unique index is not sufficient, it must be a unique constraint.) When you create a PK or a unique constraint, an associated index is automatically created for you to.

There is no such index requirement on the referencing column, and the database will not create one for you automatically. Why should it? - often FK's are to small code tables where an index would not be useful.   Of course, you can always create an index yourself if you want to.

BTW, I think your terminology is backwards from usual usage, re parent and child record.

//Walt Received on Thu Feb 08 2007 - 09:10:57 CST

Original text of this message

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