Re: collision in serial numbers after INSERT?
От | Bill Moran |
---|---|
Тема | Re: collision in serial numbers after INSERT? |
Дата | |
Msg-id | 20070603180801.b4f608fe.wmoran@potentialtech.com обсуждение исходный текст |
Ответ на | Re: collision in serial numbers after INSERT? (Steve Lefevre <lefevre.10@osu.edu>) |
Список | pgsql-general |
Steve Lefevre <lefevre.10@osu.edu> wrote: > > Bill Moran wrote: > > Don't do that. Please let us know what site recommended that so I can > > send an email to the author correcting them. > > > Hello Bill - > > The 'offending' site and article is at > http://www.sitepoint.com/article/site-mysql-postgresql-2/3 My goodness, that article is ancient. 2001. I have a hard time believing he's going to update it if it's been wrong that long. > > Instead, do SELECT currval('<seqname>'), which is guaranteed to be isolated > > from other sessions. > > > I've also gotten other advice to SELECT next_val ( whatever the exact > wording is) will reserve that serial number for you. Is that true? Yes, please see the documentation. Both currval() and next_val() are transaction safe (thus guaranteed not to cause overlapped serials) but they do slightly different things. -- Bill Moran http://www.potentialtech.com
В списке pgsql-general по дате отправления: