Martijn van Oosterhout wrote:
thnx a lot. But it does not work as expected cause the update-statement
ist not commiting for the whole table during the execution. So the
resulting order can be different from the original order, which is what
I try to avoid.
Well, that's because you're typin
21 juin 2005 15:23
To: Martijn van Oosterhout
Cc: PostgreSQL List
Subject: Re: [GENERAL] renumber id's in correct order (compact id's)
Martijn van Oosterhout wrote:
> How about:
>
> update table set id = (select count(*) from table t2 where t2.id <=
table.id);
>
> Ugly
On Tue, Jun 21, 2005 at 03:23:07PM +0200, peter pilsl wrote:
> Martijn van Oosterhout wrote:
> >How about:
> >
> >update table set id = (select count(*) from table t2 where t2.id <=
> >table.id);
> >
> >Ugly as hell, but it should work.
> >
>
>
> thnx a lot. But it does not work as expected caus
Martijn van Oosterhout wrote:
How about:
update table set id = (select count(*) from table t2 where t2.id <= table.id);
Ugly as hell, but it should work.
thnx a lot. But it does not work as expected cause the update-statement
ist not commiting for the whole table during the execution. So t
How about:
update table set id = (select count(*) from table t2 where t2.id <= table.id);
Ugly as hell, but it should work.
Hope this helps,
On Tue, Jun 21, 2005 at 10:06:40AM +0200, peter pilsl wrote:
>
>
> I've entries with id's like:
>
> x | id
> ---+
> b | 1
> a | 4
> e | 5
>
I've entries with id's like:
x | id
---+
b | 1
a | 4
e | 5
c | 12
d | 19
(5 rows)
now I'd like to have the id in continuing number to get:
x | id
---+
b | 1
a | 2
e | 3
c | 4
d | 5
(5 rows)
Simpliest way to do would be to create a sequence and update the whole