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.
Tag: what is
@@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.
What 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 reading3 PostgreSQL AUTO_INCREMENT Equivalents
In MySQL and MariaDB we can use the AUTO_INCREMENT
keyword to create an automatically incrementing column in a table. In SQLite, we’d use the AUTOINCREMENT
keyword. And in SQL Server we can use the IDENTITY
property. Some of those DBMSs also allow us to create sequence objects, which provide us with more options for creating an auto-increment type column.
When it comes to PostgreSQL, there are a few ways to create an auto-incrementing column. Below are three options for creating an AUTO_INCREMENT
style column in Postgres.
COLLATION() Function in MySQL
In MySQL, COLLATION()
is a built in function that returns the collation of its string argument.
We provide the string when we call the function.
Continue readingCHARSET() Function in MySQL
In MySQL, CHARSET()
is a built in function that returns the character set of its string argument.
We provide the string when we call the function.
Continue readingWhat is TCL?
When using relational database management systems (RDBMSs) we often hear terms like DDL, DML, DQL, DCL, and TCL. But what exactly are they?
In this article we’ll look at what TCL stands for in the context of SQL, and what it does.
Continue readingHow SERIAL Works in PostgreSQL
In PostgreSQL we can create auto-incrementing columns using the serial
data type. The serial
type causes the column to be automatically populated with an auto-incrementing value each time a new row is inserted. The same applies for the smallserial
and bigserial
types.
This article provides an overview of how these data types work.
Continue readingCreate an IDENTITY Column in PostgreSQL
Prior to PostgreSQL 10, if we wanted to create an auto-incrementing column, we would typically use the SERIAL
type, or we’d create our own sequence and apply it to an integer column.
But from PostgreSQL 10 onwards, we’ve been able to create identity columns.
Continue reading