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.

  1. Postgres Serial Java Type
  2. Postgresql Serial Insert
Active2 years, 3 months ago

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

Somnath GuhaSomnath Guha

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

Postgres serial java type
  • 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

Postgres Serial Java Type

dhke
11.7k2 gold badges25 silver badges47 bronze badges

Postgresql Serial Insert

Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged javapostgresqlbigint or ask your own question.