renumber table

Поиск
Список
Период
Сортировка
От Steve Clark
Тема renumber table
Дата
Msg-id 4859770B.9020502@netwolves.com
обсуждение исходный текст
Ответы Re: renumber table  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Список pgsql-general
Hello List,

I have acquired the task of maintaining and existing application that uses postgresql. I am only lightly versed
in sql and have the following problem I need to solve.

I have a table in which each row has a column - row_number. The row_numbers need to be sequential.
Everything is fine until a row in the middle of the table gets deleted, now I need to renumber the remaining
rows so they are sequential again. The table is small, typically less than a 100 rows. Is there a simple way
to do this in sql. I know I can dump the table to an external file and then use 'C' or a bash script to fix up the
row_numbers and then reload the table - but it seems there is probably a more elegant way to do this in sql.

Anyway thanks for any tips.

Steve

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

Предыдущее
От: "Dave Lee"
Дата:
Сообщение: Re: migrating from mysql: need to convert empty string to null
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Error when trying to drop a tablespace