Re: lastval(seq) ?

From: Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: lastval(seq) ?
Date: 2003-10-21 20:12:36
Message-ID: 20031021201236.GA29235@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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[(at)]dcc(dot)uchile(dot)cl>)
"El sabio habla porque tiene algo que decir;
el tonto, porque tiene que decir algo" (Platon).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-10-21 20:43:15 Re: lastval(seq) ?
Previous Message Jean-Michel POURE 2003-10-21 20:05:36 Re: DBDesigner for Linux