Deleted Flag/Unique Constraint - Mailing list pgsql-general

From Bryan Murphy
Subject Deleted Flag/Unique Constraint
Date
Msg-id bd8531800703291439i59b1ad15v1c89beba71545a4c@mail.gmail.com
Whole thread Raw
Responses Re: Deleted Flag/Unique Constraint
Re: Deleted Flag/Unique Constraint
List 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

pgsql-general by date:

Previous
From: Toke Høiland-Jørgensen
Date:
Subject: Re: Btree indexes, large numbers and <= comparisons
Next
From: Scott Marlowe
Date:
Subject: Re: How to speedup CHECKPOINTs?