Re: last inserted raw (identity)
От | nolan@celery.tssi.com |
---|---|
Тема | Re: last inserted raw (identity) |
Дата | |
Msg-id | 20030802052229.8727.qmail@celery.tssi.com обсуждение исходный текст |
Ответ на | Re: last inserted raw (identity) (Martijn van Oosterhout <kleptog@svana.org>) |
Ответы |
Re: last inserted raw (identity)
|
Список | pgsql-general |
> > In short, I think the answer to the original question is that there is no > > reliable way to find out what the last record inserted was. > > It returns the last record *you* entered. If you want the last record > entered by anyone (committed ofcourse), you'd use order by x desc limit 1. I agree that currval() would return the last record *I* inserted, but I don't understand how an order by clause would always return the last record that *ANYBODY* inserted. (And I thought that was the original question, but perhaps I am mis-remembering it at this point.) If another user has a cache of 10 sequence values, there's no way for me to know that. Thus when the other user inserts a record using one of those cached sequence values, it could be either higher or lower than the sequence value in MY most recently inserted record. (I think it could be higher only if I also have my own cache of sequence values, assuming that the sequence never wraps.) -- Mike Nolan
В списке pgsql-general по дате отправления: