renumber table - Mailing list pgsql-general

From Steve Clark
Subject renumber table
Date
Msg-id 4859770B.9020502@netwolves.com
Whole thread Raw
Responses Re: renumber table  ("Scott Marlowe" <scott.marlowe@gmail.com>)
List 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 by date:

Previous
From: "Dave Lee"
Date:
Subject: Re: migrating from mysql: need to convert empty string to null
Next
From: Tom Lane
Date:
Subject: Re: Error when trying to drop a tablespace