Re: Serial id not incrementing when manual ids are used, User Error? Bug?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Serial id not incrementing when manual ids are used, User Error? Bug?
Дата
Msg-id 20041130052832.GA87521@winnie.fuhr.org
обсуждение исходный текст
Ответ на Serial id not incrementing when manual ids are used, User Error? Bug?  (mgalvin@nycap.rr.com)
Список pgsql-bugs
On Mon, Nov 29, 2004 at 03:47:27PM -0500, mgalvin@nycap.rr.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/

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: 8.0 Beta-5 Linux PSQL Endless loop -- Followup
Следующее
От: "PostgreSQL Bugs List"
Дата:
Сообщение: BUG #1333: vacuum full apparently fails to complete