Re: Current value of a sequence?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adam Haberlach <adam(at)newsnipple(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Current value of a sequence?
Date: 2001-06-04 03:49:49
Message-ID: 25610.991626589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adam Haberlach <adam(at)newsnipple(dot)com> writes:
> I'm trying to find the next value that will be assigned by a sequence
> without actually incrementing it (yes, I know it isn't atomic-safe
> and all)

If you aren't very concerned about cross-transaction safety,

select last_value + increment_by from seq;

is approximately right.

There is a *lot* of discussion about this in the mailing list archives.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martín Marqués 2001-06-04 07:00:16 datestyle
Previous Message Tim Mickol 2001-06-04 02:48:38 RE: editing postgresql.conf for network access