Is there a way to get pg_dump to exclude a specific sequence?
There are two cases:
The sequence to exclude is owned by a table you're also dumping (typical case:
SERIAL
column).
See: Dump a table without sequence table in postgres
Short answer: no, the sequence can't be left aside.The sequence is not owned by a dumped table. Then it can be excluded with the
--exclude-table
switch as if it was a table.
From pg_dump documentation:
-T table --exclude-table=table
Do not dump any tables matching the table pattern.
The pattern is interpreted according to the same rules as for -t
And about -t
:
-t table
--table=tableDump only tables (or views or sequences or foreign tables) matching table
If the sequence is owned by a table you can exclude both the sequence and the table using -T, such as:
pg_dump -T table -T table_id_seq