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

Re: AutoIncrement not working on this table only

From: Kassel Ben CRBE <KasselB(at)nswccd(dot)navy(dot)mil>
To: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: AutoIncrement not working on this table only
Date: 2002-11-05 02:10:57
Message-ID: 1F9F67162ADED3119F18009027A8F404025FC3A2@crbeex03.dt.navy.mil (view raw or flat)
Thread:
Lists: pgsql-novice
A huge thank you to all who helped me solve my problem. To synopsize for those keeping a lessons learned:

The sequence table got out of sync with the with the column being sequenced. This was mot probably caused by reloading data improperly without regard for the sequence generated value. 

The sequence can be resynced using the command:

select (setval('my_seq',max(my_col)) from my_table; 

or in my case the actual command which solved the problem:

SELECT setval('datadef_datadefindex_seq',MAX(datadefindex)) from datadef; 

later,
ben

pgsql-novice by date

Next:From: Brian JohnsonDate: 2002-11-05 05:45:09
Subject: List sequence assigned to primary key
Previous:From: Josh BerkusDate: 2002-11-04 20:26:31
Subject: Re: Novice DB Schema question

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