Reader small image

You're reading from  jOOQ Masterclass

Product typeBook
Published inAug 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800566897
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Anghel Leonard
Anghel Leonard
author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard

Right arrow

Using database sequences

To yield sequential numbers, databases such as PostgreSQL, SQL Server, and Oracle rely on sequences. A database sequence lives independently from tables – it can be associated with the primary key and non-primary key columns, it can be auto-generated (as in the case of PostgreSQL (BIG)SERIAL), it can be used across multiple tables, it can have independent permissions, it can have cycles, it can increment values in its own transactions to guarantee uniqueness across transactions using it, we can explicitly alter its values by setting minimum, maximum, increment, and current values, and so on.

For instance, let's consider the following sequence (employee_seq), defined in our PostgreSQL schema for the employee.employee_number primary key:

CREATE SEQUENCE "employee_seq" START 100000 INCREMENT 10 
       MINVALUE 100000 MAXVALUE 10000000 
       OWNED BY "employee...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
jOOQ Masterclass
Published in: Aug 2022Publisher: PacktISBN-13: 9781800566897

Author (1)

author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard