Re: Gaps in PK sequence numbers
От | Christophe Pettus |
---|---|
Тема | Re: Gaps in PK sequence numbers |
Дата | |
Msg-id | DB68A3C3-FCF6-4815-9C5C-A77310B66474@thebuild.com обсуждение исходный текст |
Ответ на | Gaps in PK sequence numbers (Rich Shepard <rshepard@appl-ecosys.com>) |
Ответы |
Re: Gaps in PK sequence numbers [RESOLVED]
|
Список | pgsql-general |
> On Jun 10, 2024, at 15:57, Rich Shepard <rshepard@appl-ecosys.com> wrote: > When I tried inserting new rows in the companies table psql told me that PK > value 2310 already existed. Selecting max(PK) returned 2341. When entering > multiple new rows is there a way to ignore gaps? Strictly speaking, the sequence underlying nextval() has no idea what primary keys are or are not in use. It's just a transaction-ignoringcounter that increases with each nextval() call. The only reason that you'd get duplicate key errorsin this case are: 1. The sequence was reset to a different, lower value. 2. Rows were inserted that didn't use the sequence to select a primary key.
В списке pgsql-general по дате отправления: