Re: resetting sequence to cur max value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: developer(at)wexwarez(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: resetting sequence to cur max value
Date: 2006-12-12 17:19:56
Message-ID: 4919.1165943996@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

developer(at)wexwarez(dot)com writes:
> Is there a way to set it up so it knows to skip past existing ids?

Usually you do something like

select setval('seq_name', (select max(idcol) from table) + 1);

after loading data into the table.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-12-12 17:22:16 Re: date comparisons
Previous Message Marc Mamin 2006-12-12 17:17:00 Re: a question on SQL