Re: Alter sequence restart with selected value... - Mailing list pgsql-general

From Jeff Ross
Subject Re: Alter sequence restart with selected value...
Date
Msg-id 46EFFBFE.8010203@wykids.org
Whole thread Raw
In response to Re: Alter sequence restart with selected value...  ("Scott Marlowe" <scott.marlowe@gmail.com>)
List pgsql-general
Scott Marlowe wrote:
> On 9/18/07, Jeff Ross <jross@wykids.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.


pgsql-general by date:

Previous
From: "Phoenix Kiula"
Date:
Subject: Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER
Next
From: Richard Broersma Jr
Date:
Subject: Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER