Postgres 12+ 支持生成的列:https ://www.postgresql.org/docs/current/ddl-generated-columns.html
从文档来看,语法似乎是有限的——它强制人们显式地命名生成列所依赖的列。
CREATE TABLE people (
...,
height_cm numeric,
height_in numeric GENERATED ALWAYS AS (height_cm / 2.54) STORED
);
有没有办法将整行传递给生成函数?就像是
CREATE TABLE people (
...,
height_cm numeric,
height_in numeric GENERATED ALWAYS AS generator_function(current_row) STORED
);