Search Postgresql Archives

Can't dump new-style sequences independently from their tables.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux