Subject Re: [firebird-support] Uniqueness among non-null values in nullable column?
Author Mark Rotteveel
On 24-4-2012 10:41, Thomas Steinmaurer wrote:
>> Even it is compound, the NULLs are not taken into account for
>> uniqueness, only the non-null parts:
>
> Nope, AFAIK never has been. Try:
>
> create table t2 (c1 varchar(20), c2 varchar(20));
> alter table t2 add constraint u_t2 unique (c1, c2);
>
> commit;
>
> insert into t2 (c1, c2) values ('a', null);
> insert into t2 (c1, c2) values ('a', null);

I think we misunderstood each other. My comment was on the fact that you
claim - or at least so it seemed to me - that NULLs in unique keys only
work for non-compound keys, which isn't true.

You are right that in your example you can insert ('a', null) only once
(because NULLs are not taken into account for uniqueness).
--
Mark Rotteveel