Querying the last value of all sequences

From: <btober(at)seaworthysys(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Querying the last value of all sequences
Date: 2003-04-30 21:20:23
Message-ID: 65086.216.238.112.88.1051737623.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I know that I can get a list of all sequences with

SELECT
c.relname AS sequencename
FROM pg_class c WHERE (c.relkind = 'S');

which produces, for example,

country_country_pk_seq
province_province_pk_seq
city_city_pk_seq
postal_code_postal_code_pk_seq

And I know I can get the last value from a particular sequence with

SELECT
sequence_name,
last_value
FROM city_city_pk_seq

which produces, for example

city_city_pk_seq 14702

But how can I get a list of sequence names and the respective last value
for ALL sequences?

~Berend Tober

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua Drake 2003-04-30 21:39:48 Re: Upgrade to RedHat 9.0 broke PostgreSQL
Previous Message scott.marlowe 2003-04-30 21:09:52 Re: Buffer Cache question....