Re: Querying the last value of all sequences

From: DeJuan Jackson <djackson(at)speedfc(dot)com>
To: btober(at)seaworthysys(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Querying the last value of all sequences
Date: 2003-05-13 19:44:31
Message-ID: 3EC14B1F.1010400@speedfc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You could make creative use of psql (if you just want the results for
yourself);

\a
\t

SELECT
'SELECT
sequence_name,
last_value
FROM' || c.relname
FROM pg_class c WHERE (c.relkind = 'S') \g | psql <database>
\t
\a

btober(at)seaworthysys(dot)com wrote:

>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
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/docs/faqs/FAQ.html
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeremiah Elliott 2003-05-13 20:11:17 Relation "pg_relcheck" does not exist
Previous Message Bruno Wolff III 2003-05-13 19:20:18 Re: Creating functions and triggers