Re: [GENERAL] Renumber table rows

2012-06-06 Thread Efraín Déctor
Thank you. It really worked. From: David Johnston Sent: Wednesday, June 06, 2012 3:17 PM To: 'Efraín Déctor' ; pgsql-general@postgresql.org Subject: RE: [GENERAL] Renumber table rows Try something along the lines of: UPDATE operador SET idoperador = new_idoper

Re: [GENERAL] Renumber table rows

2012-06-06 Thread David Johnston
@postgresql.org Subject: [GENERAL] Renumber table rows Hello. I have a table that his primary key is not ordered is something like this: 1 - a 12- b 123 - c etc. I want to do an update to make it like this 1 – a 2 – b 3 – c I tried this: UPDATE operador SET

[GENERAL] Renumber table rows

2012-06-06 Thread Efraín Déctor
Hello. I have a table that his primary key is not ordered is something like this: 1 - a 12- b 123 - c etc. I want to do an update to make it like this 1 – a 2 – b 3 – c I tried this: UPDATE operador SET idoperador=(SELECT row_number() OVER (ORDER BY idoperador) from operador) But

Re: [GENERAL] renumber table

2008-06-20 Thread Steve Clark
David Spadea wrote: Steve, I'd just like to add that I agree with Scott that this is asking for trouble if the field being renumbered is used as a foreign key somewhere. If you have no way of changing this logic, you should at least look into 'on delete cascade' and 'on update cascade' on you

Re: [GENERAL] renumber table

2008-06-19 Thread David Spadea
Steve, I'd just like to add that I agree with Scott that this is asking for trouble if the field being renumbered is used as a foreign key somewhere. If you have no way of changing this logic, you should at least look into 'on delete cascade' and 'on update cascade' on your dependent tables. You c

Re: [GENERAL] renumber table

2008-06-19 Thread David Spadea
Steve, Here's your problem and its solution as I understand it: -- Given an example table like this (data isn't too important -- just the sequencing) create table meh ( idserial primary key , word varchar(10) ); -- Populate it with data insert into meh (word) values ('on

Re: [GENERAL] renumber table

2008-06-19 Thread David Wilson
On Thu, Jun 19, 2008 at 7:54 AM, Steve Clark <[EMAIL PROTECTED]> wrote: > I am not sure that will do what I want. As an example > suppose I have 5 rows and the idfield is 1,2,3,4,5 > now row 1 is updated, not the idfield but another column, then row 3 is > deleted. > Now I would like to renumber

Re: [GENERAL] renumber table

2008-06-19 Thread Steve Clark
Scott Marlowe wrote: On Wed, Jun 18, 2008 at 3:50 PM, Steve Clark <[EMAIL PROTECTED]> wrote: I realize this is certainly not the best design - but at this point in time it can't be changed. The table is rarely updated and never concurrently and is very small, typically less than 100 rows so the

Re: [GENERAL] renumber table

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 3:50 PM, Steve Clark <[EMAIL PROTECTED]> wrote: > > I realize this is certainly not the best design - but at this point in time > it can't be changed. The table > is rarely updated and never concurrently and is very small, typically less > than 100 rows so there really is >

Re: [GENERAL] renumber table

2008-06-18 Thread Steve Clark
Scott Marlowe wrote: On Wed, Jun 18, 2008 at 2:58 PM, Steve Clark <[EMAIL PROTECTED]> wrote: 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 whi

Re: [GENERAL] renumber table

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 2:58 PM, Steve Clark <[EMAIL PROTECTED]> wrote: > 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 h

[GENERAL] renumber table

2008-06-18 Thread Steve Clark
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 fi