tacnode

Generated Columns

Generated Columns automatically calculate values from other columns or expressions, storing the results directly in the table. Syntax:

column_name data_type GENERATED ALWAYS AS (expression) STORED

Consider the following points:

  • Generated columns depend on other columns and cannot have assigned values.

  • Expressions should not include volatile functions or subqueries.

  • These columns can be used as part of the index to improve query performance.

Example:

CREATE TABLE products (
    product_id INT,
    name TEXT,
    price NUMERIC,
    tax NUMERIC,
    final_price NUMERIC GENERATED ALWAYS AS (price * (1 + tax)) STORED
);

In summary, Generated Columns streamline SQL operations by automatically computing derived columns, a significant feature of Tacnode.

For additional information, please refer to Generated Columns.

On this page

No Headings