unique index on fields with possible null values

Поиск
Список
Период
Сортировка
От Dmitry Ruban
Тема unique index on fields with possible null values
Дата
Msg-id 248746715.20070727125938@ruban.biz
обсуждение исходный текст
Ответы Re: unique index on fields with possible null values  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: How to cast, if type has spaces in the name
Следующее
От: Paul Lambert
Дата:
Сообщение: Join question