Re: catching up an id sequence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Austin Swinney <austin(at)interactivate(dot)com>
Cc: pg novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: catching up an id sequence
Date: 2004-07-29 22:01:07
Message-ID: 17333.1091138467@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Austin Swinney <austin(at)interactivate(dot)com> writes:
> Hi most esteemed novices and experts. It is an honor to post here!
> I imported a MySQL dump into PostgreSQL (7.4.3) and was wondering what
> a good way to catch up the ID sequence table to be current with the
> table I imported.

You want setval(). The usual approach is

select setval('tab_col_seq', (select max(col) from tab) + 1);

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Steve Tucknott 2004-07-30 12:35:56 Significant spaces
Previous Message Austin Swinney 2004-07-29 21:21:59 catching up an id sequence