Search Postgresql Archives

Re: Alter sequence restart with selected value...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/18/07, Jeff Ross <jross@xxxxxxxxxx> 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));

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux