public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: dfgpostgres <[email protected]>
Cc: [email protected]
Subject: Re: PG Unpivot ?
Date: Mon, 03 Nov 2025 12:33:23 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAAcmDX_KU4A1DWzKmO4XacVQ72+0KZ9rZSvQwHkCWgpqB-Lb2w@mail.gmail.com>
References: <CAAcmDX_KU4A1DWzKmO4XacVQ72+0KZ9rZSvQwHkCWgpqB-Lb2w@mail.gmail.com>

dfgpostgres <[email protected]> writes:
> I want 9 records returned, each row with 3 cols, 1st col is the ctid,
> second is the column name, third is the val.

Perhaps psql's "expanded" mode is close enough?

regression=# \x
Expanded display is on.
regression=# select * from unpivot;
-[ RECORD 1 ]---
intcol   | 1
floatcol | 1.1
strcol   | one
-[ RECORD 2 ]---
intcol   | 2
floatcol | 2.2
strcol   | two
-[ RECORD 3 ]---
intcol   | 3
floatcol | 3.3
strcol   | three

PS: I do not advise relying on ctid as a row identifier.
Use a proper primary key.

			regards, tom lane






view thread (2+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: PG Unpivot ?
  In-Reply-To: <[email protected]>

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

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