Can't dump new-style sequences independently from their tables. - Mailing list pgsql-general

From Christophe Pettus
Subject Can't dump new-style sequences independently from their tables.
Date
Msg-id A64F0B8E-BA72-4182-8AA4-4CC7EAB6CBB7@thebuild.com
Whole thread Raw
List pgsql-general
Quick example:

xof=# CREATE TABLE t1 (id SERIAL PRIMARY KEY);
CREATE TABLE
xof=# CREATE TABLE t2 (id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY);
CREATE TABLE
xof=# \d+
                                       List of relations
 Schema |   Name    |   Type   | Owner | Persistence | Access method |    Size    | Description
--------+-----------+----------+-------+-------------+---------------+------------+-------------
 public | t1        | table    | xof   | permanent   | heap          | 0 bytes    |
 public | t1_id_seq | sequence | xof   | permanent   |               | 8192 bytes |
 public | t2        | table    | xof   | permanent   | heap          | 0 bytes    |
 public | t2_id_seq | sequence | xof   | permanent   |               | 8192 bytes |
(4 rows)

Swift:~ xof$ pg_dump -t 't1_id_seq' | fgrep 'setval'
SELECT pg_catalog.setval('public.t1_id_seq', 1, false);
Swift:~ xof$ pg_dump -t 't2_id_seq' | fgrep 'setval'
Swift:~ xof$ pg_dump -t 't2' | fgrep 'setval'
SELECT pg_catalog.setval('public.t2_id_seq', 1, false);
Swift:~ xof$

So, you can dump a sequence created with SERIAL independently from the table it is owned by, but not a sequence created
byGENERATED ALWAYS AS IDENTITY; you need to dump the owning table.  It's easily worked around, but I'm curious why that
is.


pgsql-general by date:

Previous
From: Guyren Howe
Date:
Subject: Re: Description field for tables and views
Next
From: Achilleas Mantzios
Date:
Subject: Re: Description field for tables and views