Skip to content

Instantly share code, notes, and snippets.

View ardentperf's full-sized avatar

Jeremy Schneider ardentperf

View GitHub Profile
@fabriziomello
fabriziomello / gapless_sequence.sql
Last active July 22, 2024 07:01
Gapless sequence example in PostgreSQL
CREATE TABLE public.gapless_sequence (
sequence_schema TEXT,
sequence_name TEXT,
last_value BIGINT DEFAULT 0,
step INTEGER DEFAULT 1
);
ALTER TABLE public.gapless_sequence
ADD CONSTRAINT gapless_sequence_pk PRIMARY KEY (sequence_schema, sequence_name);