public inbox for [email protected]
help / color / mirror / Atom feedFrom: Adrian Klaver <[email protected]>
To: Shaheed Haque <[email protected]>
Cc: pgsql-general list <[email protected]>
Subject: Re: Can I use pg_dump to save a sequence for a table that is not also being saved?
Date: Tue, 17 Mar 2026 10:43:37 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHAc2jcNTiR83D4qR-BkNc4kWbMD=7GhAw=oexiHtqmX003O6w@mail.gmail.com>
References: <CAHAc2jdyYM4U3Ts6Hed8GVYWMgNPo=kaBc3QpC5XoHEZ_5YAag@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAHAc2jcNTiR83D4qR-BkNc4kWbMD=7GhAw=oexiHtqmX003O6w@mail.gmail.com>
On 3/17/26 10:28 AM, Shaheed Haque wrote:
> Hi Adrian,
>
> Thanks for the kind replies, but it seems my email was not very clear...
>
> I was hoping, possibly foolishly, that specifying the wildcard in "--
> table=public.*id_seq" would dump the matched sequences, irrespective of
> whether the associated table data was being dumped. Is there a way to
> get just the sequences?
1) You are using --data-only which means you won't get the sequence
definition, only the statement to set the sequence value:
SELECT pg_catalog.setval('public.seq_test_line_id_seq', 1, false);
If the sequence is not already in the database instance the above will fail.
2) Sequences are an object that can be created as a stand alone which
you then use as needed or more generally these days as a dependent
object to a serial 'type' or a GENERATED ALWAYS AS IDENTITY attribute to
a column. In the latter cases the table needs to exist for the sequence
to have any relevance. In your case I'm thinking that the sequences you
want are tied to tables and in the case where you don't dump the
associated table the sequence data(pg_catalog.setval(...)) is not dumped
as there is no point.
>
> It is very possible that I am barking up the wrong tree with pg_dump,
> and what I need is some queries using the information_schema.
I'm going to say yes you will need to find another method. It would help
to know exactly what it is you want.
>
> Thanks, Shaheed
> --
> Adrian Klaver
> [email protected] <mailto:[email protected]>
>
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], [email protected]
Subject: Re: Can I use pg_dump to save a sequence for a table that is not also being saved?
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