Re: Alter sequence restart with selected value...

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

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));

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Phoenix Kiula 2007-09-18 16:16:55 Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER
Previous Message Jeff Ross 2007-09-18 15:58:01 Alter sequence restart with selected value...