How to use UUID as a database primary key? (Java and Postgres examples)

Kanan Rahimov
2 min readAug 18, 2023
UUID as Primary Key (with examples)

Topics: why use UUID?

Exploring the benefits of UUIDs as primary keys in Java projects with PostgreSQL.


  • Universally unique across tables
  • It can be used as a unique reference
  • - One table with all types