I'd have expected the CREATE SEQUENCE and ALTER TABLE to be separate that can go in the post-data section, and be there even in schema-only dumps because it was easier for whoever added sections to pg_dump. After all, what really matters is the destination, not the journey.
On 10/29/25 07:47, kurt thepw.com wrote: > > < > < CREATE TABLE <schema>.<tablename> ( > < <other columns>, > < id bigint NOT NULL > < ); > < > > I've never seen a plaintext pg_dump output where the sequence > associated with a column in a table was not mentioned in s "DEFAULT > nextval(..." modifier in that column's line of the CREATE TABLE > statement, ex: > > < > < CREATE TABLE <schema>.<tbl> ( > < id integer DEFAULT nextval('<schema>.<seqname>'::regclass) NOT NULL, > < <next column>..., > < . . . . . > < );
That is for case where someone manually creates DEFAULT:
ALTER TABLE public.id_test ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( SEQUENCE NAME public.id_test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1 );
> > With the sequence already created earlier in the dump file. But then, > I've never before seen a table column with two associated sequences. > Maybe that is what makes pg_dump generate the > > "ALTER TABLE <schema>.<tablename> ALTER COLUMN id ADD GENERATED..." > > Statements.