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

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