Re: Convert pg_constraint.conkey array to same-order array of column names

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Convert pg_constraint.conkey array to same-order array of column names
Date: 2023-03-24 12:07:20
Message-ID: CAFCRh--8y2JYoqrrX3Pren2S8+ygTkSwozMCwxsnRXs3HKxHsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 24, 2023 at 11:51 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> On 2023-Mar-23, Dominique Devienne wrote:
> > But I'm wondering about getting 1 row per constraint instead,
> > and fetching an array of column names.
>
> IIRC you can use array_agg(unnest ORDER BY ordinality), grouping by
> constraint OID or name.
>

Thanks. This lead me to a better search, yielding two informative results:
https://stackoverflow.com/questions/60877627/perform-unnest-inner-join-and-then-array-agg-as-part-of-an-update-query
http://amyszczepanski.com/2019/03/25/unnest-and-array-agg-respecting-order.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2023-03-24 14:02:14 Re: Oracle to PostgreSQL Migration
Previous Message Inzamam Shafiq 2023-03-24 11:07:11 PostgreSQL vs MariaDB