Re: lastval(seq) ? - Mailing list pgsql-general

From Alvaro Herrera Munoz
Subject Re: lastval(seq) ?
Date
Msg-id 20031021201236.GA29235@dcc.uchile.cl
Whole thread Raw
In response to Re: lastval(seq) ?  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
On Tue, Oct 21, 2003 at 12:49:39PM -0700, CSN wrote:

> For updating sequences after copy importing data (with
> id's).
>
> Is there a transaction-safe way?

Sure:

begin;
lock table table;
select setval('table_id_seq', (select max(id) from table));
commit;

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"El sabio habla porque tiene algo que decir;
el tonto, porque tiene que decir algo" (Platon).

pgsql-general by date:

Previous
From: Jean-Michel POURE
Date:
Subject: Re: DBDesigner for Linux
Next
From: "scott.marlowe"
Date:
Subject: Re: lastval(seq) ?