Re: Import id column then convert to SEQUENCE? - Mailing list pgsql-general

From Vick Khera
Subject Re: Import id column then convert to SEQUENCE?
Date
Msg-id AANLkTiksWTWcfgmaezbWfLa1ZrD5_yOEZ60zuV-NkL7_@mail.gmail.com
Whole thread Raw
In response to Re: Import id column then convert to SEQUENCE?  (Shoaib Mir <shoaibmir@gmail.com>)
List pgsql-general
On Thu, Dec 9, 2010 at 10:56 PM, Shoaib Mir <shoaibmir@gmail.com> wrote:
> I guess I misread it... use the following:
>
> - Import all the data into say an integer column.
> - Now create a sequence and give it a start value of where your import
> ended.
> - Make the default value for the column using the new sequence.
>

create the table with a SERIAL column, which will make the sequence
and set the auto increment default as you wanted.

import the data

update the sequence with setval() to the next highest value you want
it to return, usually max()+1 of the populated column.

pgsql-general by date:

Previous
From: Vick Khera
Date:
Subject: Re: Invalid byte sequence
Next
From: Peter Eisentraut
Date:
Subject: Re: Using regexp_replace to remove small words