Serial Postgresql Java
This quickstart demonstrates how to connect to an Azure Database for PostgreSQL using a Java application. It shows how to use SQL statements to query, insert, update, and delete data in the database. The steps in this article assume that you are familiar with developing using Java, and are new to. Summary: in this tutorial, we will introduce you to the PostgreSQL SERIAL and show you how to use the serial to create an auto-increment column in a database table. Introduction to the PostgreSQL SERIAL pseudo-type. In PostgreSQL, a sequence is a special kind of database object that generates a sequence of integers.
I am trying to create Postgres table with Bigserial data type as a promary key. Once I am creating the table the table definition is getting changed to bigint NOT NULL DEFAULT nextval('transactions.transaction_id_seq'::regclass), to this. Please let me know why this happenning?
Thanks In Advance,Somnath
1 Answer
As noted in the documentation, serials are not 'real' data types, but rather convenience wrappers. If you create a serial column, you automatically get

- a new sequence ('tablename_columnname_seq`)
- an integer column of the appropriate type that takes its default value from the sequence.
- the setup for the column to use the sequence.
To quote:
The data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases).
is the same as
Which matches what you are getting.
dhke