Re: Filling Missing Primary Key Values

From: Chris Travers <chris(dot)travers(at)gmail(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Filling Missing Primary Key Values
Date: 2011-08-11 19:37:58
Message-ID: CAKt_Zfv5mO79CbYLsXJ=iYiwThSu23mAk-UZ+EiMukJBc4a0pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 11, 2011 at 12:34 PM, Rich Shepard <rshepard(at)appl-ecosys(dot)com> wrote:
> On Thu, 11 Aug 2011, Chris Travers wrote:
>
>> The simplest seems to me to be a sequence and use nextval() to populate
>> the null values. The major advantage would be that the sequence could stay
>> around in case you need it again. So for example:
>>
>> create sequence my_varchar_values;
>
>> UPDATE my_table set my_varchar =
>> nextval('my_varchar_values')::varchar(12) where my_varchar IS NULL;
>
> Chris,
>
>  I was wondering if this was the best approach since I have new data to add
> to the table. Don't need a starting value, eh?
>
>
TBH, it's the approach I would use. It creates one additional
database object but the queries are simpler and thus more
maintainable.

Best Wishes,
Chris Travers

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-08-11 19:40:04 Re: Filling Missing Primary Key Values
Previous Message Rich Shepard 2011-08-11 19:34:27 Re: Filling Missing Primary Key Values