From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Scott Marlowe <smarlowe(at)qwest(dot)net> |
Cc: | Yateen Joshi <yjoshi(at)starentnetworks(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Single Row Table? |
Date: | 2004-08-30 13:20:19 |
Message-ID: | 20040830132019.GA28435@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Aug 29, 2004 at 15:38:45 -0600,
Scott Marlowe <smarlowe(at)qwest(dot)net> wrote:
> On Sun, 2004-08-29 at 15:30, Bruno Wolff III wrote:
> > On Fri, Aug 27, 2004 at 13:32:07 +0530,
> > Yateen Joshi <yjoshi(at)starentnetworks(dot)com> wrote:
> > > Hi,
> > >
> > > 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.
> > > How can I do that? Can I add any constraints? Or do I need to write a
> > > separate trigger for the same?
> >
> > A simple way to force this is to add a primary key and a constraint
> > that forces the primary key to be a particular value.
>
> Is it reasonable / possible to add a check constraint something like
> select count(*) from table <=1?
It should be possible to do that with an after trigger, but it is a bit
more work to set up. As long as the table gets vacuumed, either way
is probably reasonably fast.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2004-08-30 13:29:56 | Re: is last modified timestamp for tables recorded in any system table(s)? |
Previous Message | email lists | 2004-08-30 13:19:01 | is last modified timestamp for tables recorded in any system table(s)? |