I try to add a column to my table which references the BMI and I already have 2 columns with height and weight. I want to generate automatically this column when I fill the 2 others. But I get an error and I don't find any answer to solve it.
CREATE TABLE player
(
id INT PRIMARY KEY NOT NULL,
height INT,
weight INT
);
ALTER TABLE player ADD COLUMN bmi FLOAT GENERATED ALWAYS AS (weight/((height/100)^2)) STORED;
I get following error :
ERROR: syntax error at or near "("
LINE : ...E player ADD COLUMN bmi FLOAT GENERATED ALWAYS AS (weight/((h...
SQL state: 42601 Character: 61