From: | Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au> |
---|---|
To: | Nathaniel <naptrel(at)yahoo(dot)co(dot)uk> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Adding a conditional unique constraint |
Date: | 2007-04-19 11:51:26 |
Message-ID: | 1176983487.4698.2.camel@fukawi2.homelinux.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2007-04-19 12:30:44 | Re: Adding a conditional unique constraint |
Previous Message | Nathaniel | 2007-04-19 09:52:16 | Adding a conditional unique constraint |