Re: noobie question

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Steve Clark <sclark(at)netwolves(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: noobie question
Date: 2013-01-24 17:20:37
Message-ID: 51016D65.80602@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/24/2013 08:47 AM, Steve Clark wrote:
> Hi list,
>
> This may be really simple - I usually do it using a procedural language
> such as php or a bash script.
>
> Say I have a table that has 2 columns like
> create table "foo" (
> id integer not null,
> name text
> );
> CREATE UNIQUE INDEX "foo_pkey" on "foo" using btree ( "id" "int4_ops" );
>
> with 10 rows of data where id is 1 to 10.
>
> Now I want to insert a new row ahead of id 5 so I have to renumber the rows
> from 5 to 10 increasing each by one.
>
> Or the opposite I want to delete a row an renumber to close up the gap.
>
> Is there an easy way to do this in postgresql without resulting to some
> external language?

I can see this taking a lot of overhead as the table increases.
I guess it comes down to what you are trying to achieve?
Do you want a gapless sequence?
Do you want a ROWNUM?
Something else?

>
> Thanks for your consideration.
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anson Abraham 2013-01-24 17:29:52 main.log file not being updated
Previous Message Gauthier, Dave 2013-01-24 16:58:00 Re: noobie question