How to Create a Generated Column in MariaDB

A generated column is a database column whose value is an expression. Therefore, the value of the generated column is usually derived (for example, it could be derived from values in other columns).

Generated columns are also sometimes referred to as computed columns or virtual columns.

Creating a generated column in MariaDB is essentially the same as creating a normal column. The difference is that the definition of the generated column contains an expression that determines the column’s value.

Continue reading

MariaDB CASE Statement

In MariaDB, the CASE statement can be used in stored programs to perform a complex conditional construct. It compares a list of conditions and returns a different result depending on which condition (if any) is matched.

The CASE statement is distinct from the CASE operator, in that the CASE statement is specifically for use in stored programs. Also, there’s a slight difference in the syntax.

Continue reading

How NVL2() Works in MariaDB

In MariaDB, the NVL2() function allows us to replace a value with another value, the new value being determined by whether or not the initial value is null.

It’s similar to the NVL() function, except that NVL2() accepts three arguments instead of two. This allows us to specify a different value to return in the event the first argument is not null.

Continue reading