Re: Adding a conditional unique constraint

Поиск
Список
Период
Сортировка
От Phillip Smith
Тема Re: Adding a conditional unique constraint
Дата
Msg-id 1176983487.4698.2.camel@fukawi2.homelinux.net
обсуждение исходный текст
Ответ на Adding a conditional unique constraint  (Nathaniel <naptrel@yahoo.co.uk>)
Список pgsql-novice
ALTER TABLE proposals
ADD CONSTRAINT one_draft_each
CHECK  (draft IS false)
OR    (draft IS true AND user_id NOT IN (SELECT user_id FROM proposals WHERE draft IS true))

It will be a lot slower than a UNIQUE constraint, especially as your table gets bigger...


On Thu, 2007-04-19 at 10:52 +0100, Nathaniel wrote:
ALTER TABLE proposals ADD CONSTRAINT one_draft_each CHECK draft IS 
false OR UNIQUE user_id

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments

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

Предыдущее
От: Nathaniel
Дата:
Сообщение: Adding a conditional unique constraint
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: Adding a conditional unique constraint