Subject Re: [firebird-support] A unique index which is not?
Author Martijn Tonies
> 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.

This is why we have GUIs that won't let you create a FK to columns,
but only to parent constraints ;-)

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com