Re: How to keep the last row of a data set?

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to keep the last row of a data set?
Date: 2012-12-13 21:15:15
Message-ID: CAPTjJmoyjcJnPB74ucgp5hb=Qv+kwgiq6ZSjvGXMOsnV_RCjGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Dec 14, 2012 at 7:22 AM, John R Pierce <pierce(at)hogranch(dot)com> wrote:
> On 12/13/2012 5:32 AM, seiliki(at)so-net(dot)net(dot)tw wrote:
>>
>> I am trying to implement a mechanism that prohibits the last row of a data
>> set from being deleted.
>>
>> CREATE TABLE t1 (c1 INTEGER,c2 INTEGER, PRIMARY KEY (c1,c2));
>>
>> INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(2,1),(2,2),(2,3);
>
>
> Which row is the last row? relations are sets, not ordered lists.

My understanding of the OP is that this is a constraint whereby there
must always be at least one remaining row for a given value of c1.
That is to say, you may delete any row from t1 as long as it's not the
last row (temporally, not sequentially) with that c1.

ChrisA

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Noel 2012-12-13 21:17:14 Re: initdb error
Previous Message Tom Lane 2012-12-13 21:13:27 Re: JDBC to load UTF8@psql to latin1@mysql