Reordering a table

Поиск
Список
Период
Сортировка
От Howard Cole
Тема Reordering a table
Дата
Msg-id 4D63E704.7090605@selestial.com
обсуждение исходный текст
Ответы Re: Reordering a table  (David Kerr <dmk@mr-paradox.net>)
Re: Reordering a table  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
Re: Reordering a table  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
Hi,

a puzzle to solve...

I have a table with a primary key, and a timestamp, e.g.

id    stamp
1     2011-02-01 10:00
2     2011-02-01 09:00
3     2011-02-01 11:00

Now for reasons too painful to go into, I need to reorder the id
(sequence) so that they are in time order:

id    stamp
1     2011-02-01 09:00
2     2011-02-01 10:00
3     2011-02-01 11:00

I thought I could do it by adding a third colum with the order in it,
but I cannot think of a way to do this short of writing some code

id    stamp                         order
1     2011-02-01 10:00    2
2     2011-02-01 09:00    1
3     2011-02-01 11:00    3

Any ideas?

Thanks.
Howard
www.selestial.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: work_mem = 900MB but Sort Method: external merge Disk: 304008kB
Следующее
От: Tom Lane
Дата:
Сообщение: Re: work_mem = 900MB but Sort Method: external merge Disk: 304008kB