In PostgreSQL, the nextval()
function is used to advance sequence objects to their next value and return that value. We pass the name of the sequence when we call the function. This assumes that the sequence object exists.
Author: Ian
Fix “WRONGTYPE Operation against a key holding the wrong kind of value” when using ZINTERSTORE in Redis
If you get an error that reads “WRONGTYPE Operation against a key holding the wrong kind of value” when using the ZINTERSTORE
command in Redis, it’s probably because you’re passing a key with the wrong data type.
To fix this issue, be sure that each key you pass to the ZINTERSTORE
command is either a set or a sorted set.
How to Change the Range of a Sequence in SQL Server
SQL Server sequence objects allow us to increment or decrement through a range of numbers. Once set, we don’t need to change anything. We can simply use NEXT VALUE FOR
to generated the next sequential number.
But what if we want to change the sequence to use a different range?
For example, we created a sequence that increments between 0 and 100, but now we want to change it to increment between 200 and 300.
Easy. We can use the ALTER SEQUENCE
statement to do just that.
Get the Number of Rows Affected by Previous SQL Statement
Some RDBMSs provide an easy way for us to find out how many rows were affected by the last SQL statement. This can be handy when running INSERT
, UPDATE
, or DELETE
statements.
The method used depends on the DBMS we’re using. Below, I look at how some of the major DBMSs implement this functionality.
Continue reading@@ROWCOUNT vs ROWCOUNT_BIG() in SQL Server
SQL Server provides us with both a @@ROWCOUNT
and a ROWCOUNT_BIG()
function. You may be wondering what the difference is between these two functions?
Let’s find out.
Continue readingMySQL BENCHMARK() Explained
In MySQL, BENCHMARK()
is a built-in function that executes an expression repeatedly for a specified number of times.
It can be used to time how quickly MySQL processes the expression. Specifically, the function is intended for measuring the runtime performance of scalar expressions.
The result is always 0
, or NULL
for inappropriate arguments. The function is intended to be used within the mysql
command line tool, which reports query execution times.
Fix Msg 529 “Explicit conversion from data type date to int is not allowed” in SQL Server
If you’re getting SQL Server error Msg 529 that reads Explicit conversion from data type date to int is not allowed, it’s because you’re trying to explicitly convert a date data type to an int data type, which is not allowed in SQL Server.
To fix this issue, try converting the date value to a string first, and then to an integer.
Alternatively, change the destination type to one that’s allowed.
Also, check that you’re trying to convert the correct value. For example, you may have selected the wrong column or variable. In this case, selecting the correct column may fix the problem.
Continue readingWhat is CRUD?
In the world of database management systems (DBMSs) and computer programming, CRUD is an acronym that stands for Create, Read, Update, and Delete. These are considered to be the four basic operations of persistent storage.
Let’s take a look at how CRUD fits into database management systems and programming in general.
Continue readingFix “START value (…) cannot be greater than MAXVALUE (…)” When Creating a Sequence in PostgreSQL
If you’re getting an error that reads something like “START value (11) cannot be greater than MAXVALUE (10)” in PostgreSQL when you’re trying to create a sequence, it’s because your sequence’s start value is higher than its maximum value, when it should be lower or the same.
To fix this issue, be sure that the sequence’s maximum value is not less than its start value.
Continue readingHow to List the Time Zone Names in MySQL
By default, time zone names aren’t included with MySQL. The MySQL installation process creates the appropriate tables, but it doesn’t populate these tables.
That said, it’s very easy to populate these tables.
Once populated, we can list out the time zone names available in our system by querying the mysql.time_zone_name
table.