dbTalk Databases Forums  

catching up an id sequence

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss catching up an id sequence in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Austin Swinney
 
Posts: n/a

Default catching up an id sequence - 07-29-2004 , 04:21 PM






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.

In the Perl app associated with the DB, I swapped out currval for
mysql_insertid. Then I noticed that the currval reported is started
from 0, but there are already 1400+ records in that table that have id
numbers.

The definition in question is:

messageid | integer | not null default
nextval('public.message_messageid_seq'::text)

Ideas? Many thanks!

Austin


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: catching up an id sequence - 07-29-2004 , 05:01 PM






Austin Swinney <austin (AT) interactivate (DOT) com> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.