0

[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
);
dh YB
  • 965
  • 3
  • 10

1 Answers1

0

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:

  • a trigger to set the column value
  • a view to show the upper name on the query Note that you don't need to store it in the table to get it indexed with:
create index animal_normalized_name on animal(upper(name::text));
dh YB
  • 965
  • 3
  • 10