Re: Alter sequence restart with selected value...

From: Jeff Ross <jross(at)wykids(dot)org>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alter sequence restart with selected value...
Date: 2007-09-18 16:25:11
Message-ID: 46EFFBFE.8010203@wykids.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Marlowe wrote:
> On 9/18/07, Jeff Ross <jross(at)wykids(dot)org> wrote:
>> I'm using copy to insert a bunch of rows into a new table with a unique
>> primary key. Copy is correctly incrementing the primary key, but
>> apparently the sequence itself is never updated because when I go to
>> insert again I get a constraint violation.
>
> Try using setval.
>
> select setval('seqname',select max(id) from tablename));
>
>
> !DSPAM:46eff995184363531088756!
>

Oh, I knew it was going to be something simple!

Than you, Scott.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2007-09-18 16:29:14 index fillfactor (was Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER)
Previous Message Phoenix Kiula 2007-09-18 16:16:55 Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER