Re: How to find all current sequence IDs

From: Nisarg Patel <er(dot)nisarg(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Campbell, Lance" <lance(at)illinois(dot)edu>, pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: How to find all current sequence IDs
Date: 2024-02-21 23:17:15
Message-ID: CAA=RfSPoPw0ERRGEQTVGYvAzJjES42At0bhxCNvW1x_LnAu0nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This has worked for me in the past:
select schemaname, sequencename, last_value
from pg_sequences;

Thank you,
Nisarg

On Wed, Feb 21, 2024, 5:14 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "Campbell, Lance" <lance(at)illinois(dot)edu> writes:
> > Is there a way to get a list of all sequences, the schema it is used in,
> and the current sequence number in use?
>
> Try something like
>
> select relname, relnamespace::regnamespace, pg_sequence_last_value(oid)
> from pg_class where relkind = 'S';
>
> regards, tom lane
>
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Cars Jeeva 2024-02-22 10:42:08 PG_DUMP ERROR
Previous Message Tom Lane 2024-02-21 22:13:56 Re: How to find all current sequence IDs