Arturo Perez wrote:
What happens is that if I do a select nextval('seq') I get a number
that's lower than the
max primary key id.  This is inspite of my doing
   SELECT setval('seq', ((SELECT MAX(seq_ID) FROM table)+1))
   ALTER SEQUENCE seq RESTART WITH <max + 1>;
   select pg_catalog.setval(seq, <max+1>, true);

This seems to be a bit over the top;
        SELECT setval('seq', (SELECT MAX(seq_ID) FROM table)
should be enough. Even the +1 isn't necessary, as the first value the sequence will return is already 1 higher than the value retrieved from MAX.

Are you sure you're using the correct sequence(s) to retrieve your column values for the problematic table(s)? How do you set the values for seqID?

Also note that a SERIAL type column is simply a macro for creating an INT4 type column with a DEFAULT nextval('...'). You can easily change your schema to include the defaults.

--
Alban Hertroys
[EMAIL PROTECTED]

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to