In Redis, the MSET
command allows us to set multiple keys at once. It replaces any existing values, just as SET
does.
Category: DBMS
Database Management Systems
SQL Server CASE Statement
The SQL Server CASE
statement evaluates a list of conditions and returns one of multiple possible result expressions.
Although it’s commonly known as the “CASE
statement”, the SQL Server documentation lists it as an expression. Plus it’s referred to as the “CASE
expression” in the SQL standard. Some other DBMSs distinguish between the CASE
statement and the CASE
expression. Either way, here’s a quick rundown on how the “CASE
statement” (or CASE
expression) works in SQL Server.
Redis SET Command Explained
In Redis, the SET
command sets a key to hold a given string value.
If the key already holds a value, it is overwritten with the new value. Also, any previous time to live associated with the key is discarded (assuming a successful SET
operation).
Redis GET Command Explained
In Redis, the GET
command returns the value of a given key. If the key doesn’t exist, it returns nil
.
An error is returned if the value stored at key
is not a string.
Redis LASTSAVE Command Explained
When using Redis, we can use the LASTSAVE
command to get the Unix time of the last DB save.
More specifically, LASTSAVE
returns the Unix time of the last DB save executed with success.
Install Redis on a Mac with Homebrew
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 reading