pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastien Flaesch <sebastien.flaesch@4js.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Get the sequence name corresponding to a GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY column
Date: Mon, 6 Feb 2023 17:17:17 +0000
Message-ID: <DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> (raw)

Hello!

Assuming that a sequence is used to implement GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY

Is there any built-in function that returns the underlying sequence name used for such column?

Otherwise, an SQL query to return the sequence name?

I need the sequence name, in order to reset it (setval) or to get the last generated value (currval) ...

The query must work with all PostgreSQL versions 10 to 15 ...

Seb

view thread (7+ messages)  latest in thread

Message-ID: <DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
Permalink:  ../DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sebastien.flaesch@4js.com
  Subject: Re: Get the sequence name corresponding to a GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY column
  In-Reply-To: <DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
  References: <DBAP191MB12892E942BD10BC2F46A354EB0DA9@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox