Re: sequence, set value of

Поиск
Список
Период
Сортировка
От GH
Тема Re: sequence, set value of
Дата
Msg-id 20010617192910.A15196@over-yonder.net
обсуждение исходный текст
Ответ на Re: sequence, set value of  (zilch@home.se)
Ответы Re: sequence, set value of
Список pgsql-general
On Sun, Jun 17, 2001 at 08:51:56PM +0200, some SMTP stream spewed forth:
>
> So, if I want the next insert to make the ID automatically 1, i can't use
> SERIAL since that gives me a sequence of minvalue 1? Wich results in a id =
> 2 in the next insert.
>
> Right?

No. Serial has a minval of 1, correct. However, when the minval is one
and nextval is one, the nextval is...one.
In other words, a newly created serial sequence will return 1 the first
time it is called and 2 the second time. (The case is special when
creating sequences for use
as a serial because you, IIRC, must call nextval() once to make the
nextval one. In other words, the first two values out of a newly created
non-serial sequence with minval=1 are one.)

>
> Daniel Akerud

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Call for alpha testing: planner statistics revisions
Следующее
От: Randall Perry
Дата:
Сообщение: Re: canned code to get db on web quickly via perl or PHP?