Re: limit table to one row

From: "Octavio Alvarez" <alvarezp(at)alvarezp(dot)ods(dot)org>
To: "Brandon Metcalf" <brandon(at)geronimoalloys(dot)com>, Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 16:25:14
Message-ID: op.uu9mhwk84oyyg1@alvarezp-ws
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 09 Jun 2009 08:24:01 -0700, Brandon Metcalf
<brandon(at)geronimoalloys(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Spotts 2009-06-09 17:15:04 Re: type cast in index
Previous Message Linos 2009-06-09 16:20:21 type cast in index