Re: unique index with bool

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: unique index with bool
Дата
Msg-id 428CAE31.8010702@archonet.com
обсуждение исходный текст
Ответ на unique index with bool  (tmpmac@mac.com)
Список pgsql-general
tmpmac@mac.com wrote:
> CREATE UNIQUE INDEX name on table(param1,param2);
>
> How to create such unique index when param2 is bool type, and this
> param2 should be accepted only in case of true ?
>
> I tried: CREATE UNIQUE INDEX name on table(param1,(param2 = 'true'));
>  but it's not working.

Something like:

CREATE UNIQUE INDEX my_uniq_idx ON table(param1,param2)

ALTER TABLE table ADD CONSTRAINT my_constraint CHECK (param2='' OR
param1=true);

So - separate out the test linking param1/param2 from your uniqueness
requirement.
--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Douglas McNaught
Дата:
Сообщение: Re: Shared memory and FreeBSD's jail()
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Postgresql 7.4.7 docs(PDF)