Ever since Redis 4.0.0, the HSET
command has allowed us to add (and update) multiple fields to a hash.
Prior to Redis 4.0.0, we needed to use the (now deprecated) HMSET
command to add more than one field at once.
Ever since Redis 4.0.0, the HSET
command has allowed us to add (and update) multiple fields to a hash.
Prior to Redis 4.0.0, we needed to use the (now deprecated) HMSET
command to add more than one field at once.
If you’re getting an error that reads something like “The requested range for sequence object ‘Sequence1’ exceeds the maximum or minimum limit. Retry with a smaller range.” in SQL Server, it’s probably because you’re trying to return a value that’s outside the range of the sequence object.
This can happen when you’re using the sp_sequence_get_range
stored procedure to return a range from a sequence object that exceeds the minimum or maximum value for that sequence object, and the sequence object does not have CYCLE
defined. It’s a similar error to error 11728, which can happen when using NEXT VALUE FOR
to generate a new value from a sequence.
If you’re getting an error that reads something like “The sequence object ‘…’ has reached its minimum or maximum value. Restart the sequence object to allow new values to be generated.“, it’s probably because you’re using a sequence that’s reached the minimum or maximum value specified in its definition.
Continue readingWe can use MariaDB’s SHOW CREATE TABLE
statement to generate a CREATE TABLE
script for existing tables in the database. This allows us to recreate the table without having to manually type out the table’s definition.
The statement requires SELECT
privilege for the table.
If you’re getting an error that reads “NEXT VALUE FOR function cannot be used directly in a statement that contains an ORDER BY clause unless the OVER clause is specified” in SQL Server, it’s probably because you’re trying to sort the results of a query that uses the NEXT VALUE FOR
function without using the OVER
clause.
By default, Redis’s HRANDFIELD
command returns distinct fields. In other words, it won’t return the same field multiple times – each field that’s returned by the command will only be returned once.
However, we can override this behaviour by using an negative count value for the count
argument.
When we pass a negative count
argument, the HRANDFIELD
command allows non-distinct fields to be returned.
There are various methods for cloning/copying tables with SQL, but not all methods are supported by all RDBMSs.
Below are two options for cloning a table in SQL Server.
Continue readingIn PostgreSQL, we can use the RETURNING
clause to return data that was modified during an UPDATE
, INSERT
, or DELETE
operation. This allows us to see the data that was modified without having to perform a separate query to retrieve that data.
In SQL Server, we can use sequences to generate sequence numbers that increment by a specified amount. This means that any new number generated by the sequence will be the next sequential increment as specified in the sequence’s definition.
Normally, this is exactly what we want. We want each number to adhere to the increment that we specified when defining the sequence.
But what if we want to reset the sequence, so that the numbering starts all over again? In other words, we want to restart the sequence from the beginning. Or what if we want to reset the sequence so that it increments in a different range?
Fortunately, we can reset a sequence with the ALTER SEQUENCE
statement.
If you’re getting an error that reads “WRONGTYPE Operation against a key holding the wrong kind of value” when using the Redis HSTRLEN
command, it’s probably because you’re running the command against a key that doesn’t contain a hash.