Deleted Flag/Unique Constraint

From: "Bryan Murphy" <bryan(dot)murphy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Deleted Flag/Unique Constraint
Date: 2007-03-29 21:39:58
Message-ID: bd8531800703291439i59b1ad15v1c89beba71545a4c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is it possible to declare a unique constraint in combination with a deleted
flag?

For example, if I have a table like this:

CREATE TABLE
(
ID NOT NULL PRIMARY KEY,
Key VARCHAR(32) NOT NULL,
Value VARCHAR(32) NOT NULL,
Deleted INT NOT NULL DEFAULT 0
);

can I declare a unique constraint that only checks Key and Value when
Deleted = 0?

Thanks,
Bryan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2007-03-29 21:45:37 Re: How to speedup CHECKPOINTs?
Previous Message Toke Høiland-Jørgensen 2007-03-29 20:52:16 Re: Btree indexes, large numbers and <= comparisons