Re: no keys... - Mailing list pgsql-general

From scott.marlowe
Subject Re: no keys...
Date
Msg-id Pine.LNX.4.44.0207161447480.30529-100000@css120.ihs.com
Whole thread Raw
In response to Re: no keys...  (Jeff Davis <list-pgsql-general@empires.org>)
List pgsql-general
On Tue, 16 Jul 2002, Jeff Davis wrote:

> Each row automatically has an oid assigned to it, which can act as a key. It's
> sort of "hidden", but all you have to do is "select oid,* from mytable" to
> see it. Then you can delete based on that oid.
>
> Regards,
>     Jeff
>
> On Tuesday 16 April 2002 12:31 pm, Dorward Villaruz wrote:
> > i have a table where there is no primary key
> >
> > i have 5 rows of data
> >
> > day1 time1
> > day1 time1
> > day1 time2
> > day1 time2
> > day1 time2
> >
> > time2 is newer than time1, how should i delete the four oldest record in
> > the table. this means that the only row that will be left on my table is:
> >
> >  day1 time2

You can do something like this in sql:

delete from test where oid !=(select max(oid) from test group by time
order by time desc limit 1);



pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: table size growing out of control
Next
From: Tom Lane
Date:
Subject: Re: size of function body