From: | Dave Cramer <davecramer(at)postgres(dot)rocks> |
---|---|
To: | hans(at)matfyz(dot)cz, pgsql-docs(at)lists(dot)postgresql(dot)org |
Subject: | Re: SELECT last_value FROM sequence_name; |
Date: | 2021-04-12 09:10:53 |
Message-ID: | CADK3HHJ1Y45Ka9bJ3_bo3GuM8ea=xK9gkodwmhCZ5hc7evoBAg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
On Mon, 12 Apr 2021 at 04:50, PG Doc comments form <noreply(at)postgresql(dot)org>
wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/functions-sequence.html
> Description:
>
> Please add Note, how to get the (global) last value:
> SELECT last_value FROM sequence_name;
>
> https://dba.stackexchange.com/questions/3281/how-do-i-use-currval-in-postgresql-to-get-the-last-inserted-id
The reason this is not added is that it is incorrect to use the sequence
this way. How do you know which session incremented it, or if it has been
incremented since the last use ? The correct way to use a sequence is to
increment it and then use currval or the like
Dave Cramer
www.postgres.rocks
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2021-04-12 21:08:35 | Re: repeated info in sections 4.1.1, 4.1.2.3 |
Previous Message | PG Doc comments form | 2021-04-12 08:47:22 | SELECT last_value FROM sequence_name; |