public inbox for [email protected]
help / color / mirror / Atom feedFrom: Christophe Pettus <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Can't dump new-style sequences independently from their tables.
Date: Wed, 3 Jul 2024 12:55:52 -0700
Message-ID: <[email protected]> (raw)
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 by GENERATED ALWAYS AS IDENTITY; you need to dump the owning table. It's easily worked around, but I'm curious why that is.
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Can't dump new-style sequences independently from their tables.
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox