Re: [GENERAL] Add a serial column to a table based on a sort clause

2009-09-02 Thread David Fetter
On Wed, Sep 02, 2009 at 04:40:13PM +0400, Igor Katson wrote: > I have a table, which has a creation_ts (timestamp) column, but does > not have a id (serial) column. I want to add such a one, but, AFAIK, > if I enter > > ALTER TABLE table ADD COLUMN id serial > > it will randomly put the sequence

[GENERAL] Add a serial column to a table based on a sort clause

2009-09-02 Thread Igor Katson
I have a table, which has a creation_ts (timestamp) column, but does not have a id (serial) column. I want to add such a one, but, AFAIK, if I enter ALTER TABLE table ADD COLUMN id serial it will randomly put the sequence numbers. I wrote a function, which uses a cursor and UPDATE WHERE CURRENT