Subject Re: [firebird-support] A unique index which is not?
Author Helen Borrie
At 04:05 PM 17/09/2004 -0500, you wrote:
>I have this strange problem. I have two tables which I am trying to
>create a foreign key relationship between them. However, even though I
>create the unique index before attempting to create the FK relationship
>it fails claiming that the unique index cannot be found. Any idea what
>may the problem be? This is 1.5.1 on Linux.

Yes. You can't form a FK to a unique INDEX. It has to be a UNIQUE
constraint. A unique index isn't a UNIQUE constraint.

What you really needed here was not this:

CREATE UNIQUE INDEX unique_val ON repl_type (repl_type_code);

but this:
ALTER TABLE repl_type
ADD CONSTRAINT uq_repl_type_code
UNIQUE (repl_type_code);

Make sure you drop the unique index before you create the UNIQUE constraint.

And, yes, the exception message IS misleading.