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.

Read more

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.

Read more

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.

Read more

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.

Read more

MySQL ROW_COUNT() Explained

In MySQL, ROW_COUNT() is a built-in function that returns the number of rows updated, inserted, or deleted by the preceding statement.

The value returned by ROW_COUNT() is often the same as the row count that the mysql client displays following statement execution, as well as the value from the mysql_affected_rows() C API function.

Read more

SQLite CHANGES() Function

The SQLite changes() function returns the number of database rows that were changed, inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers.

Basically, it allows us to see how many rows are affected when we run any of those statements.

Read more

FORMAT_BYTES() in MySQL

In MySQL, FORMAT_BYTES() is a built in function that converts a numeric byte count to a more human-readable format. It returns a string consisting of the value and a units indicator.

We provide the numeric byte count when we call the function.

Read more