unique index on fields with possible null values - Mailing list pgsql-sql

From Dmitry Ruban
Subject unique index on fields with possible null values
Date
Msg-id 248746715.20070727125938@ruban.biz
Whole thread Raw
Responses Re: unique index on fields with possible null values
List pgsql-sql
Hello pgsql-sql,

I'm trying to find a solution for unique index on fields with possible
null values.

Example table:

CREATE TABLE test (a integer NOT NULL,b integer NULL
);

As long as unique index can't check if there are records with null
values i found the only one solution for this problem:

CREATE UNIQUE INDEX test_uniq1 ON test (a, COALESCE(b,0));

Are there any other ways of doing this?

-- 
Best regards,Dmitry                          mailto:dmitry@ruban.biz



pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: How to cast, if type has spaces in the name
Next
From: Paul Lambert
Date:
Subject: Join question