Unique indices and nulls

Поиск
Список
Период
Сортировка
От Roland Roberts
Тема Unique indices and nulls
Дата
Msg-id m2y9a9zigj.fsf@kuiper.rlent.pnet
обсуждение исходный текст
Ответы Re: Unique indices and nulls  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
I see in the documentation that a unique index does not place any
constraints on the number of nulls in a table.  In my case, I have a
table with has four columns (plus other data) where that combination
of 4 columns should be unique.

    (catalog, entry, suffix, component)

forms a unique tuple.  In most (but not all) cases, (catalog, entry)
is unique and suffix and component will both be null.  In those cases,
it is common to have an entry with (catalog, entry, null, null), as
well as multiple entries with (catalog, entry, suffix, component).

But there should never be more than one entry with (catalog, entry,
null, null).

Is there any way I can enforce this?  Am I going to have to write a
trigger to check for duplicates?

roland
--
               PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@rlenter.com                     76-15 113th Street, Apt 3B
roland@astrofoto.org                       Forest Hills, NY 11375

В списке pgsql-novice по дате отправления:

Предыдущее
От: rmit.test2115@gmail.com
Дата:
Сообщение: [NOVICE] pl/pgsql and returns timestamp type
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Unique indices and nulls