Re: How to create unique constraint on NULL columns

Поиск
Список
Период
Сортировка
От Andrus
Тема Re: How to create unique constraint on NULL columns
Дата
Msg-id dbgner$5c1$1@news.hub.org
обсуждение исходный текст
Ответ на Re: How to create unique constraint on NULL columns  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
> Or better:
> CREATE UNIQUE INDEX permission_unique_key
> (user_id,permission_id,department_id);
> CREATE UNIQUE INDEX permission_uninull_key (user_id,permission_id)
> WHERE department_id IS NULL;
>
> ...you may want to add WHERE department_id IS NOT NULL to the first query
> (or not).  Anyway -- this way these indexes could be used by searches
> easily
> than using previous index I've sent.
>

 Dawid,

I see no difference of adding/not adding IS NOT NULL to the first CREATE
UNIQUE INDEX .
So why the explicit creation of first unique index is required ?

It would be better to create unique constraint on
(user_id,permission_id,department_id) instead on explicity creating index.

Andrus.



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

Предыдущее
От: "Andrus"
Дата:
Сообщение: Re: How to find the number of rows deleted
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: How to find the number of rows deleted