Subject | Re: [firebird-support] Uniqueness among non-null values in nullable column? |
---|---|
Author | Mark Rotteveel |
Post date | 2012-04-24T08:52:06Z |
On 24-4-2012 10:41, Thomas Steinmaurer wrote:
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
>> Even it is compound, the NULLs are not taken into account forI think we misunderstood each other. My comment was on the fact that you
>> 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);
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