Re: using sequences

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: using sequences
Дата
Msg-id 20030614122124.GA27374@wolff.to
обсуждение исходный текст
Ответ на Re: using sequences  (Erik Price <eprice@ptc.com>)
Ответы Re: using sequences  (Erik Price <eprice@ptc.com>)
Список pgsql-general
On Fri, Jun 13, 2003 at 17:29:01 -0400,
  Erik Price <eprice@ptc.com> wrote:
>
>
> Bruno Wolff III wrote:
>
> >If you are trying to do this you probably don't really understand
> >sequences.
> >There aren't any common good reasons for trying to get the value of a
> >sequence
> >before you have generated a value in the current session.
>
> It seems you're right that I dont understand them.  However, I don't
> have any intent of calling it like this (without having generated a
> value), rather, I was simply curious and playing around with the
> commandline client, and following some instructions I had seen in
> another post.  I didn't realize that it needed to be "activated" for the
> current session.

"activated" isn't really the right word. When you call nextval you are
giving a number that is unique. No one else gets to see that number
(until you save it somewhere) which prevents contention between different
connections trying to get unique numbers from the same sequence.
currval is just a way to see the last value of nextval that was given to
you. If one hasn't been given to you, then there isn't anything for
currval to return.

Related to this is that you should only use the uniqueness of sequence
values. You shouldn't expect them to be continuous and you shouldn't
expect them to be monotonicly increasing other than within a single
session.

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

Предыдущее
От: Jason Godden
Дата:
Сообщение: Growing Database Size Solved
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Index not being used in MAX function (7.2.3)