From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | mgalvin(at)nycap(dot)rr(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Serial id not incrementing when manual ids are used, User Error? Bug? |
Date: | 2004-11-30 05:28:32 |
Message-ID: | 20041130052832.GA87521@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, Nov 29, 2004 at 03:47:27PM -0500, mgalvin(at)nycap(dot)rr(dot)com wrote:
> So does post not update a SERIAL column sequence when id's are
> manually entered? Would I have to manually do a nextval on the seq
> when manually setting id's? Should't post know that i used an id
> number and use the next availible number, something like ( (the
> largest id number in the key) + increment_val )?
SERIAL is just a convenient way of creating an INTEGER column with
a default value. If you provide a value for that column then the
default isn't used, so the INSERT never calls nextval() to increment
the sequence.
If you need to set some of the SERIAL column's values explicitly,
e.g., when importing data, then you can use ALTER SEQUENCE or
setval() when you're finished to change the sequence's value.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Mark | 2004-11-30 06:49:31 | Bug: 8.0.0b5 Win Server Installer |
Previous Message | Tom Lane | 2004-11-30 05:15:27 | Re: 8.0 Beta-5 Linux PSQL Endless loop -- Followup |