Re: limit table to one row - Mailing list pgsql-general

From Octavio Alvarez
Subject Re: limit table to one row
Date
Msg-id op.uu9mhwk84oyyg1@alvarezp-ws
Whole thread Raw
In response to Re: limit table to one row  (Brandon Metcalf <brandon@geronimoalloys.com>)
List pgsql-general
On Tue, 09 Jun 2009 08:24:01 -0700, Brandon Metcalf
<brandon@geronimoalloys.com> wrote:
>
>   CREATE TABLE foo (
>     start  DATE,
>     length VARCHAR(10),
>   );
>
> I need to be able to get one value for each column at any given time.

CREATE UNIQUE INDEX u ON foo ((start IS NOT NULL));

You would just make sure you SELECT FROM foo WHERE start IS NOT NULL;

However, it doesn't prevent you from having 0 rows on the table.


pgsql-general by date:

Previous
From: Linos
Date:
Subject: type cast in index
Next
From: Chris Browne
Date:
Subject: Re: Can postgresql store its data on raw device now?