Redis ZLEXCOUNT Command Explained

In Redis, the ZLEXCOUNT command returns the number of elements in a sorted set with a value between two given values. It can be used when we force lexicographical ordering by applying the same score to all members of a sorted set.

Read more

How LAST_INSERT_ID() Works in MySQL

In MySQL, the LAST_INSERT_ID() function returns the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement.

It can also be called with an argument, in which case, it returns the value of the expression and the next call to LAST_INSERT_ID() will return the same value.

Read more

Fix “Cannot DROP SEQUENCE ‘…’ because it is being referenced by object” in SQL Server

If you’re getting an error that reads something like “Cannot DROP SEQUENCE ‘Sequence2’ because it is being referenced by object ‘DF__Dogs__DogId__6C190EBB’“, it could be because you’re trying to drop a sequence object that’s referenced by a DEFAULT constraint.

Sequences that are referenced by a DEFAULT constraint can’t be dropped until the DEFAULT constraint is dropped.

Therefore, to fix this issue, drop the DEFAULT constraint first.

Read more

MySQL ICU_VERSION() Explained

In MySQL, the ICU_VERSION() function returns the version of the International Components for Unicode (ICU) library used to support regular expression operations.

The ICU_VERSION() function is primarily intended for use in test cases.

Read more

2 Ways to Set a Maximum and/or Minimum Value when Creating a Sequence in SQL Server

By default, SQL Server sets its own minimum and maximum values for sequence objects based on the data type of the sequence object. Assuming we don’t set the data type for the sequence, these min/max values are based on the bigint data type (because that’s the default data type for sequence objects in SQL Server).

However, we can also set our own minimum and maximum values for our sequences. We can do this either explicitly (by setting the MAXVALUE and MINVALUE properties) or implicitly (by setting the data type).

Read more

Fix “START value (…) cannot be less than MINVALUE (…)” When Creating a Sequence in PostgreSQL

If you’re getting an error that reads something like “START value (0) cannot be less than MINVALUE (1)” in PostgreSQL when you’re trying to create a sequence, it’s because your sequence’s start value is lower than its minimum value, when it should be at least the same or higher.

To fix this issue, be sure that the sequence’s start value is at least the same or greater than the minimum value.

Read more