Re: UNIQUE boolean: only one row may be "true"

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Randall Lucas <rlucas(at)tercent(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: UNIQUE boolean: only one row may be "true"
Date: 2003-05-06 17:26:04
Message-ID: 20030506172604.92026.qmail@web12708.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> How shall I create a constraint such that only one row may be 'true'?

Instead of, or along with your pg boolean, use a C type boolean where
true is 1 and false is null:
...
col_tf int check( col_tf = 1 || col_tf is null ) unique,
...
a kludge to be sure, but works

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael A Nachbaur 2003-05-06 17:40:03 Re: pgsql Replication Proxy (was Re: Replication for a
Previous Message Bruno Wolff III 2003-05-06 17:23:54 Re: UNIQUE boolean: only one row may be "true"