Re: How to find all current sequence IDs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Campbell, Lance" <lance(at)illinois(dot)edu>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: How to find all current sequence IDs
Date: 2024-02-21 22:13:56
Message-ID: 174178.1708553636@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"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 Nisarg Patel 2024-02-21 23:17:15 Re: How to find all current sequence IDs
Previous Message Campbell, Lance 2024-02-21 22:06:55 How to find all current sequence IDs