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
@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
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
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
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
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
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
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
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
>
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
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
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
12 matches
Mail list logo