How CURRVAL() Works in PostgreSQL

In PostgreSQL, the currval() function returns the value most recently returned by nextval() for the specified sequence in the current session.

The currval() function is very similar to the lastval() function, except that lastval() doesn’t require the name of a sequence like currval() does. That’s because lastval() doesn’t report on any particular sequence – it reports on the last time nextval() was used in the current session, regardless of which sequence was used. The currval() on the other hand, only reports on the specified sequence.

Continue reading

How LASTVAL() Works in PostgreSQL

In PostgreSQL, the lastval() function returns the value most recently returned by nextval() in the current session.

The lastval() function is very similar to the currval() function, except that lastval() doesn’t require the name of a sequence like currval() does. That’s because lastval() doesn’t report on any particular sequence – it reports on the last time nextval() was used in the current session, regardless of which sequence was used.

Continue reading

MySQL 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.

Continue reading

How CONVERT() Works in MySQL

In MySQL, CONVERT() is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.

We provide the value as an argument when we call the function, as well as the type that we want it converted to.

The CONVERT() function is similar to the CAST() function, which also converts between data types.

Continue reading