Re: Sequences, defaults and getting a new key

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Sequences, defaults and getting a new key
Дата
Msg-id 22507.1203657404@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Sequences, defaults and getting a new key  (Jeff Willden <jeff@pavanell.com>)
Список pgsql-novice
Jeff Willden <jeff@pavanell.com> writes:
> When the primary key of a table defaults to the nextval() of a
> sequence, if you insert a new record into the table and accept the
> default, how do you then select the value that was just used as the
> new primary key and guarantee that you don't accidentally get the
> value that another user just generated at about the same instant?

currval() or INSERT RETURNING would do it.  Check the archives for
a few thousand prior discussions ...

            regards, tom lane

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

Предыдущее
От: Jeff Willden
Дата:
Сообщение: Sequences, defaults and getting a new key
Следующее
От: Alex du Plessis
Дата:
Сообщение: Trigger question