Is there a way to get pg_dump to exclude a specific sequence?

后端 未结 2 1743
一向
一向 2021-02-05 09:00

I want to exclude a sequence from my pg_dump command which is putting the output into a plain file.

Command: /Library/PostgreSQL/8.4/bin/pg_dump --host localhos         


        
2条回答
  •  臣服心动
    2021-02-05 09:35

    There are two cases:

    1. 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.

    2. 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=table

    Dump only tables (or views or sequences or foreign tables) matching table
    

提交回复
热议问题