Re: How do I create unique IDs for an existing set of records
В списке pgsql-sql по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: How do I create unique IDs for an existing set of records |
| Дата | |
| Msg-id | 26777.1019837679@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | How do I create unique IDs for an existing set of records ("Nick Fankhauser" <nickf@ontko.com>) |
| Ответы |
Re: How do I create unique IDs for an existing set of records
|
| Список | pgsql-sql |
"Nick Fankhauser" <nickf@ontko.com> writes:
> I tried:
> update test set new_pk = (select nextval('test_new_pk_seq'));
> but it wants to update *all* of the rows to the current nextval (I was
> hoping it would evaluate nextval on each row).
Yeah, the sub-select is taken (perhaps mistakenly) as something that
can be evaluated only once, because it doesn't depend on the outer
query. You are overthinking the problem; this should work:
update test set new_pk = nextval('test_new_pk_seq');
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера