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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-novice by date

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