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

SQL ISNULL() Explained

Some RDBMSs provide an ISNULL() function that can be used when dealing with potentially null values.

MySQL, MariaDB, and Oracle Database each have an ISNULL() function that returns 1 if its argument is null, and 0 if it’s not.

SQL Server also has an ISNULL() function, but it works differently. It works more like how the IFNULL() function works in some other RDBMSs.

Other RDBMSs, such as PostgreSQL and SQLite don’t include an ISNULL() function, but they do support the IS NULL predicate (as do the other RDBMSs).

Continue reading