yugabytedb

Generated columns in YugabyteDB


[Question posted by a user on YugabyteDB Community Slack]

I'm studying YB for a while and I faced a problem. I try to create Generated Columns but this feature is available in PostgreSQL 12 so I would like to know if YB has a plan to support this feature or if there is any solution that is similar to the feature.

This is a example statement.

CREATE TABLE animal (
id int NOT NULL GENERATED ALWAYS AS IDENTITY,
name text,
normalized_name text GENERATED ALWAYS AS (upper(name::text)) STORED
);

Solution

  • For the moment (we will move to PostgreSQL 13 compatibility soon) the GENERATED ALWAYS AS IDENTITY is supported but the one on (upper(name::text)) is not. Workarounds are:

    create index animal_normalized_name on animal(upper(name::text));