pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Philip Semanchuk <philip@americanefficient.com>
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: ALTER COLUMN to change GENERATED ALWAYS AS expression?
Date: Tue, 07 Feb 2023 09:30:48 +0100
Message-ID: <6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at> (raw)
In-Reply-To: <4C775CB6-D73C-42B6-A94E-40C495AAA521@americanefficient.com>
References: <4C775CB6-D73C-42B6-A94E-40C495AAA521@americanefficient.com>

On Mon, 2023-02-06 at 12:04 -0500, Philip Semanchuk wrote:
> I have a column defined GENERATED ALWAYS AS {my_expression} STORED. I’d like to change the
> {my_expression} part. After reading the documentation for ALTER TABLE
> (https://www.postgresql.org/docs/current/sql-altertable.html) and trying a few things that
> resulted in syntax errors, there doesn’t seem to be a way to alter the column’s GENERATED
> expression in place. It seems like my only option is to drop and re-add the column.
> Is that correct?

I think that is correct.  But changing the expression would mean rewriting the column
anyway.  The only downside is that a dropped column remains in the table, and no even
a VACUUM (FULL) will get rid of it.

Yours,
Laurenz Albe





view thread (9+ messages)  latest in thread

Message-ID: <6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at>
Permalink:  ../6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at/
Also on:    postgresql.org/message-id/6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at

 · 

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: laurenz.albe@cybertec.at, philip@americanefficient.com
  Subject: Re: ALTER COLUMN to change GENERATED ALWAYS AS expression?
  In-Reply-To: <6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at>
  References: <4C775CB6-D73C-42B6-A94E-40C495AAA521@americanefficient.com> <6442cf200b9ba3d86e695172c4da98a802bda48e.camel@cybertec.at>

* 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