Re: Ref to last INSERT on a table without OIDs?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Ref to last INSERT on a table without OIDs?
Дата
Msg-id 20030128170842.GB14694@wolff.to
обсуждение исходный текст
Ответ на Ref to last INSERT on a table without OIDs?  ("Mark Cave-Ayland" <mark.cave-ayland@webbased.co.uk>)
Список pgsql-general
On Tue, Jan 28, 2003 at 14:25:32 -0000,
  Mark Cave-Ayland <mark.cave-ayland@webbased.co.uk> wrote:
>
> Hopefully just a quick one: how is it possible to obtain a reference to
> the last inserted record in a table which is created without oids? I
> would like to dump/restore some of our larger tables so they don't use
> oids, however I am concerned that simply getting the current PK sequence
> value after insertion within a transaction is not safe when many people
> are accessing the table/sequence at once? Can anyone clarify this? We're
> using the latest and greatest 7.3.1.

If you are trying to get the primary key of the last record inserted during
the same database session, then using serial for the type of the primary
key and the currval function is exactly what you want.

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Ref to last INSERT on a table without OIDs?
Следующее
От: Vivek Khera
Дата:
Сообщение: Re: Vacuum verbose output?