When one of the field is null, PG considers that the tuple is not the same:('a',null) is not equal to ('a',null)So, the unique constraint is not violated in PG. But is there a way to have the same feature than Oracle? I already tried with:create unique index idx on t(coalesce(c1,''),coalesce(c2,'')) But in this case, I cannot insert several (null,null) without raising a duplicate key error.
When one of the field is null, PG considers that the tuple is not the same:
('a',null) is not equal to ('a',null)
So, the unique constraint is not violated in PG.
But is there a way to have the same feature than Oracle?
I already tried with:
create unique index idx on t(coalesce(c1,''),coalesce(c2,''))
But in this case, I cannot insert several (null,null) without raising a duplicate key error.
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных