The Redis HKEYS
command returns all fields in the hash stored at the specified key.
Redis HDEL Command
In Redis, the HDEL
command enables us to delete one or more fields in a hash. It deletes the specified field/s at the specified key.
If the field doesn’t exist, it’s ignored. If the key doesn’t exist, it’s treated as an empty hash and 0
is returned.
Redis HSETNX Command
In Redis, the HSETNX
command enables us to set a field in a hash, but only if the field doesn’t already exist. It sets the field at the specified key to the value we provide.
If the key doesn’t exist, it’s created with the specified hash value. If the field already exists, nothing is set (i.e. the command has no effect).
Continue reading5 Ways to Create a Table in SQL
Probably the most common way of creating a table in SQL is to use a basic CREATE TABLE
statement, along with the table’s definition. But that’s not the only way of doing it.
Below are five options for creating a table when using SQL.
Continue readingRedis HSET Command
In Redis, the HSET
command enables us to set one or more fields in a hash. It sets the field/s at the specified key to the value/s we provide.
If the key doesn’t exist, it’s created with the specified hash value. If the field already exists, it is overwritten with the new value.
Continue reading7 Ways to Insert Multiple Rows in SQL
We can use the SQL INSERT
statement to insert a row into a table. We can also use it to insert more than one row.
Below are seven ways to insert multiple rows into a table in SQL. Most of these examples should work in the major RDBMSs, with the possible exception of Oracle. But no worries, I’ve included an example just for Oracle.
Continue readingFix “One or more scores can’t be converted into double” when using SORT or SORT_RO in Redis
If you’re getting an error that reads “One or more scores can’t be converted into double” when using either the SORT
or SORT_RO
commands in Redis, it could be because you omitted the ALPHA
modifier when trying to sort string values.
If you want to sort string values lexicographically, you need to use the ALPHA
modifier when using the SORT
or SORT_RO
command.
Add Minutes to a Time Value in SQLite
In SQLite, we can use the TIME()
function to add a given number of minutes to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
Fix: “ERR wrong number of arguments for ‘smembers’ command” in Redis
If you’re getting an error that reads “ERR wrong number of arguments for ‘smembers’ command” in Redis, it’s because you’re calling the SMEMBERS
command with the wrong number of arguments.
To fix this issue, make sure you’re passing the correct number of arguments. At the time of writing, the correct number of arguments for this command is one.
Continue readingHow to Rename a Key in Redis Without Fear of Overwriting any Existing Keys
If you need to rename a key in Redis, you may be wondering how to do it without overwriting any existing keys. If you use the RENAME
command, and a key already exists with your new key name, you’ll overwrite the existing key.
Fortunately, Redis also has a RENAMENX
command, which only renames the key if there’s no other key with the new name. So we can use this command whenever we need to rename a key without fear of overwriting any existing keys.