Re: unique in two not so unique columns

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: unique in two not so unique columns
Date: 2002-11-02 08:43:16
Message-ID: 20021102084316.GD2571@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Nov 02, 2002 at 12:58:34AM -0600, Thomas T. Thai wrote:
> I have two columns in a table:
>
> email varchar(64)
> verified boolean
>
> How do I make a check for unique email that is verified while allowing for
> non-verified emails to be not unique?

create unique index check_index on table(email) where verified = 't';

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doriano Azzena 2002-11-02 09:21:11 Re: PGDATESTYLE + SuSe 8.0
Previous Message Thomas T. Thai 2002-11-02 06:58:34 unique in two not so unique columns