Re: Single Row Table?

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Single Row Table?
Date: 2004-08-31 19:12:47
Message-ID: ch2ijf$iem$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Penhey wrote on 30.08.2004 23:12:

>> I have got a table which is supposed to contain only one row. It does
>> not have any primary keys defined.
>>
>> So, essentially, when a new insert happens in that table, I would like
>> it (the insert) to fail if there is already a row existing in that table.
>>
>>
> You could try:
>
> id INT PRIMARY KEY NOT NULL DEFAULT(1) CHECK (id = 1),
>

I like that approach :)

But should you also prevent DELETE's from that table? Otherwise you could
wind up with no rows at all. I guess that would have to be done using a rule...

Thomas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-08-31 19:14:52 Re: Types and SRF's
Previous Message Bruce Momjian 2004-08-31 19:07:59 Re: Not able to build libpq for Windows