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 constraints

Re: Foreign key constraints

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: Sun, 20 Jun 1999 04:19:21 GMT
Message-ID: <37766610.46771694@netnews.worldnet.att.net>


On Fri, 18 Jun 1999 08:49:54 -0400, Kenneth C Stahl <kstahl_at_lucent.com> wrote:

>Question: If a foreign key constraint is created for a column in a
>table, is it required that there be an index on that column? One book I
>read suggested that if there isn't an index for the column then there
>may be locking problems when updates occur.

Locking problems can occur if you delete or change records on the table being referenced. Say that I have an employee table with 100,000 records that all have foreign keys to the dept table. Then say that I delete one dept record. Oracle needs to check to see if any employees point to that record. If there is no index on the employee.dept field, Oracle will be forced to do a full tablescan, and it will lock the table to be sure that it remains stable while that occurs.

Jonathan



jonathan_at_gennick.com
http://gennick.com
Brighten the Corner Where You Are Received on Sat Jun 19 1999 - 23:19:21 CDT

Original text of this message

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