Обсуждение: Sequence Manipulation Functions
Hello,
I use PostgreSQL 8.0.3.
I want to get the information of the last value of a sequence.
The function 'currval' only gives the value back, if before a nextval is executed.
Return the value most recently obtained by nextval for this sequence in the current session. (An error is reported if nextval has never been called for this sequence in this session.) Notice that because this is returning a session-local value, it gives a predictable answer whether or not other sessions have executed nextval since the current session did.
But that is not very helpful.
I noticed that the phpPgAdmin has that information
| Name | Last value | Increment by | Max value | Min value | Cache value | Log count | Is cycled? | Is called? |
|---|---|---|---|---|---|---|---|---|
| adr_dsnr | 108 | 1 | 9223372036854775807 | 1 | 1 | 25 | No | Yes |
So how can I get that information?
Thanks
Michaela
Select last_value from your_sequence_name; John MG wrote: > Hello, > > I use PostgreSQL 8.0.3. > > I want to get the information of the last value of a sequence. > > The function 'currval' only gives the value back, if before a nextval is executed. > Return the value most recently obtained by nextval for this sequence in the current session. (An error is reported if nextvalhas never been called for this sequence in this session.) Notice that because this is returning a session-local value,it gives a predictable answer whether or not other sessions have executed nextval since the current session did. > > But that is not very helpful. > > I noticed that the phpPgAdmin has that information > > Name Last value Increment by Max value Min value Cache value Log count Is cycled? Is called? > adr_dsnr 108 1 9223372036854775807 1 1 25 No Yes > > > So how can I get that information? > > Thanks > > Michaela > > > > >
MG schrieb: > Hello, > > I use PostgreSQL 8.0.3. > > I want to get the information of the last value of a sequence. > > The function 'currval' only gives the value back, if before a nextval is > executed. > > /Return the value most recently obtained by |nextval| for this sequence > in the current session. (An error is reported if |nextval| has never > been called for this sequence in this session.) Notice that because this > is returning a session-local value, it gives a predictable answer > whether or not other sessions have executed |nextval| since the current > session did./ > > But that is not very helpful. > > I noticed that the phpPgAdmin has that information > > Name Last value Increment by Max value Min value Cache value Log > count Is cycled? Is called? > adr_dsnr 108 1 9223372036854775807 1 1 25 No Yes > > So how can I get that information? > SELECT * FROM adr_dsnr; Otoh, for what do you need this information? Regards Tino
On Jan 10 03:56, MG wrote:
> I noticed that the phpPgAdmin has that information
>
> Name Last value Increment by Max value Min value Cache value Log count Is cycled? Is called?
> adr_dsnr 108 1 9223372036854775807 1 1 25 No Yes
test=# \d roomsold_main_id_seq
Sequence "public.roomsold_main_id_seq"
Column | Type
---------------+---------
sequence_name | name
last_value | bigint
increment_by | bigint
max_value | bigint
min_value | bigint
cache_value | bigint
log_cnt | bigint
is_cycled | boolean
is_called | boolean
test=# \x
Expanded display is on.
test=# SELECT sequence_name, last_value, increment_by, max_value,
test-# min_value, cache_value, log_cnt, is_cycled, is_called
test-# FROM roomsold_main_id_seq;
-[ RECORD 1 ]-+---------------------
sequence_name | roomsold_main_id_seq
last_value | 1
increment_by | 1
max_value | 9223372036854775807
min_value | 1
cache_value | 1
log_cnt | 1
is_cycled | f
is_called | f
HTH.
Regards.