Re: How to create unique constraint on NULL columns

Поиск
Список
Период
Сортировка
От Dawid Kuroczko
Тема Re: How to create unique constraint on NULL columns
Дата
Msg-id 758d5e7f05071808007dfffacb@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to create unique constraint on NULL columns  (Dawid Kuroczko <qnex42@gmail.com>)
Список pgsql-general
On 7/18/05, Dawid Kuroczko <qnex42@gmail.com> wrote:
> On 7/18/05, Andrus <eetasoft@online.ee> wrote:
> > I have meaningful primary key in department table (department code used
> > inside enterptise), not a surrogate number (I use meaningful primary keys
> > whenever possible).
>
> OK, so then just define the UNIQUE INDEX to be exactly what you need,
> for example:

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.

    Regards,
        Dawid

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Changes to not deferred FK in 8.0.3 to 7.4?
Следующее
От: Joe Maldonado
Дата:
Сообщение: Re: TRUNCATE locking problem