我想从我的pg_dump命令中排除一个序列,该序列将输出放入一个普通文件中。
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
[我知道上面有一些我正在使用的表的开关,并且您可以结合pg_dump documentation中所述与pg_restore结合使用tar格式的数据库对象来启用/禁用它,但我不会使用pg_restore。
非常感谢
格雷厄姆
有两种情况:
要排除的顺序是归表所有,您也在转储(典型情况:SERIAL
列)。请参阅:Dump a table without sequence table in postgres简短的回答:不,序列不能搁置。
序列由转储表不拥有。然后可以使用--exclude-table
开关将其排除,就好像它是一个表一样。
来自pg_dump文档:
-T表--exclude-table = table
Do not dump any tables matching the table pattern.
根据与-t相同的规则解释该模式
关于-t
:
-t表--table = table
Dump only tables (or views or sequences or foreign tables) matching table
如果序列归表所有,则可以使用-T排除序列和表,例如:
pg_dump -T table -T table_id_seq