Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group