How to change definition of a Postgres 12 GENERATED column?
CREATE TABLE test (
id serial PRIMARY KEY,
val_a int4 NOT NULL DEFAULT 0,
val_b int4 NOT NULL DEFAULT 0,
val_sum int4 generated always AS (val_a + val_b) stored
);
I tried
ALTER TABLE test ALTER COLUMN val_sum TYPE int4 generated always AS (val_a + val_b + 1) stored;
ALTER TABLE test ALTER COLUMN val_sum SET generated always AS (val_a + val_b + 1) stored;
but both give syntax errors.
The alternative is to drop & add column, which works, but I wonder how to simply change it like any other column.