有没有办法让pg_dump排除特定序列? [英] Is there a way to get pg_dump to exclude a specific sequence?
问题描述
我想从我的pg_dump命令中排除一个序列,该序列将输出放入一个普通文件中。
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 localhost --port 5433 --username xxx --format plain --clean --inserts --verbose --file /Users/xxx/documents/output/SYSTEM_admin_20131126015325.sql --exclude-table public.table1 --exclude-table public.table2 mydatabase
我知道上面有一些我正在使用的表的开关,并且可以结合使用tar格式启用/禁用数据库对象如 pg_dump文档中所述,但我不会使用pg_restore。
I know there are switches for tables which i am using above and that you can enable/disable database objects in the tar format in combination with pg_restore as stated in the pg_dump documentation but I will not be using pg_restore.
非常感谢
Graham
推荐答案
有两种情况:
-
要排除的顺序归表所有 >您也在转储(典型情况:
SERIAL
列)。
请参阅:
简短的回答:不,不能将序列放在一边。
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.
该序列由转储表不拥有。然后可以使用-exclude-table
开关将其排除,就好像它是一个表一样。
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.
来自pg_dump文档:
From pg_dump documentation:
-T表
--exclude-table = table
-T table --exclude-table=table
Do not dump any tables matching the table pattern.
该模式根据与-t
大约 -t
:
-t表
--table = table
-t table
--table=table
Dump only tables (or views or sequences or foreign tables) matching table
这篇关于有没有办法让pg_dump排除特定序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!