What is the difference between serial and integer data types in Postgresql?

Asked

Viewed 3,030 times

2

I am creating a database in Postgresql and hit the doubt as I can create in the table the field ID with AUTO_INCREMENT, searching the internet I found some examples with the field ID with SERIAL data type and others with data type INTEGER.

What is the difference between these 2 types of data and what we can use to be our AUTO_INCREMENT ID in the Postgresql database?

1 answer

2


When defining a field as serial the bank creates a column of the type integer or biginteger with a sequence associated, it is responsible for increasing the number. If you create a field just like integer is in charge of the programmer the logic of how it will be incremented is to create a sequence by hand, via application etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.