Re: resetting sequence to cur max value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: developer(at)wexwarez(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: resetting sequence to cur max value
Date: 2006-12-13 03:48:10
Message-ID: 331.1165981690@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> On Tue, Dec 12, 2006 at 12:19:56PM -0500, Tom Lane wrote:
>> Usually you do something like
>> select setval('seq_name', (select max(idcol) from table) + 1);
>> after loading data into the table.

> Is "+ 1" necessary with the two-parameter form of setval()?

Given the docs you quoted, no --- I was just too lazy to look up whether
it set is_called or not. With the +1 you don't have to think ;-)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anton 2006-12-13 05:13:47 Re: Why DISTINCT ... DESC is slow?
Previous Message Tom Lane 2006-12-13 03:41:19 Re: Statement timeout not working on broken connections with active queries