Below are the steps that I used to install Redis on my M1 Mac. The M1 Mac (and M2) uses the ARM64 architecture, but this is not a problem, as Redis versions 4.0 and above support the ARM architecture.
Continue readingHow to Convert to Lowercase in SQLite
In SQLite we can use the lower()
function to convert uppercase characters to lowercase.
SQL NVL2() Explained
Some DBMSs have an NVL2()
function that 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 exactly three arguments. This allows us to specify a different value to return in the event the first argument is not null.
In contrast, with the NVL()
function, some DBMSs accept only two arguments (which makes the function a synonym for the IFNULL()
function) while others accept an unlimited number of arguments (which makes it a synonym for the COALESCE()
function).
SQL NVL() Explained
Some DBMSs provide an NVL()
function, which can be used when working with potentially NULL values. The function allows us to replace any NULL values with another value.
Find Duplicate Rows that have a Primary Key in SQL
Here are examples of using SQL to return duplicate rows when those rows have a primary key or other unique identifier column.
These queries work in most of the major RDBMSs, including SQL Server, Oracle, MySQL, MariaDB, PostgreSQL, and SQLite.
Continue readingHow to Get the Definition of a Generated Column in PostgreSQL
If you have a generated column in PostgreSQL, you can use the following methods to find the definition of that column.
Continue readingAdd Years to a Date in SQLite
In SQLite, we can use the DATE()
function to add one or more years to a date.
For datetime values, we can use the DATETIME()
function.
Find Rows that Contain Lowercase Characters in SQL
Most RDBMSs provide at least a few ways to return rows that contain lowercase characters. Here are some options available in the major RDBMSs.
Continue readingOracle CASE Statement
In Oracle Database, the CASE
statement compares a list of conditions and returns one of multiple possible expressions.
Oracle Database’s CASE
statement is very similar to the CASE
expression (which is defined in the SQL standard (ISO/IEC 9075)). However, Oracle supports both the CASE
expression and the CASE
statement, and there’s a distinction between the two. The CASE
statement can be used to execute of a sequence of PL/SQL statements, whereas the CASE
expression returns a single value. Also, there’s a difference in how they deal with the lack of an ELSE
clause when a condition is not met.
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