From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Can't dump new-style sequences independently from their tables. |
Date: | 2024-07-03 19:55:52 |
Message-ID: | A64F0B8E-BA72-4182-8AA4-4CC7EAB6CBB7@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 by GENERATED ALWAYS AS IDENTITY; you need to dump the owning table. It's easily worked around, but I'm curious why that is.
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2024-07-03 19:56:33 | Re: Description field for tables and views |
Previous Message | Guyren Howe | 2024-07-03 19:45:07 | Re: Description field for tables and views |