On Mon, 10 Jun 2024, Christophe Pettus wrote:
The sequence functions are documented here:
https://www.postgresql.org/docs/current/functions-sequence.html
setval is the function you want. You can use a SELECT so you don't have to
copy values around:
select setval('t_pk_seq', (sele
On Monday, June 10, 2024, Rich Shepard wrote:
>
> Is there a way to reset the sequence to the maximum
> number +1? I don't recall seeing this in the postgres docs but will look
> again.
>
https://www.postgresql.org/docs/current/functions-sequence.html
setval
The bigint argument can be compute
> On Jun 10, 2024, at 18:10, Rich Shepard wrote:
> Thanks, Christophe. Is there a way to reset the sequence to the maximum
> number +1? I don't recall seeing this in the postgres docs but will look
> again.
The sequence functions are documented here:
https://www.postgresql.org/docs/cu
On Mon, 10 Jun 2024, David G. Johnston wrote:
For efficiency the only thing used to determine the next value of a
sequence is the stored value of the last sequence value issued. Where that
value may have been used, in a table as a PK or some other purpose, does
not enter into it. Using a sequenc
On Mon, 10 Jun 2024, Christophe Pettus wrote:
Strictly speaking, the sequence underlying nextval() has no idea what
primary keys are or are not in use. It's just a transaction-ignoring
counter that increases with each nextval() call. The only reason that
you'd get duplicate key errors in this ca
> On Jun 10, 2024, at 15:57, Rich Shepard 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 underly
On Mon, Jun 10, 2024 at 3:57 PM Rich Shepard
wrote:
>
> I found a web page that explains how to find the gaps in a sequence, yet I
> want to understand why nextval() doesn't begin with the max(FK)+1 value.
>
For efficiency the only thing used to determine the next value of a
sequence is the stor