Re: using sequences
От | Erik Price |
---|---|
Тема | Re: using sequences |
Дата | |
Msg-id | 3EEF653D.3090808@ptc.com обсуждение исходный текст |
Ответ на | Re: using sequences (Bruno Wolff III <bruno@wolff.to>) |
Список | pgsql-general |
Bruno Wolff III wrote: >>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. Thank you for that very clear explanation. I now understand both points (esp about not depending on the values to be sequential outside of a single session, which I hadn't considered before). Regards, Erik
В списке pgsql-general по дате отправления: