I have a situation where I want my composite field null check to be UNIQUE. So I'm using the UNIQUE NULLS NOT DISTINCT syntax as follows:
create table codes
(
id serial primary key,
code text not null,
sub_code text null,
unique nulls not distinct (code,sub_code)
);
In this example the code can be entered again if it has a sub_code but only one version of codes can exist without a sub_code
It looks like PostgreSQL is rejecting the word nulls. Any ideas why? Is there a configuration to turn this syntax on?