How to Create a Generated Column in PostgreSQL

In PostgreSQL, a generated column is a special column that is always computed from other columns. A generated column doesn’t have a fixed value like in a base column. Rather, its value is determined by an expression that references other columns in the table.

Generated columns are included in the SQL standard (ISO/IEC 9075), and are supported by most major RDBMSs. Generated columns were first introduced in PostgreSQL 12.

Continue reading

2 Ways to Get the Definition of a Generated Column in MySQL

A generated column is one whose value is derived from an expression, as opposed to a fixed value. The expression typically uses other columns in the same table to compute the derived value.

We can create a generated column in MySQL very easily. But what if we want to go back later and see its definition?

Here are two options for returning the definition of a generated column in MySQL.

Continue reading