Subject Re: [ib-support] Foreign Key -- Alter Table fails -- could not find UNIQUE INDEX with specified columns
Author David K. Trudgett
On Wednesday 2002-03-27 at 14:58:14 -0500, Ann Harrison wrote:

> >The problem happens with this bit of SQL:
> >
> > ALTER TABLE TABLE1
> > ADD CONSTRAINT FK_TAB1TAB2
> > FOREIGN KEY (COL1, COL2)
> > REFERENCES TABLE2 (COL1, COL2);
> >
> >The error:
> >
> > Statement failed, SQLCODE = -607
> >
> > unsuccessful metadata update
> > -could not find UNIQUE INDEX with specified columns
>
> Ah. The message is misleading. We require a constraint
> on the columns in TABLE2 - either PRIMARY KEY or UNIQUE.
> A unique index won't do.

Thanks, Ann, that makes a bit more sense, now. It stands to reason
that a foreign key constraint shouldn't depend on an index that could
be here today, gone tomorrow.

Cheers,

David Trudgett